Skip to content

Commit c454717

Browse files
authored
core: fix potential race in chainIndexerTest (#22346)
1 parent 5bc0343 commit c454717

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/chain_indexer_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"math/big"
2324
"math/rand"
@@ -224,7 +225,10 @@ func (b *testChainIndexBackend) Process(ctx context.Context, header *types.Heade
224225
//t.processCh <- header.Number.Uint64()
225226
select {
226227
case <-time.After(10 * time.Second):
227-
b.t.Fatal("Unexpected call to Process")
228+
b.t.Error("Unexpected call to Process")
229+
// Can't use Fatal since this is not the test's goroutine.
230+
// Returning error stops the chainIndexer's updateLoop
231+
return errors.New("Unexpected call to Process")
228232
case b.processCh <- header.Number.Uint64():
229233
}
230234
return nil

0 commit comments

Comments
 (0)