Skip to content

Commit

Permalink
Merge pull request #7174 from filecoin-project/fix/timed-blockstore-test
Browse files Browse the repository at this point in the history
fix: make TestTimedCacheBlockstoreSimple pass reliably
  • Loading branch information
Stebalien authored Aug 25, 2021
2 parents 2495c52 + b3966ab commit 87fc8db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blockstore/timed.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ func (t *TimedCacheBlockstore) Start(_ context.Context) error {
return fmt.Errorf("already started")
}
t.closeCh = make(chan struct{})

// Create this timer before starting the goroutine. Otherwise, creating the timer will race
// with adding time to the mock clock, and we could add time _first_, then stall waiting for
// a timer that'll never fire.
ticker := t.clock.Ticker(t.interval)
go func() {
ticker := t.clock.Ticker(t.interval)
defer ticker.Stop()
for {
select {
Expand Down

0 comments on commit 87fc8db

Please sign in to comment.