summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam T <sta.cs.vsu@gmail.com>2013-04-05 01:57:15 +0400
committerSam T <sta.cs.vsu@gmail.com>2013-04-05 01:57:15 +0400
commit5233bacca87058537323ac71748cb626f30dec54 (patch)
treeaaf315ca4f9d58467a3602007744837c0a7d97ad /tests
parent776ee76f903768a65e928211ec0ad7c51d55a7a2 (diff)
+ add THP
Diffstat (limited to 'tests')
-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