Skip to content

Commit

Permalink
eth/fetcher: fix test to avoid hanging. Partial fix for ethereum#23331
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Nov 1, 2021
1 parent c2e64db commit 538246b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion eth/fetcher/tx_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func TestTransactionFetcherSingletonRequesting(t *testing.T) {
func TestTransactionFetcherFailedRescheduling(t *testing.T) {
// Create a channel to control when tx requests can fail
proceed := make(chan struct{})

defer close(proceed)
testTransactionFetcherParallel(t, txFetcherTest{
init: func() *TxFetcher {
return NewTxFetcher(
Expand Down Expand Up @@ -1263,6 +1263,17 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
fetcher.Start()
defer fetcher.Stop()

defer func() { // drain the wait chan on exit
for {
select {
case <-wait:
continue
default:
return
}
}
}()

// Crunch through all the test steps and execute them
for i, step := range tt.steps {
switch step := step.(type) {
Expand Down

0 comments on commit 538246b

Please sign in to comment.