From 3341190cff4aef4f150392f359b31397a7e8c025 Mon Sep 17 00:00:00 2001 From: daywalker90 Date: Wed, 14 Oct 2026 16:32:38 +0200 Subject: [PATCH] tests: fix races in test_channel_lease_unilat_closes CI flaked with: > assert l3blocks == 4032 - 6 - 2 - 1 E assert 4025 == (((4032 - 6) - 2) - 1) l3's commitment used a blockheight 2 blocks behind the chain, because l2 was stopped before l3 had saved a commitment with the new height. A second run flaked with: E pyln.client.lightning.RpcError: RPC call failed: method: fundchannel ... error: {'code': 301, 'message': 'Could not afford 506268sat using all 0 available UTXOs: 506696sat short'} l2 broadcast the l1 funding tx, but did not record its change output until after the l2->l3 fundchannel with minconf=0 had already failed. Wait for l3 to log the commitsig carrying the new blockheight before stopping l2, and wait for l2 to see the funding change before the minconf=0 fundchannel. Changelog-None --- tests/test_closing.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_closing.py b/tests/test_closing.py index d4c678b1caf0..e93532e9e9da 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -946,13 +946,19 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) # l1 leases a channel from l2 - l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, - feerate='{}perkw'.format(feerate), - compact_lease=rates['compact_lease']) + fc = l1.rpc.fundchannel( + l2.info["id"], + amount, + request_amt=amount, + feerate="{}perkw".format(feerate), + compact_lease=rates["compact_lease"], + ) # l2 leases a channel from l3 l2.rpc.connect(l3.info['id'], 'localhost', l3.port) rates = l2.rpc.dev_queryrates(l3.info['id'], amount, amount) + # minconf=0 below needs l2 to see its change from the l1 funding tx + l2.daemon.wait_for_log(rf'Owning output.* txid {fc["txid"]}') l2.rpc.fundchannel(l3.info['id'], amount, request_amt=amount, feerate='{}perkw'.format(feerate), minconf=0, compact_lease=rates['compact_lease']) @@ -983,6 +989,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind): # make sure we're at the right place for the csv lock height = bitcoind.rpc.getblockchaininfo()['blocks'] l2.daemon.wait_for_log(f'Blockheight: SENT_ADD_ACK_COMMIT->RCVD_ADD_ACK_REVOCATION LOCAL now {height}') + l3.daemon.wait_for_log(f'got commitsig .*: feerate .*, blockheight: {height},') l2.stop() # unilateral close channels l1<->l2 & l3<->l2