From cbf69f6ded936577a344a1409fe5c63009452669 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 24 Aug 2021 11:35:56 -0700 Subject: [PATCH 1/2] fix: make TestTimedCacheBlockstoreSimple pass reliably --- blockstore/timed.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blockstore/timed.go b/blockstore/timed.go index 80e6c8a080f..b21dceeb887 100644 --- a/blockstore/timed.go +++ b/blockstore/timed.go @@ -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 addint 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 { From b3966ab4eb003f597aa38af0450ee6308e7560ac Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 24 Aug 2021 20:39:28 -0400 Subject: [PATCH 2/2] Fix typo in comment --- blockstore/timed.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockstore/timed.go b/blockstore/timed.go index b21dceeb887..b279943b680 100644 --- a/blockstore/timed.go +++ b/blockstore/timed.go @@ -49,7 +49,7 @@ func (t *TimedCacheBlockstore) Start(_ context.Context) error { t.closeCh = make(chan struct{}) // Create this timer before starting the goroutine. Otherwise, creating the timer will race - // with addint time to the mock clock, and we could add time _first_, then stall waiting for + // 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() {