summaryrefslogtreecommitdiff
path: root/tests/Network
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-26 16:50:33 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-26 16:50:33 +0400
commitfa01c6b1b3918b5dc68933ad18a7ce930788338b (patch)
tree973df1368194c201e3ab3f171f4d7012a6993c51 /tests/Network
parentd08a9456ee79d57d7060a9d71064c73a619428c6 (diff)
Test TimeoutExpired exceptions
Diffstat (limited to 'tests/Network')
-rw-r--r--tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs16
-rw-r--r--tests/Network/BitTorrent/Tracker/TestData.hs6
2 files changed, 16 insertions, 6 deletions
diff --git a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
index 57680a5b..acc60e09 100644
--- a/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
+++ b/tests/Network/BitTorrent/Tracker/RPC/UDPSpec.hs
@@ -36,6 +36,10 @@ rpcOpts = def
36 , optMaxTimeout = 10 36 , optMaxTimeout = 10
37 } 37 }
38 38
39isTimeoutExpired :: RpcException -> Bool
40isTimeoutExpired (TimeoutExpired _) = True
41isTimeoutExpired _ = False
42
39spec :: Spec 43spec :: Spec
40spec = parallel $ do 44spec = parallel $ do
41 forM_ (L.filter isUdpTracker trackers) $ \ TrackerEntry {..} -> 45 forM_ (L.filter isUdpTracker trackers) $ \ TrackerEntry {..} ->
@@ -48,8 +52,10 @@ spec = parallel $ do
48 q <- arbitrarySample 52 q <- arbitrarySample
49 announce mgr trackerURI q >>= validateInfo q 53 announce mgr trackerURI q >>= validateInfo q
50 else do 54 else do
51 it "should throw TrackerNotResponding" $ do 55 it "should throw TimeoutExpired" $ do
52 pending 56 withManager rpcOpts $ \ mgr -> do
57 q <- arbitrarySample
58 announce mgr trackerURI q `shouldThrow` isTimeoutExpired
53 59
54 describe "scrape" $ do 60 describe "scrape" $ do
55 if tryScraping then do 61 if tryScraping then do
@@ -58,9 +64,9 @@ spec = parallel $ do
58 xs <- scrape mgr trackerURI [def] 64 xs <- scrape mgr trackerURI [def]
59 L.length xs `shouldSatisfy` (>= 1) 65 L.length xs `shouldSatisfy` (>= 1)
60 else do 66 else do
61 it "should throw TrackerNotResponding" $ do 67 it "should throw TimeoutExpired" $ do
62 pending 68 withManager rpcOpts $ \ mgr -> do
63 69 scrape mgr trackerURI [def] `shouldThrow` isTimeoutExpired
64 70
65 describe "Manager" $ do 71 describe "Manager" $ do
66 when tryScraping $ do 72 when tryScraping $ do
diff --git a/tests/Network/BitTorrent/Tracker/TestData.hs b/tests/Network/BitTorrent/Tracker/TestData.hs
index 85544b91..22077e90 100644
--- a/tests/Network/BitTorrent/Tracker/TestData.hs
+++ b/tests/Network/BitTorrent/Tracker/TestData.hs
@@ -72,7 +72,11 @@ notWorking name uri = (trackerEntry uri)
72trackers :: [TrackerEntry] 72trackers :: [TrackerEntry]
73trackers = 73trackers =
74 [ announceOnly "LinuxTracker" 74 [ announceOnly "LinuxTracker"
75 "http://linuxtracker.org:2710/00000000000000000000000000000000/announce" 75 "http://linuxtracker.org:2710/00000000000000000000000000000000/announce"
76
77 -- from "http://www.linux23.com/"
78 , announceScrape "Arch" "http://tracker.archlinux.org:6969/announce"
79 , notWorking "rarbg" "udp://9.rarbg.com:2710/announce"
76 80
77 , announceScrape "OpenBitTorrent" "udp://tracker.openbittorrent.com:80/announce" 81 , announceScrape "OpenBitTorrent" "udp://tracker.openbittorrent.com:80/announce"
78 , announceScrape "PublicBT" "udp://tracker.publicbt.com:80/announce" 82 , announceScrape "PublicBT" "udp://tracker.publicbt.com:80/announce"