summaryrefslogtreecommitdiff
path: root/tests/Network/BitTorrent/DHT/SessionSpec.hs
diff options
context:
space:
mode:
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