summaryrefslogtreecommitdiff
path: root/tests/client.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/client.hs')
-rw-r--r--tests/client.hs19
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 @@
1module Main (main) where 1module Main (main) where
2 2
3import Data.Torrent
4import Network.Torrent.THP
5import System.Environment 3import System.Environment
6import Data.ByteString as B 4import Data.ByteString as B
7import Data.ByteString.Lazy as L 5import Data.ByteString.Lazy as L
8import Data.BEncode 6import Data.BEncode
9 7
8import Data.Torrent
9import Network.Torrent.THP
10import Network.Torrent.PeerID
11
12showWarn :: TResponse -> IO ()
13showWarn resp
14 | Just msg <- respWarning resp = print msg
15 | otherwise = return ()
16
10main :: IO () 17main :: IO ()
11main = do 18main = 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