diff options
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) | ||