summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/Tracker
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-01 14:28:58 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-01 14:28:58 +0400
commit541ffe4b36e53dc57926ef70f1a41caf0c114b58 (patch)
tree511a3036cfa27d2ac057f34b3ffe3e0a3b616068 /tests/Network/BitTorrent/Tracker
parent1188f4bcfccf578ab9bec286108ad3c4e8296b13 (diff)
Add basic tests for tracker HTTP rpc
Diffstat (limited to 'tests/Network/BitTorrent/Tracker')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs
new file mode 100644
index 00000000..141a2597
--- /dev/null
+++ b/tests/Network/BitTorrent/Tracker/RPC/HTTPSpec.hs
@@ -0,0 +1,35 @@
1module Network.BitTorrent.Tracker.RPC.HTTPSpec (spec) where
2
3import Control.Monad
4import Control.Monad.Trans
5import Control.Monad.Trans.Resource
6import Data.Default
7import Data.List as L
8import Data.Maybe
9import Network.URI
10import Test.Hspec
11
12import Network.BitTorrent.Tracker.RPC.MessageSpec hiding (spec)
13import Network.BitTorrent.Tracker.RPC.HTTP
14
15
16trackerURIs :: [URI]
17trackerURIs =
18 [ fromJust $ parseURI "http://announce.opensharing.org:2710/announce"
19 , fromJust $ parseURI "http://exodus.desync.com/announce"
20 ]
21
22spec :: Spec
23spec = do
24 forM_ trackerURIs $ \ uri ->
25 context (show uri) $ do
26 describe "announce" $ do
27 it "have valid response" $ do
28 q <- arbitrarySample
29 info <- runResourceT $ connect uri >>= announce q
30 validateInfo q info
31
32 describe "scrape" $ do
33 it "have valid response" $ do
34 xs <- runResourceT $ connect uri >>= scrape [def]
35 L.length xs `shouldSatisfy` (>= 1)