Merge pull request #7174 from filecoin-project/fix/timed-blockstore-test

fix: make TestTimedCacheBlockstoreSimple pass reliably
This commit is contained in:
Steven Allen 2021-08-24 18:06:06 -07:00 committed by GitHub
commit 87fc8db5a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,8 +47,12 @@ func (t *TimedCacheBlockstore) Start(_ context.Context) error {
return fmt.Errorf("already started")
}
t.closeCh = make(chan struct{})
go func() {
// 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() {
defer ticker.Stop()
for {
select {