diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-05 01:57:15 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-05 01:57:15 +0400 |
commit | 5233bacca87058537323ac71748cb626f30dec54 (patch) | |
tree | aaf315ca4f9d58467a3602007744837c0a7d97ad /tests | |
parent | 776ee76f903768a65e928211ec0ad7c51d55a7a2 (diff) |
+ add THP
Diffstat (limited to 'tests')
-rw-r--r-- | tests/client.hs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/client.hs b/tests/client.hs index 2b626241..bab11b11 100644 --- a/tests/client.hs +++ b/tests/client.hs | |||
@@ -1,12 +1,19 @@ | |||
1 | module Main (main) where | 1 | module Main (main) where |
2 | 2 | ||
3 | import Data.Torrent | ||
4 | import Network.Torrent.THP | ||
5 | import System.Environment | 3 | import System.Environment |
6 | import Data.ByteString as B | 4 | import Data.ByteString as B |
7 | import Data.ByteString.Lazy as L | 5 | import Data.ByteString.Lazy as L |
8 | import Data.BEncode | 6 | import Data.BEncode |
9 | 7 | ||
8 | import Data.Torrent | ||
9 | import Network.Torrent.THP | ||
10 | import Network.Torrent.PeerID | ||
11 | |||
12 | showWarn :: TResponse -> IO () | ||
13 | showWarn resp | ||
14 | | Just msg <- respWarning resp = print msg | ||
15 | | otherwise = return () | ||
16 | |||
10 | main :: IO () | 17 | main :: IO () |
11 | main = do | 18 | main = do |
12 | [path] <- getArgs | 19 | [path] <- getArgs |
@@ -14,6 +21,7 @@ main = do | |||
14 | 21 | ||
15 | let Right contents' = decode contents >>= return . L.toStrict . encode | 22 | let Right contents' = decode contents >>= return . L.toStrict . encode |
16 | print (contents' == contents) | 23 | print (contents' == contents) |
24 | |||
17 | -- let (a, b) = showInfos contents | 25 | -- let (a, b) = showInfos contents |
18 | -- print b | 26 | -- print b |
19 | -- print a | 27 | -- print a |
@@ -22,7 +30,10 @@ main = do | |||
22 | let Right b = decode contents | 30 | let Right b = decode contents |
23 | let Right t = fromBEncode b | 31 | let Right t = fromBEncode b |
24 | 32 | ||
33 | peerID <- newPeerID | ||
34 | |||
35 | let req = defaultRequest (tAnnounce t) (tInfoHash t) (peerID) | ||
36 | Right resp <- sendRequest req | ||
25 | 37 | ||
26 | let req = defaultRequest (tAnnounce t) (tInfoHash t) | ||
27 | resp <- sendRequest req | ||
28 | print resp | 38 | print resp |
39 | showWarn resp | ||