diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-13 14:05:00 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-13 14:05:00 +0400 |
commit | 2027b99f7a12986c6c0cb9d3205e0893fba17c9a (patch) | |
tree | 042e0471bcfc4a125ce479dff17df4fc89aee008 /tests | |
parent | 8ddb71a490ec862d1df626b7eb9300d9ddb782f3 (diff) |
Update client example
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Network/BitTorrent/Tracker/RPCSpec.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPCSpec.hs b/tests/Network/BitTorrent/Tracker/RPCSpec.hs new file mode 100644 index 00000000..6bc72e86 --- /dev/null +++ b/tests/Network/BitTorrent/Tracker/RPCSpec.hs | |||
@@ -0,0 +1,29 @@ | |||
1 | module Network.BitTorrent.Tracker.RPCSpec (spec) where | ||
2 | import Control.Monad | ||
3 | import Data.Default | ||
4 | import Data.List as L | ||
5 | import Network.URI | ||
6 | import Test.Hspec | ||
7 | |||
8 | import Network.BitTorrent.Tracker.MessageSpec hiding (spec) | ||
9 | import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec) | ||
10 | import Network.BitTorrent.Tracker.RPC.UDPSpec as UDP hiding (spec) | ||
11 | import Network.BitTorrent.Tracker.RPC as RPC | ||
12 | |||
13 | uris :: [URI] | ||
14 | uris = UDP.trackerURIs ++ HTTP.trackerURIs | ||
15 | |||
16 | spec :: Spec | ||
17 | spec = do | ||
18 | forM_ uris $ \ uri -> | ||
19 | context (show uri) $ do | ||
20 | describe "announce" $ do | ||
21 | it "have valid response" $ do | ||
22 | q <- arbitrarySample | ||
23 | info <- connect uri >>= announce q | ||
24 | validateInfo q info | ||
25 | |||
26 | describe "scrape" $ do | ||
27 | it "have valid response" $ do | ||
28 | xs <- connect uri >>= scrape [def] | ||
29 | L.length xs `shouldSatisfy` (>= 1) | ||