mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
test.Fatal() can only be used in test goroutine instead of its child
This commit is contained in:
parent
96490a10be
commit
e25b1235d0
1 changed files with 14 additions and 1 deletions
|
|
@ -993,14 +993,27 @@ func TestLogRebirth(t *testing.T) {
|
||||||
signer = types.NewEIP155Signer(gspec.Config.ChainID)
|
signer = types.NewEIP155Signer(gspec.Config.ChainID)
|
||||||
newLogCh = make(chan bool)
|
newLogCh = make(chan bool)
|
||||||
removeLogCh = make(chan bool)
|
removeLogCh = make(chan bool)
|
||||||
|
errMsgCh = make(chan string, 5) // Receive error message from validateLogEvent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
n := 5 // 5 is the number of times validateLogEvent is used to create new goroutines
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if msg := <-errMsgCh; msg != "" {
|
||||||
|
t.Fatal(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// validateLogEvent checks whether the received logs number is equal with expected.
|
// validateLogEvent checks whether the received logs number is equal with expected.
|
||||||
validateLogEvent := func(sink interface{}, result chan bool, expect int) {
|
validateLogEvent := func(sink interface{}, result chan bool, expect int) {
|
||||||
chanval := reflect.ValueOf(sink)
|
chanval := reflect.ValueOf(sink)
|
||||||
chantyp := chanval.Type()
|
chantyp := chanval.Type()
|
||||||
if chantyp.Kind() != reflect.Chan || chantyp.ChanDir()&reflect.RecvDir == 0 {
|
if chantyp.Kind() != reflect.Chan || chantyp.ChanDir()&reflect.RecvDir == 0 {
|
||||||
t.Fatalf("invalid channel, given type %v", chantyp)
|
errMsgCh <- fmt.Sprintf("invalid channel, given type %v", chantyp)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
errMsgCh <- ""
|
||||||
}
|
}
|
||||||
cnt := 0
|
cnt := 0
|
||||||
var recv []reflect.Value
|
var recv []reflect.Value
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue