Skip to content

Commit

Permalink
Test update 'no excess busyness'
Browse files Browse the repository at this point in the history
If we are above the credits instead of failing instantly take a look if
any of the events provide us with more credits. This makes the test
suite more robust incase one kind of events happens close to another
kind of events. For example a burst of peersharing activity just before
the node starts to look for new public roots.
  • Loading branch information
karknu authored and coot committed May 6, 2024
1 parent 2935fe1 commit 6858d03
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,21 @@ tooBusyForTooLong trace0 =
-- For normal governor events we check if the length of the busy time span
-- is now too big (adjusted for any perturbation credits). If so we've
-- found a violation.
busy !busyStartTime !credits ((busyEndTime, _dt, GovernorEvent{}) : _trace')
| busySpanLength > credits = Left (busyEndTime, credits)
busy !busyStartTime !credits ((busyEndTime, _dt, GovernorEvent{}) : trace')
| busySpanLength > endCredits credits trace'=
Left (busyEndTime, endCredits credits trace')
where
busySpanLength = diffTime busyEndTime busyStartTime

-- If the governor wakes up due to an action that gives us new credits
-- we take those credits into account before failing.
endCredits !c [] = c
endCredits !c ((t, _, MockEnvEvent e) : tr) | t == busyEndTime =
endCredits (c + fromIntegral (envEventCredits e)) tr
endCredits !c ((t, _, _) : tr) | t == busyEndTime =
endCredits c tr
endCredits !c _ = c

-- We also look at how long it is to the next event to see if this is the
-- last event in the busy span, and if so we return to idle.
busy !_busyStartTime !_credits ((_t, dt, _event) : trace')
Expand Down

0 comments on commit 6858d03

Please sign in to comment.