diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 22:26:53 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 22:26:53 +0400 |
commit | e8d8650941642ac1619e66dfb605d6a81973c332 (patch) | |
tree | 627a337e76c8cde65c648ef603cc6e09c815d55e /tests/Network/BitTorrent | |
parent | 03e4888687698d8a8d421c9f894bcabf0e950568 (diff) |
Test parallel DHT queries
Diffstat (limited to 'tests/Network/BitTorrent')
-rw-r--r-- | tests/Network/BitTorrent/DHT/SessionSpec.hs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/Network/BitTorrent/DHT/SessionSpec.hs b/tests/Network/BitTorrent/DHT/SessionSpec.hs index 343c8ab6..c936dd1b 100644 --- a/tests/Network/BitTorrent/DHT/SessionSpec.hs +++ b/tests/Network/BitTorrent/DHT/SessionSpec.hs | |||
@@ -1,5 +1,7 @@ | |||
1 | {-# LANGUAGE ScopedTypeVariables #-} | 1 | {-# LANGUAGE ScopedTypeVariables #-} |
2 | module Network.BitTorrent.DHT.SessionSpec (spec) where | 2 | module Network.BitTorrent.DHT.SessionSpec (spec) where |
3 | import Control.Applicative | ||
4 | import Control.Concurrent | ||
3 | import Control.Monad.Reader | 5 | import Control.Monad.Reader |
4 | import Control.Monad.Trans.Resource | 6 | import Control.Monad.Trans.Resource |
5 | import Data.Default | 7 | import Data.Default |
@@ -57,8 +59,15 @@ spec = do | |||
57 | isOk <- simpleDHT (checkToken addr token) | 59 | isOk <- simpleDHT (checkToken addr token) |
58 | isOk `shouldBe` False | 60 | isOk `shouldBe` False |
59 | 61 | ||
60 | describe "routing table" $ do | 62 | describe "routing table" $ |
61 | return () | 63 | it "accept any node entry when table is empty" $ |
64 | property $ \ (nid :: NodeId) -> do | ||
65 | let info = NodeInfo nid myAddr | ||
66 | closest <- simpleDHT $ do | ||
67 | insertNode info | ||
68 | liftIO $ yield | ||
69 | getClosest nid | ||
70 | closest `shouldSatisfy` L.elem info | ||
62 | 71 | ||
63 | describe "peer storage" $ do | 72 | describe "peer storage" $ do |
64 | it "should return nodes, if there are no peers" $ property $ \ ih -> do | 73 | it "should return nodes, if there are no peers" $ property $ \ ih -> do |
@@ -72,7 +81,8 @@ spec = do | |||
72 | res `shouldSatisfy` isRight | 81 | res `shouldSatisfy` isRight |
73 | 82 | ||
74 | describe "topic storage" $ do | 83 | describe "topic storage" $ do |
75 | return () | 84 | it "should not grow indefinitely" $ do |
85 | pending | ||
76 | 86 | ||
77 | describe "messaging" $ do | 87 | describe "messaging" $ do |
78 | describe "queryNode" $ do | 88 | describe "queryNode" $ do |
@@ -84,7 +94,12 @@ spec = do | |||
84 | rid `shouldBe` tid | 94 | rid `shouldBe` tid |
85 | 95 | ||
86 | describe "queryParallel" $ do | 96 | describe "queryParallel" $ do |
87 | return () | 97 | it "should handle parallel requests" $ do |
98 | (nid, resps) <- simpleDHT $ (,) | ||
99 | <$> asks thisNodeId | ||
100 | <*> queryParallel (L.replicate 100 $ queryNode myAddr Ping) | ||
101 | resps `shouldSatisfy` L.all (== (nid, Ping)) | ||
88 | 102 | ||
89 | describe "(<@>) operator" $ do | 103 | describe "(<@>) operator" $ do |
90 | return () \ No newline at end of file | 104 | it "" $ |
105 | pending \ No newline at end of file | ||