summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker/RPCSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Network/BitTorrent/Tracker/RPCSpec.hs')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPCSpec.hs21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPCSpec.hs b/tests/Network/BitTorrent/Tracker/RPCSpec.hs
index 6bc72e86..340754d3 100644
--- a/tests/Network/BitTorrent/Tracker/RPCSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/RPCSpec.hs
@@ -1,9 +1,11 @@
1module Network.BitTorrent.Tracker.RPCSpec (spec) where 1module Network.BitTorrent.Tracker.RPCSpec (spec) where
2import Control.Applicative
2import Control.Monad 3import Control.Monad
3import Data.Default 4import Data.Default
4import Data.List as L 5import Data.List as L
5import Network.URI 6import Network.URI
6import Test.Hspec 7import Test.Hspec
8import Test.QuickCheck
7 9
8import Network.BitTorrent.Tracker.MessageSpec hiding (spec) 10import Network.BitTorrent.Tracker.MessageSpec hiding (spec)
9import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec) 11import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec)
@@ -13,17 +15,26 @@ import Network.BitTorrent.Tracker.RPC as RPC
13uris :: [URI] 15uris :: [URI]
14uris = UDP.trackerURIs ++ HTTP.trackerURIs 16uris = UDP.trackerURIs ++ HTTP.trackerURIs
15 17
18pinfo :: PeerInfo
19pinfo = PeerInfo "-HS0003-203534.37422" 6000 Nothing
20
21instance Arbitrary SAnnounceQuery where
22 arbitrary = SAnnounceQuery <$> arbitrary <*> arbitrary
23 <*> arbitrary <*> arbitrary
24
16spec :: Spec 25spec :: Spec
17spec = do 26spec = do
18 forM_ uris $ \ uri -> 27 forM_ uris $ \ uri ->
19 context (show uri) $ do 28 context (show uri) $ do
20 describe "announce" $ do 29 describe "announce" $ do
21 it "have valid response" $ do 30 it "have valid response" $ do
22 q <- arbitrarySample 31 withManager def pinfo $ \ mgr -> do
23 info <- connect uri >>= announce q 32 q <- arbitrarySample
24 validateInfo q info 33 info <- announce mgr uri q
34 return ()
25 35
26 describe "scrape" $ do 36 describe "scrape" $ do
27 it "have valid response" $ do 37 it "have valid response" $ do
28 xs <- connect uri >>= scrape [def] 38 withManager def pinfo $ \ mgr -> do
29 L.length xs `shouldSatisfy` (>= 1) 39 xs <- scrape mgr uri [def]
40 L.length xs `shouldSatisfy` (>= 1)