From 34cf40470f0b7df573f84492b9649ad0d40dc1fd Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Tue, 21 May 2024 11:34:15 +0200 Subject: [PATCH] Identify messages by prefixing a,b,c Also trace dropped messages and this seems to be always only dropping data messages. Where are the pings? --- .../test/Hydra/Network/ReliabilitySpec.hs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hydra-node/test/Hydra/Network/ReliabilitySpec.hs b/hydra-node/test/Hydra/Network/ReliabilitySpec.hs index bdbcebdb560..de7c9dbbbff 100644 --- a/hydra-node/test/Hydra/Network/ReliabilitySpec.hs +++ b/hydra-node/test/Hydra/Network/ReliabilitySpec.hs @@ -214,7 +214,7 @@ mockMessagePersistence numberOfParties = do , appendMessage = \msg -> atomically $ modifyTVar' messages (|> msg) } -prop_stressTest :: Int -> Int -> Int -> Int -> Property +prop_stressTest :: Natural -> Natural -> Natural -> Int -> Property prop_stressTest nAlice nBob nCarol seed = within 1000000 $ conjoin @@ -228,9 +228,13 @@ prop_stressTest nAlice nBob nCarol seed = ] & cover 1 (duplicates aliceReceived > 0) "resends seen by alice" where - aliceMessages = [1 .. nAlice] - bobMessages = [1 .. nBob] - carolMessages = [1 .. nCarol] + aliceMessages = ("a" <>) . show <$> [1 .. nAlice] + bobMessages = ("b" <>) . show <$> [1 .. nBob] + carolMessages = ("c" <>) . show <$> [1 .. nCarol] + + onlyData = rights + + unAuthenticated = map (\Authenticated{payload} -> payload) duplicates msgs = length msgs - length (nub msgs) @@ -259,11 +263,7 @@ prop_stressTest nAlice nBob nCarol seed = (,,) <$> (onlyData <$> getAliceMessages) <*> (onlyData <$> getBobMessages) <*> (onlyData <$> getCarolMessages) - onlyData = rights - - unAuthenticated = map (\Authenticated{payload} -> payload) - - createSometimesFailingNetwork :: MonadSTM m => m (Party -> m (NewNetwork m (Authenticated msg) msg)) + createSometimesFailingNetwork :: (MonadSTM m, Show msg) => m (Party -> m (NewNetwork m (Authenticated msg) msg)) createSometimesFailingNetwork = do stdGenV <- newTVarIO $ mkStdGen seed peerMapV <- newTVarIO mempty @@ -280,7 +280,8 @@ prop_stressTest nAlice nBob nCarol seed = -- drop 2% of messages r <- randomNumber stdGenV if (p == party || r < 0.02) - then pure () -- drop + then -- FIXME: Seems like we are only dropping 'Data', where are the pings? + trace ("dropping: " <> show msg) $ pure () else send (Authenticated msg party) -- calls receiveMessage on the other end , onMessageReceived }