Skip to content

Commit d55f09f

Browse files
ch1bov0d1ch
authored andcommitted
Limit rollback frequency in MockChain
Multiple consecutive invocations of rollbackAndForward on the MockChain seem to be prone to a race condition. However, it is unrealistic that chain forks happen more often than seeing new blocks (only when we learn about a new block the node would consider switching).
1 parent c9d3553 commit d55f09f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hydra-node/test/Hydra/Model/MockChain.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ mockChainAndNetwork tr seedKeys commits = do
269269
doRollBackward nodes chain numberOfBlocks
270270
replicateM_ (fromIntegral numberOfBlocks) $
271271
doRollForward nodes chain
272+
-- NOTE: There seems to be a race condition on multiple consecutive
273+
-- rollbackAndForward calls, which would require some minimal (1ms) delay
274+
-- here. However, waiting here for one blockTime is not wrong and enforces
275+
-- rollbacks / chain switches to be not more often than blocks being added.
276+
threadDelay blockTime
272277

273278
doRollBackward nodes chain nbBlocks = do
274279
(slotNum, position, blocks, _) <- readTVarIO chain

0 commit comments

Comments
 (0)