Skip to content

Commit c07561d

Browse files
Drop random points from adversarial schedules in the time limited leashing attack
1 parent 3830c19 commit c07561d

File tree

1 file changed

+5
-4
lines changed
  • ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Tests

1 file changed

+5
-4
lines changed

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/Genesis/Tests/Uniform.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@ prop_leashingAttackStalling =
237237
advs <- mapM dropRandomPoints $ adversarialPeers sch
238238
pure $ ps {psSchedule = sch {adversarialPeers = advs}}
239239

240-
dropRandomPoints :: [(Time, SchedulePoint blk)] -> QC.Gen [(Time, SchedulePoint blk)]
241-
dropRandomPoints ps = do
240+
dropRandomPoints :: [(Time, SchedulePoint blk)] -> QC.Gen [(Time, SchedulePoint blk)]
241+
dropRandomPoints ps = do
242242
let lenps = length ps
243243
dropsMax = max 1 $ lenps - 1
244244
dropCount <- QC.choose (div dropsMax 2, dropsMax)
245245
let dedup = map NE.head . NE.group
246246
is <- fmap (dedup . sort) $ replicateM dropCount $ QC.choose (0, lenps - 1)
247247
pure $ dropElemsAt ps is
248-
248+
where
249249
dropElemsAt :: [a] -> [Int] -> [a]
250250
dropElemsAt xs is' =
251251
let is = Set.fromList is'
@@ -286,7 +286,8 @@ prop_leashingAttackTimeLimited =
286286
(gtLoPBucketParams genesisTest)
287287
(getHonestPeer honests)
288288
(Map.elems advs0)
289-
advs = fmap (takePointsUntil timeLimit) advs0
289+
advs1 = fmap (takePointsUntil timeLimit) advs0
290+
advs <- mapM dropRandomPoints advs1
290291
pure $ PointSchedule
291292
{ psSchedule = Peers honests advs
292293
, psStartOrder = []

0 commit comments

Comments
 (0)