AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 18 Bitcoin

tests: clear util.callback_mgr between test cases

Public commit record

What the developer wrote

Authored by SomberNight

78/100 · Adequate
tests: clear util.callback_mgr between test cases

util.callback_mgr.callbacks was not getting properly cleared between tests.
Every time an Abstract_Wallet or an LNWorker (or many other subclasses of EventListener) is instantiated,
self.register_callbacks() is called in __init__, which puts callbacks into util.callback_mgr.callbacks.
These are only cleaned up if we explicitly call Abstract_Wallet.stop() or LNWorker.stop() later, which we usually do not do in the tests.

As a result, when running multiple unit tests in a row, lots of objects created in a given testcase are never GC-ed and leak into subsequent tests. This is not only a memory leak, but wastes compute too: when events are triggered and cbs get called, these old objects also have their cbs called.

After running all (~1061) unit tests, I observe util.callback_mgr.callbacks had 30 events with a total of 3156 callbacks stored.

On my laptop, running all unit tests previously took ~115 sec, and now it takes ~73 sec.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit is a test-suite cleanup, not a fix for a user-facing security bug. It stops old test objects from leaking between unit tests by clearing a global callback list after each test. That makes tests faster and less error-prone, but it does not change how the real Electrum wallet handles callbacks in production.

Recommended action

No user or operator action needed. This is a test-hygiene improvement. Reviewers may optionally verify that production code paths still call stop()/unregister_callback() appropriately so real wallets do not leak callbacks in long-running processes.

Security signals we found

01

Global callback registry leak between test cases

02

Test-only cleanup added; no production behavior change

03

No input validation, privilege boundary, or cryptographic change

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 1/15
Affected reach 2/15
Confidence 9/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.