Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,13 @@ func (c *testClock) After(d time.Duration) <-chan time.Time {
}

func (c *testClock) Sleep(d time.Duration) {
// A non-positive duration fires immediately on a real clock and must never move time
// backwards. The slot ticker legitimately calls After with a non-positive duration for the
// current slot, which would otherwise rewind the fake clock and race with the test.
if d <= 0 {
return
}

for c.paused.Load() {
runtime.Gosched()
}
Expand Down
Loading