Skip to content

Commit

Permalink
Merge pull request #1382 from input-output-hk/avoid-rollback-race-con…
Browse files Browse the repository at this point in the history
…dition

Limit rollback frequency in MockChain
  • Loading branch information
v0d1ch authored Apr 3, 2024
2 parents c9d3553 + d55f09f commit da65f88
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hydra-node/test/Hydra/Model/MockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ mockChainAndNetwork tr seedKeys commits = do
doRollBackward nodes chain numberOfBlocks
replicateM_ (fromIntegral numberOfBlocks) $
doRollForward nodes chain
-- NOTE: There seems to be a race condition on multiple consecutive
-- rollbackAndForward calls, which would require some minimal (1ms) delay
-- here. However, waiting here for one blockTime is not wrong and enforces
-- rollbacks / chain switches to be not more often than blocks being added.
threadDelay blockTime

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

0 comments on commit da65f88

Please sign in to comment.