diff options
Diffstat (limited to 'tests/client.hs')
-rw-r--r-- | tests/client.hs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/tests/client.hs b/tests/client.hs deleted file mode 100644 index bab11b11..00000000 --- a/tests/client.hs +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | module Main (main) where | ||
2 | |||
3 | import System.Environment | ||
4 | import Data.ByteString as B | ||
5 | import Data.ByteString.Lazy as L | ||
6 | import Data.BEncode | ||
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 | |||
17 | main :: IO () | ||
18 | main = do | ||
19 | [path] <- getArgs | ||
20 | contents <- B.readFile path | ||
21 | |||
22 | let Right contents' = decode contents >>= return . L.toStrict . encode | ||
23 | print (contents' == contents) | ||
24 | |||
25 | -- let (a, b) = showInfos contents | ||
26 | -- print b | ||
27 | -- print a | ||
28 | -- print (encode b == encoded a) | ||
29 | |||
30 | let Right b = decode contents | ||
31 | let Right t = fromBEncode b | ||
32 | |||
33 | peerID <- newPeerID | ||
34 | |||
35 | let req = defaultRequest (tAnnounce t) (tInfoHash t) (peerID) | ||
36 | Right resp <- sendRequest req | ||
37 | |||
38 | print resp | ||
39 | showWarn resp | ||