From 21e1fdde98a2e263bf8dfc34a2545b0635e358c8 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 21 Jan 2017 19:38:06 -0500 Subject: Routing table is idempotent test. --- tests/Main.hs | 4 ++-- tests/Network/BitTorrent/DHT/RoutingSpec.hs | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/Main.hs b/tests/Main.hs index 2f249945..5ed953da 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -13,7 +13,7 @@ import Text.Printf import Test.Hspec import Config -import Spec +import qualified Spec as Generated type Command = String @@ -80,7 +80,7 @@ terminateEnv = do runTestSuite :: [String] -> IO ExitCode runTestSuite args = do _ <- printf "running hspec test suite with args: %s\n" (show args) - catch (withArgs args (hspec spec) >> return ExitSuccess) return + catch (withArgs args (hspec Generated.spec) >> return ExitSuccess) return withEnv :: EnvOpts -> IO a -> IO a withEnv opts action = bracket (setupEnv opts) terminate (const action) diff --git a/tests/Network/BitTorrent/DHT/RoutingSpec.hs b/tests/Network/BitTorrent/DHT/RoutingSpec.hs index 6c0caad5..07a906ba 100644 --- a/tests/Network/BitTorrent/DHT/RoutingSpec.hs +++ b/tests/Network/BitTorrent/DHT/RoutingSpec.hs @@ -69,12 +69,9 @@ spec = do let justOnce x = L.length (L.filter (L.elem x) xss) == 1 L.all justOnce (L.concat xss) - it "insert is idemponent" $ do - pending -{- - property $ \ (e :: Env Int) n t -> do - - let t1 = runSimulation e (T.insert n t) - let t2 = runSimulation e (T.insert n t >>= T.insert n) + it "insert is idemponent" $ property $ \ (e :: Env Int) n t -> do + let ins :: NodeInfo Int -> Table Int -> Routing Int (Table Int) + ins n t = snd <$> T.insert (currentTime e) (TryInsert n) t + let t1 = runSimulation e (ins n t) + let t2 = runSimulation e (ins n t >>= ins n) t1 `shouldBe` t2 --} -- cgit v1.2.3