Skip to content

Commit 7175f82

Browse files
authored
eth/fetcher: avoid hang in tests (partial fix for #23331) (#23351)
* eth/fetcher: fix test to avoid hanging. Partial fix for #23331 * eth/filters: avoid dangling goroutines * eth/fetcher: revert closing of proceed
1 parent 3b967d1 commit 7175f82

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

eth/fetcher/tx_fetcher_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ func TestTransactionFetcherSingletonRequesting(t *testing.T) {
304304
func TestTransactionFetcherFailedRescheduling(t *testing.T) {
305305
// Create a channel to control when tx requests can fail
306306
proceed := make(chan struct{})
307-
308307
testTransactionFetcherParallel(t, txFetcherTest{
309308
init: func() *TxFetcher {
310309
return NewTxFetcher(
@@ -1263,6 +1262,16 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
12631262
fetcher.Start()
12641263
defer fetcher.Stop()
12651264

1265+
defer func() { // drain the wait chan on exit
1266+
for {
1267+
select {
1268+
case <-wait:
1269+
default:
1270+
return
1271+
}
1272+
}
1273+
}()
1274+
12661275
// Crunch through all the test steps and execute them
12671276
for i, step := range tt.steps {
12681277
switch step := step.(type) {

eth/filters/filter_system_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,15 @@ func TestLogFilterCreation(t *testing.T) {
301301
)
302302

303303
for i, test := range testCases {
304-
_, err := api.NewFilter(test.crit)
305-
if test.success && err != nil {
304+
id, err := api.NewFilter(test.crit)
305+
if err != nil && test.success {
306306
t.Errorf("expected filter creation for case %d to success, got %v", i, err)
307307
}
308-
if !test.success && err == nil {
309-
t.Errorf("expected testcase %d to fail with an error", i)
308+
if err == nil {
309+
api.UninstallFilter(id)
310+
if !test.success {
311+
t.Errorf("expected testcase %d to fail with an error", i)
312+
}
310313
}
311314
}
312315
}

0 commit comments

Comments
 (0)