This commit is contained in:
Mikhail Kuznetsov 2026-07-17 21:52:57 -07:00 committed by GitHub
commit b798be65d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -731,6 +731,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) {
api = NewFilterAPI(sys) api = NewFilterAPI(sys)
done = make(chan struct{}) done = make(chan struct{})
) )
defer close(done)
go func() { go func() {
// Bombard feed with txes until signal was received to stop // 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 // timeout either in 100ms or 200ms
subs := make([]*Subscription, 20) subs := make([]*Subscription, 20)
for i := range subs { for i := range subs {
created := time.Now()
fid := api.NewPendingTransactionFilter(nil) fid := api.NewPendingTransactionFilter(nil)
api.filtersMu.Lock() api.filtersMu.Lock()
f, ok := api.filters[fid] f, ok := api.filters[fid]
@ -763,6 +765,14 @@ func TestPendingTxFilterDeadlock(t *testing.T) {
// Wait for at least one tx to arrive in filter // Wait for at least one tx to arrive in filter
for { for {
hashes, err := api.GetFilterChanges(fid) 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 { if err != nil {
t.Fatalf("Filter should exist: %v\n", err) t.Fatalf("Filter should exist: %v\n", err)
} }