From a8745471aef9645feaebd68e80e5204d40d4dc6f Mon Sep 17 00:00:00 2001 From: daywalker90 Date: Wed, 16 Sep 2026 18:37:00 +0200 Subject: [PATCH] tests: fix test_funding_v2_cancel_race flake openchannel_update is idempotent: once the commitments are secured a repeat call returns the existing inflight, so two racing openchannel_update calls can both legitimately succeed and the "only up to one should succeed" assertion no longer holds. Keep the original intent (catching commands that fight over the shared command pointer and hang) by relying on result(TIMEOUT) raising TimeoutError, and replace the count check with the stronger invariant that no two distinct secured PSBTs (i.e. two commitments) were made. Changelog-None --- tests/test_connection.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index baa3f1345464..da7f3aedccfd 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1606,17 +1606,26 @@ def test_funding_v2_cancel_race(node_factory, bitcoind, executor): executor.submit(l1.rpc.openchannel_abort, start['channel_id']))) + secured = set() for i, c in enumerate(completes): try: - c[1].result(TIMEOUT) + # A command that fights over the shared command pointer hangs + # here until TIMEOUT raises TimeoutError (not an RpcError). + result = c[1].result(TIMEOUT) completes[i] = (completes[i][0], True) + # openchannel_update is idempotent: repeating it once the + # commitments are secured just echoes the inflight back, so + # several of these calls may legitimately succeed. Two + # *distinct* secured PSBTs would mean two commitments though. + if result["commitments_secured"]: + secured.add(result["psbt"]) except RpcError: completes[i] = (completes[i][0], False) - # Only up to one should succeed. - num_successes = sum(c[1] is True for c in completes) - assert num_successes <= 1, f"Multiple successes in {completes}, cancels = {cancels}" - num_complete += num_successes + assert len(secured) <= 1, ( + f"Multiple commitments in {completes}, cancels = {cancels}" + ) + num_complete += sum(c[1] is True for c in completes) for c in cancels: try: