From f89e37a8e2ecac9064231fa29445a7dcec46f966 Mon Sep 17 00:00:00 2001 From: daywalker90 Date: Mon, 14 Sep 2026 14:45:15 +0200 Subject: [PATCH] tests: fix test_rbf_non_last_mined flake ``` # The funding transaction gets mined (should be the 2nd inflight) bitcoind.generate_block(6, wait_for_mempool=1) # l2 comes back up l2.start() # everybody's got the right things now l1.daemon.wait_for_log(r'to CHANNELD_NORMAL') l2.daemon.wait_for_log(r'to CHANNELD_NORMAL') channel = only_one(l1.rpc.listpeerchannels()['channels']) > assert channel['funding_txid'] == inflights[1]['funding_txid'] E AssertionError: assert '12f2577bf10d40dd85e2de4ea867b59145fdcad541e861cf5993fbc5428b3aa7' == '1b8c5be4b21f8b741202cc2fcb1eb4ee0d529196870cfdeea03b1e69f88b436d' E E - 1b8c5be4b21f8b741202cc2fcb1eb4ee0d529196870cfdeea03b1e69f88b436d E + 12f2577bf10d40dd85e2de4ea867b59145fdcad541e861cf5993fbc5428b3aa7 tests/test_opening.py:1448: AssertionError ``` Changelog-None --- tests/test_opening.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/test_opening.py b/tests/test_opening.py index cdf069cb6eca..f528eb6801a5 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -1571,12 +1571,24 @@ def censoring_sendrawtx(r): # Make a 3rd inflight that won't make it into the mempool signed_psbt = run_retry() - last = len(l1.daemon.logs) + # Snapshot the logs only after catching up: len(logs) does not read + # new output, so a stale snapshot would match the *2nd* inflight's + # "sendrawtx exit 0" and we'd unmock before the 3rd is broadcast. + l1.daemon.logs_catchup() + l2.daemon.logs_catchup() + last1 = len(l1.daemon.logs) + last2 = len(l2.daemon.logs) l1.rpc.openchannel_signed(chan_id, signed_psbt) - wait_for(lambda: l1.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last)) + # Both nodes broadcast the (censored) funding tx, and either request + # may still be in flight, so wait for both before unmocking: otherwise + # the still-mocked attempt would be forwarded for real and replace the + # 2nd inflight in the mempool. + wait_for(lambda: l1.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last1)) + wait_for(lambda: l2.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last2)) import time - time.sleep(.05) + + time.sleep(0.05) l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', None) l2.daemon.rpcproxy.mock_rpc('sendrawtransaction', None) @@ -1686,11 +1698,22 @@ def censoring_sendrawtx(r): # Make a 3rd inflight that won't make it into the mempool signed_psbt = run_retry() - last = len(l1.daemon.logs) + # Snapshot the logs only after catching up: len(logs) does not read + # new output, so a stale snapshot would match the *2nd* inflight's + # "sendrawtx exit 0" and we'd unmock before the 3rd is broadcast. + l1.daemon.logs_catchup() + l2.daemon.logs_catchup() + last1 = len(l1.daemon.logs) + last2 = len(l2.daemon.logs) l1.rpc.openchannel_signed(chan_id, signed_psbt) - wait_for(lambda: l1.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last)) - time.sleep(.05) + # Both nodes broadcast the (censored) funding tx, and either request + # may still be in flight, so wait for both before unmocking: otherwise + # the still-mocked attempt would be forwarded for real and replace the + # 2nd inflight in the mempool. + wait_for(lambda: l1.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last1)) + wait_for(lambda: l2.daemon.is_in_log("plugin-bcli: sendrawtx exit 0", start=last2)) + time.sleep(0.05) l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', None) l2.daemon.rpcproxy.mock_rpc('sendrawtransaction', None)