From a05838846d3ba3707173f30d1a9dad1136e98d53 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Sun, 26 Mar 2023 21:02:56 +0000 Subject: [PATCH] Adjust delay for simulation to complete in IOSim --- hydra-node/test/Hydra/ModelSpec.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hydra-node/test/Hydra/ModelSpec.hs b/hydra-node/test/Hydra/ModelSpec.hs index b02c3c1cfc2..7e5883455eb 100644 --- a/hydra-node/test/Hydra/ModelSpec.hs +++ b/hydra-node/test/Hydra/ModelSpec.hs @@ -219,16 +219,19 @@ prop_checkModel actions = property $ runIOSimProp $ do (WorldState{hydraParties, hydraState}, _symEnv) <- runActions actions - -- XXX: In the past we waited until the end of time here, which would - -- robustly catch all the remaining asynchronous actions, but we have - -- now a "more active" simulated chain which ticks away and not simply - -- detects a deadlock if we wait for infinity. Maybe cancelling the - -- simulation's 'tickThread' and wait then could work? + -- XXX: This wait time is arbitrary and corresponds to 3 "blocks" from + -- the underlying simulated chain which produces a block every 20s. It + -- should be enough to ensure all nodes' threads terminate their actions + -- and those gets picked up by the chain + run $ lift waitForAMinute let parties = Set.fromList $ deriveParty . fst <$> hydraParties nodes <- run $ gets nodes assert (parties == Map.keysSet nodes) forM_ parties $ \p -> do assertBalancesInOpenHeadAreConsistent hydraState nodes p + where + waitForAMinute :: MonadDelay m => m () + waitForAMinute = threadDelay 60 assertBalancesInOpenHeadAreConsistent :: GlobalState ->