diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-03 01:13:59 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-03 01:13:59 +0400 |
commit | 0ccce42b773783341765ef751ea6d962f70d593c (patch) | |
tree | 6a1e6418edf964c123372e52f03896dda471e26f /tests/client.hs | |
parent | 8f5985915ece236a29fcb340e1e0ef731e3214e9 (diff) |
+ tests
Diffstat (limited to 'tests/client.hs')
-rw-r--r-- | tests/client.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/client.hs b/tests/client.hs new file mode 100644 index 00000000..5697d18a --- /dev/null +++ b/tests/client.hs | |||
@@ -0,0 +1,27 @@ | |||
1 | module Main (main) where | ||
2 | |||
3 | import Data.Torrent | ||
4 | import Network.Torrent.THP | ||
5 | import System.Environment | ||
6 | import Data.ByteString as B | ||
7 | import Data.ByteString.Lazy as L | ||
8 | import Data.BEncode | ||
9 | |||
10 | main :: IO () | ||
11 | main = do | ||
12 | [path] <- getArgs | ||
13 | contents <- B.readFile path | ||
14 | |||
15 | let Right contents' = decode contents >>= return . L.toStrict . encode | ||
16 | print (contents' == contents) | ||
17 | -- let (a, b) = showInfos contents | ||
18 | -- print b | ||
19 | -- print a | ||
20 | -- print (encode b == encoded a) | ||
21 | |||
22 | let Right b = decode contents | ||
23 | let Right t = fromBEncode b | ||
24 | |||
25 | let req = defaultRequest (tAnnounce t) (tInfoHash t) | ||
26 | resp <- sendRequest req | ||
27 | print resp | ||