Skip to content

Commit 365aba2

Browse files
committed
reduce the frequency of client and server diverging before they reach startTick
the generator for startTick is now heavily weighted to pick a lower value
1 parent 85f7348 commit 365aba2

File tree

1 file changed

+8
-1
lines changed
  • ouroboros-consensus/test/consensus-test/Test/Consensus/MiniProtocol/ChainSync

1 file changed

+8
-1
lines changed

ouroboros-consensus/test/consensus-test/Test/Consensus/MiniProtocol/ChainSync/Client.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ instance Arbitrary ChainSyncClientSetup where
766766
, lastTick (getClientUpdates clientUpdates) - 1
767767
, lastTick (getServerUpdates serverUpdates) - 1
768768
]
769-
startTick <- choose (1, maxStartTick)
769+
startTick <- chooseExponential 3 (1, maxStartTick)
770770
let trapBlocks =
771771
[ blockHash b
772772
| AddBlock b <- joinSchedule (getServerUpdates serverUpdates)
@@ -829,6 +829,13 @@ instance Arbitrary ChainSyncClientSetup where
829829
, y <- shrink x
830830
]
831831

832+
chooseExponential :: Enum a => Int -> (a, a) -> Gen a
833+
chooseExponential decayFactor (low, up) =
834+
frequency
835+
[ (decayFactor, pure low)
836+
, (1, chooseExponential decayFactor (succ low, up))
837+
]
838+
832839
prettyChainSyncClientSetup :: ChainSyncClientSetup -> String
833840
prettyChainSyncClientSetup testSetup =
834841
unlines

0 commit comments

Comments
 (0)