summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/DHT/SessionSpec.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-01-21 19:03:16 -0500
committerjoe <joe@jerkface.net>2017-01-21 19:03:16 -0500
commitbff5b058b2caaeef335c2a50032df15fc23568f9 (patch)
tree0943e8771c06ae9f31fa45ce356c5adea7b6d1b8 /tests/Network/BitTorrent/DHT/SessionSpec.hs
parentb70401c23869b02a2fa1229b78e40aa824d9fbe2 (diff)
Test-suite build.
Diffstat (limited to 'tests/Network/BitTorrent/DHT/SessionSpec.hs')
-rw-r--r--tests/Network/BitTorrent/DHT/SessionSpec.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/Network/BitTorrent/DHT/SessionSpec.hs b/tests/Network/BitTorrent/DHT/SessionSpec.hs
index ef844b31..32e4c158 100644
--- a/tests/Network/BitTorrent/DHT/SessionSpec.hs
+++ b/tests/Network/BitTorrent/DHT/SessionSpec.hs
@@ -15,6 +15,7 @@ import Network.BitTorrent.Address
15import Network.BitTorrent.DHT 15import Network.BitTorrent.DHT
16import Network.BitTorrent.DHT.Message 16import Network.BitTorrent.DHT.Message
17import Network.BitTorrent.DHT.Session 17import Network.BitTorrent.DHT.Session
18import Network.BitTorrent.DHT.Query
18 19
19import Data.TorrentSpec () 20import Data.TorrentSpec ()
20import Network.BitTorrent.CoreSpec () 21import Network.BitTorrent.CoreSpec ()
@@ -68,7 +69,7 @@ spec = do
68 property $ \ (nid :: NodeId) -> do 69 property $ \ (nid :: NodeId) -> do
69 let info = NodeInfo nid myAddr 70 let info = NodeInfo nid myAddr
70 closest <- simpleDHT $ do 71 closest <- simpleDHT $ do
71 _ <- insertNode info 72 _ <- insertNode info Nothing
72 liftIO $ yield 73 liftIO $ yield
73 getClosest nid 74 getClosest nid
74 closest `shouldSatisfy` L.elem info 75 closest `shouldSatisfy` L.elem info
@@ -93,15 +94,15 @@ spec = do
93 it "should always ping this node" $ do 94 it "should always ping this node" $ do
94 (rid, tid) <- simpleDHT $ do 95 (rid, tid) <- simpleDHT $ do
95 (remoteId, Ping) <- queryNode myAddr Ping 96 (remoteId, Ping) <- queryNode myAddr Ping
96 thisId <- asks thisNodeId 97 thisId <- myNodeIdAccordingTo (read "8.8.8.8:6881")
97 return (remoteId, thisId) 98 return (remoteId, thisId)
98 rid `shouldBe` tid 99 rid `shouldBe` tid
99 100
100 describe "queryParallel" $ do 101 describe "queryParallel" $ do
101 it "should handle parallel requests" $ do 102 it "should handle parallel requests" $ do
102 (nid, resps) <- simpleDHT $ (,) 103 (nid, resps) <- simpleDHT $ do
103 <$> asks thisNodeId 104 me <- myNodeIdAccordingTo (read "8.8.8.8:6881")
104 <*> queryParallel (L.replicate 100 $ queryNode myAddr Ping) 105 ( (,) me ) <$> queryParallel (L.replicate 100 $ queryNode myAddr Ping)
105 resps `shouldSatisfy` L.all (== (nid, Ping)) 106 resps `shouldSatisfy` L.all (== (nid, Ping))
106 107
107 describe "(<@>) operator" $ do 108 describe "(<@>) operator" $ do