tests: lnpeer: uncomment testcase: test_modern_shutdown_no_overlap
What changed, and why it matters
This commit only re-enables an existing automated test for a Lightning Network channel-closing scenario where two sides cannot agree on a fee. It does not change the actual Electrum wallet or Lightning code that users run, so it cannot directly affect real funds or security. It is a testing improvement.
No security action needed. Treat as a normal test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch uncomments and modernizes test_modern_shutdown_no_overlap in tests/test_lnpeer.py. It mocks LN_P2P_NETWORK_TIMEOUT down to 0.05 seconds and asserts that, when Alice and Bob’s closing-fee ranges do not overlap, the code raises an exception and logs the expected error messages. No production code paths are modified.
Changed components
tests/test_lnpeer.pyInspect captured patch +13 / −10
diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py
index 897a4b3..6fdb6c0 100644
--- a/tests/test_lnpeer.py
+++ b/tests/test_lnpeer.py
@@ -1571,16 +1571,19 @@ class TestPeerDirect(TestPeer):
alice_fee_range={'min_fee_satoshis': 1, 'max_fee_satoshis': 10},
bob_fee_range={'min_fee_satoshis': 10, 'max_fee_satoshis': 300})
- ## This test works but it is too slow (LN_P2P_NETWORK_TIMEOUT)
- ## because tests do not use a proper LNWorker object
- #def test_modern_shutdown_no_overlap(self):
- # self.assertRaises(Exception, lambda: asyncio.run(
- # self._test_shutdown(
- # alice_fee=1,
- # bob_fee=200,
- # alice_fee_range={'min_fee_satoshis': 1, 'max_fee_satoshis': 10},
- # bob_fee_range={'min_fee_satoshis': 50, 'max_fee_satoshis': 300})
- # ))
+ @mock.patch('electrum.lnpeer.LN_P2P_NETWORK_TIMEOUT', 0.05)
+ async def test_modern_shutdown_no_overlap(self):
+ with self.assertLogs('electrum', level='ERROR') as logs:
+ with self.assertRaisesRegex(Exception, "closing_signed not received"):
+ await self._test_shutdown(
+ alice_fee=1,
+ bob_fee=200,
+ alice_fee_range={'min_fee_satoshis': 1, 'max_fee_satoshis': 10},
+ bob_fee_range={'min_fee_satoshis': 50, 'max_fee_satoshis': 300})
+ self.assertTrue(any(("bob->alice" in msg and "There is no overlap between between their and our fee range." in msg) for msg in logs.output))
+ self.assertTrue(any(("alice->bob" in msg and "closing_signed not received, force closing." in msg) for msg in logs.output))
+ # note: "Task exception was never retrieved" for "Exception: There is no overlap [...]"
+ # is because we don't start peer.main_loop and hence peer.taskgroup is never joined.
async def _test_shutdown(self, alice_fee, bob_fee, alice_fee_range=None, bob_fee_range=None):
graph = self.prepare_chans_and_peers_in_graph(self.GRAPH_DEFINITIONS['single_chan'])
Why this scored 12/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.