What changed, and why it matters
This commit only removes unused test helper code from two test files. It does not change any production wallet or network code, so it cannot affect real users' funds or security.
No security action needed; this is a routine test-code cleanup. Reviewers may verify that the removed symbols are truly unused in the test suite.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes dead code in tests/test_lnpeer.py (pending_payments defaultdict, pay_scheduled_invoices stub, get_first_timestamp lambda) and tests/test_onion_message.py (unused MockWallet and MockLNWallet subclasses, plus related imports). The remaining test file now imports MockLNWallet directly from test_lnpeer. No runtime behavior of Electrum’s Lightning or onion-message logic is altered.
Changed components
tests/test_lnpeer.pytests/test_onion_message.pyInspect captured patch +2 / −22
diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py
index 536a21e..3bc39c6 100644
--- a/tests/test_lnpeer.py
+++ b/tests/test_lnpeer.py
@@ -196,7 +196,6 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
self.features |= LnFeatures.OPTION_SCID_ALIAS_OPT
self.features |= LnFeatures.OPTION_STATIC_REMOTEKEY_OPT
self.config.ENABLE_ANCHOR_CHANNELS = has_anchors
- self.pending_payments = defaultdict(asyncio.Future)
for chan in chans:
chan.lnworker = self
self._peers = {} # bytes -> Peer
@@ -226,9 +225,6 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
def clear_invoices_cache(self):
pass
- def pay_scheduled_invoices(self):
- pass
-
def get_invoice_status(self, key):
pass
@@ -314,7 +310,6 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
pay_invoice = LNWallet.pay_invoice
force_close_channel = LNWallet.force_close_channel
schedule_force_closing = LNWallet.schedule_force_closing
- get_first_timestamp = lambda self: 0
on_peer_successfully_established = LNWallet.on_peer_successfully_established
get_channel_by_id = LNWallet.get_channel_by_id
channels_for_peer = LNWallet.channels_for_peer
diff --git a/tests/test_onion_message.py b/tests/test_onion_message.py
index 4e381d6..76e09a2 100644
--- a/tests/test_onion_message.py
+++ b/tests/test_onion_message.py
@@ -24,8 +24,8 @@ from electrum.onion_message import (
from electrum.util import bfh, read_json_file, OldTaskGroup, get_asyncio_loop
from electrum.logging import console_stderr_handler
-from . import ElectrumTestCase, test_lnpeer
-from .test_lnpeer import PutIntoOthersQueueTransport, PeerInTests, keypair
+from . import ElectrumTestCase
+from .test_lnpeer import keypair, MockLNWallet
TIME_STEP = 0.01 # run tests 100 x faster
OnionMessageManager.SLEEP_DELAY *= TIME_STEP
@@ -273,21 +273,6 @@ class MockNetwork:
self.config.EXPERIMENTAL_LN_FORWARD_PAYMENTS = True
-class MockWallet:
- def __init__(self):
- pass
-
-
-class MockLNWallet(test_lnpeer.MockLNWallet):
-
- async def add_peer(self, connect_str: str):
- t1 = PutIntoOthersQueueTransport(self.node_keypair, 'test')
- p1 = PeerInTests(self, keypair().pubkey, t1)
- self.peers[p1.pubkey] = p1
- p1.initialized.set_result(True)
- return p1
-
-
class MockPeer:
their_features = LnFeatures(LnFeatures.OPTION_ONION_MESSAGE_OPT)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.