From ebdbe5401f79313db5337a9a1de503efbbc3d92a Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Fri, 10 Jul 2026 09:08:10 +0400 Subject: [PATCH] eth/filters: fix flaky TestPendingTxFilterDeadlock The test polls GetFilterChanges with a 100ms filter timeout. On a loaded system a >100ms gap between two polls lets the timeout loop uninstall the filter, so the next poll returns errFilterNotFound and the test fails. Treat that as a benign early timeout, gated on the deadline having actually elapsed; the uninstall is still verified through the sub.Err() wait at the end of the test. Also close the done channel so the tx-sending goroutine exits when the test finishes instead of spinning for the remainder of the test binary. Signed-off-by: Mikhail Kuznetsov --- eth/filters/filter_system_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 6f97d5b664..1b2bc1b03d 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -731,6 +731,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) { api = NewFilterAPI(sys) done = make(chan struct{}) ) + defer close(done) go func() { // Bombard feed with txes until signal was received to stop @@ -752,6 +753,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) { // timeout either in 100ms or 200ms subs := make([]*Subscription, 20) for i := range subs { + created := time.Now() fid := api.NewPendingTransactionFilter(nil) api.filtersMu.Lock() f, ok := api.filters[fid] @@ -763,6 +765,14 @@ func TestPendingTxFilterDeadlock(t *testing.T) { // Wait for at least one tx to arrive in filter for { hashes, err := api.GetFilterChanges(fid) + if errors.Is(err, errFilterNotFound) && time.Since(created) >= timeout { + // The filter was not polled for longer than the configured + // timeout and has already been uninstalled. This can happen + // on a loaded system and is not a deadlock: the uninstall + // is verified through sub.Err() below. The time check keeps + // this tolerance from masking uninstalls before the deadline. + break + } if err != nil { t.Fatalf("Filter should exist: %v\n", err) }