core: fix potential race in chainIndexerTest (#22346)

This commit is contained in:
Sina Mahmoodi 2021-03-19 13:32:57 +01:00 committed by GitHub
parent 5bc0343ed3
commit c454717fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package core
import (
"context"
"errors"
"fmt"
"math/big"
"math/rand"
@ -224,7 +225,10 @@ func (b *testChainIndexBackend) Process(ctx context.Context, header *types.Heade
//t.processCh <- header.Number.Uint64()
select {
case <-time.After(10 * time.Second):
b.t.Fatal("Unexpected call to Process")
b.t.Error("Unexpected call to Process")
// Can't use Fatal since this is not the test's goroutine.
// Returning error stops the chainIndexer's updateLoop
return errors.New("Unexpected call to Process")
case b.processCh <- header.Number.Uint64():
}
return nil