pytest: fix flake in test_coin_movement_notices
What changed, and why it matters
This commit fixes a flaky automated test, not a security issue. The test sometimes failed because it restarted a node before a logging plugin had finished recording a payment event. The fix adds a wait for the plugin's log line before restarting. There is no vulnerability in the production software.
No security action needed. This is a test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is in tests/test_plugin.py only. It removes a @pytest.mark.flaky(reruns=5) decorator from test_coin_movement_notices and adds a l2.daemon.wait_for_log() call before l2.restart() to ensure the coin_movements.py plugin has processed the sendpay notification. This eliminates a race condition in the test harness, not in Core Lightning itself.
Changed components
tests/test_plugin.pyInspect captured patch +3 / −1
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index d62ccf75..d45b07b3 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -2191,7 +2191,6 @@ def test_plugin_fail(node_factory):
l1.daemon.wait_for_log(r': exited during normal operation')
-@pytest.mark.flaky(reruns=5)
@pytest.mark.openchannel('v1')
@pytest.mark.openchannel('v2')
def test_coin_movement_notices(node_factory, bitcoind, chainparams):
@@ -2269,6 +2268,9 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
l2.rpc.sendpay(route, payment_hash21, payment_secret=inv['payment_secret'])
l2.rpc.waitsendpay(payment_hash21)
+ # Make sure coin_movements.py sees event before we restart!
+ l2.daemon.wait_for_log(f"plugin-coin_movements.py: coin movement: .*'payment_hash': '{payment_hash21}'")
+
# restart to test index
l2.restart()
wait_for(lambda: all(c['state'] == 'CHANNELD_NORMAL' for c in l2.rpc.listpeerchannels()["channels"]))
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.