From 5ae0705f22563059454804ffbb4531d3fd49a640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADckolas=20Goline?= Date: Tue, 7 Jul 2026 18:57:56 -0300 Subject: [PATCH] tests: fix flaky test_simple_close_delay_broadcast mempool race The test mined a block as soon as 'Broadcasting txid' appeared in l2's log, but that log fires when CLN calls sendrawtransaction, not when bitcoind has accepted the tx into its mempool. Under rpcproxy timing the block could be mined empty, leaving the funding output unspent so 'Resolved FUNDING_TRANSACTION/FUNDING_OUTPUT by MUTUAL_CLOSE' never logged and the test timed out. Wait for the tx to enter the mempool before generating the block. Changelog-None --- tests/test_closing.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_closing.py b/tests/test_closing.py index b846d9f1b..88a9fb199 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -4358,11 +4358,14 @@ def test_simple_close_delay_broadcast(node_factory, bitcoind, executor): == 'CLOSINGD_COMPLETE') assert not l2.daemon.is_in_log('Simple close: delaying broadcast') - # l2 broadcasts immediately; wait until its tx is confirmed. - # We wait for the broadcast log rather than polling getrawmempool(), - # which can miss a just-submitted tx under the rpcproxy timing. + # l2 broadcasts immediately; wait until its tx is actually in the mempool + # before mining. The 'Broadcasting txid' log only means CLN *called* + # sendrawtransaction, not that bitcoind accepted the tx: mining on the log + # alone can produce an empty block under rpcproxy timing, leaving the + # funding output unspent so MUTUAL_CLOSE never resolves. generate_block's + # wait_for_mempool polls until the tx appears, so it can't miss it. l2.daemon.wait_for_log('Broadcasting txid') - bitcoind.generate_block(1) + bitcoind.generate_block(1, wait_for_mempool=1) l1.daemon.wait_for_log('Resolved FUNDING_TRANSACTION/FUNDING_OUTPUT by MUTUAL_CLOSE') l2.daemon.wait_for_log('Resolved FUNDING_TRANSACTION/FUNDING_OUTPUT by MUTUAL_CLOSE') fut.result(timeout=10)