From 2027b99f7a12986c6c0cb9d3205e0893fba17c9a Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Fri, 13 Dec 2013 14:05:00 +0400 Subject: Update client example --- tests/Network/BitTorrent/Tracker/RPCSpec.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/Network/BitTorrent/Tracker/RPCSpec.hs (limited to 'tests/Network/BitTorrent/Tracker') 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 @@ +module Network.BitTorrent.Tracker.RPCSpec (spec) where +import Control.Monad +import Data.Default +import Data.List as L +import Network.URI +import Test.Hspec + +import Network.BitTorrent.Tracker.MessageSpec hiding (spec) +import Network.BitTorrent.Tracker.RPC.HTTPSpec as HTTP hiding (spec) +import Network.BitTorrent.Tracker.RPC.UDPSpec as UDP hiding (spec) +import Network.BitTorrent.Tracker.RPC as RPC + +uris :: [URI] +uris = UDP.trackerURIs ++ HTTP.trackerURIs + +spec :: Spec +spec = do + forM_ uris $ \ uri -> + context (show uri) $ do + describe "announce" $ do + it "have valid response" $ do + q <- arbitrarySample + info <- connect uri >>= announce q + validateInfo q info + + describe "scrape" $ do + it "have valid response" $ do + xs <- connect uri >>= scrape [def] + L.length xs `shouldSatisfy` (>= 1) -- cgit v1.2.3