diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 01:45:12 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 01:45:12 +0400 |
commit | 81b71a4a9f0a6f9fd64de08d2dd22303b169a076 (patch) | |
tree | 5e364431594649ab2376006f1174b2fddceffc3b /tests/Network | |
parent | 879074f286a602848d3edff10de36e88a9622cbc (diff) |
Return Bool instead of raising exception in checkToken
Diffstat (limited to 'tests/Network')
-rw-r--r-- | tests/Network/BitTorrent/DHT/SessionSpec.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/Network/BitTorrent/DHT/SessionSpec.hs b/tests/Network/BitTorrent/DHT/SessionSpec.hs index 75c95462..3e197875 100644 --- a/tests/Network/BitTorrent/DHT/SessionSpec.hs +++ b/tests/Network/BitTorrent/DHT/SessionSpec.hs | |||
@@ -2,6 +2,7 @@ | |||
2 | module Network.BitTorrent.DHT.SessionSpec (spec) where | 2 | module Network.BitTorrent.DHT.SessionSpec (spec) where |
3 | import Control.Monad.Reader | 3 | import Control.Monad.Reader |
4 | import Data.Default | 4 | import Data.Default |
5 | import Data.List as L | ||
5 | import Test.Hspec | 6 | import Test.Hspec |
6 | import Test.QuickCheck | 7 | import Test.QuickCheck |
7 | 8 | ||
@@ -33,14 +34,17 @@ spec = do | |||
33 | describe "tokens" $ do | 34 | describe "tokens" $ do |
34 | it "should not complain about valid token" $ | 35 | it "should not complain about valid token" $ |
35 | property $ \ (addrs :: [NodeAddr IPv4]) -> do | 36 | property $ \ (addrs :: [NodeAddr IPv4]) -> do |
36 | simpleDHT $ do | 37 | isOks <- simpleDHT $ do |
37 | forM_ addrs $ \ addr -> do | 38 | forM addrs $ \ addr -> do |
38 | token <- grantToken addr | 39 | token <- grantToken addr |
39 | checkToken addr token | 40 | checkToken addr token |
40 | {- | 41 | L.and isOks `shouldBe` True |
41 | it "" $ property $ \ (addr :: NodeAddr IPv4) token -> do | 42 | |
42 | simpleDHT (checkToken addr token) `shouldThrow` (== undefined) | 43 | it "should complain about invalid token" $ |
43 | -} | 44 | property $ \ (addr :: NodeAddr IPv4) token -> do |
45 | isOk <- simpleDHT (checkToken addr token) | ||
46 | isOk `shouldBe` False | ||
47 | |||
44 | describe "routing table" $ do | 48 | describe "routing table" $ do |
45 | return () | 49 | return () |
46 | 50 | ||