pytest: get more\ information when test_funding_v2_cancel_race fails.
What changed, and why it matters
This commit only improves a test so that when it fails, the error message shows which specific operations succeeded. It does not change any production code or fix a security issue.
No action needed; this is a test-debugging improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is purely in tests/test_connection.py. It labels the futures submitted to the executor with their RPC method names and records success/failure per call, then prints the full list if more than one openchannel_update unexpectedly succeeds. No node logic, RPC behavior, or protocol handling is modified.
Changed components
tests/test_connection.pyInspect captured patch +17 / −14
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 37530022..f0623c78 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -1580,27 +1580,30 @@ def test_funding_v2_cancel_race(node_factory, bitcoind, executor):
# Switch order around.
for i in range(4):
if (i + count) % 2 == 0:
- completes.append(executor.submit(l1.rpc.openchannel_update,
- start['channel_id'],
- start['psbt']))
+ completes.append(("openchannel_update",
+ executor.submit(l1.rpc.openchannel_update,
+ start['channel_id'],
+ start['psbt'])))
else:
- cancels.append(executor.submit(l1.rpc.openchannel_abort,
- start['channel_id']))
+ cancels.append(("openchannel_abort",
+ executor.submit(l1.rpc.openchannel_abort,
+ start['channel_id'])))
- # Only up to one should succeed.
- success = False
- for c in completes:
+ for i, c in enumerate(completes):
try:
- c.result(TIMEOUT)
- num_complete += 1
- assert not success
- success = True
+ c[1].result(TIMEOUT)
+ completes[i] = (completes[i][0], True)
except RpcError:
- pass
+ 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
for c in cancels:
try:
- c.result(TIMEOUT)
+ c[1].result(TIMEOUT)
num_cancel += 1
except RpcError:
pass
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.