tests: remove `test_withdraw_stuck_reserved_on_broadcast_failure`
What changed, and why it matters
This commit simply deletes an old test that was written to document a known bug. The bug itself was already fixed in an earlier commit, and another test now serves as the regression test. No code behavior changes, and no new security issue is introduced here.
No action needed. This is a benign test cleanup. If reviewing the referenced fix commit 1c5e63299411912d469e4160caa8c93e07e91447, verify that the UTXO unreservation logic is correct and covered by the remaining regression test.
Security signals we found
Removal of a test that documented a known UTXO-reservation bug
Commit message references a prior fix commit
No functional code changes
Evidence from the diff
The diff removes test_withdraw_stuck_reserved_on_broadcast_failure from tests/test_wallet.py. The commit message states the underlying bug was fixed in commit 1c5e63299411912d469e4160caa8c93e07e91447 and that test_withdraw_unreserves_on_broadcast_failure now covers the regression. The deleted test explicitly asserted the presence of a known bug (UTXOs staying reserved after a failed broadcast) and then worked around it. This is a test-cleanup change only.
Changed components
tests/test_wallet.pyInspect captured patch +0 / −64
diff --git a/tests/test_wallet.py b/tests/test_wallet.py
index f88eefc1..651eb0e5 100644
--- a/tests/test_wallet.py
+++ b/tests/test_wallet.py
@@ -2930,67 +2930,3 @@ def test_withdraw_unreserves_on_broadcast_failure(node_factory, bitcoind):
bitcoind.generate_block(1)
sync_blockheight(bitcoind, [l1])
assert l1.db_query('SELECT COUNT(*) as c FROM outputs WHERE status=0')[0]['c'] == 0
-
-
-@unittest.skipIf(TEST_NETWORK != 'regtest', "Uses regtest-specific address types")
-def test_withdraw_stuck_reserved_on_broadcast_failure(node_factory, bitcoind):
- """Test funds don't get stuck as reserved after withdraw fails due to
- broadcast rejection (e.g. feerate below mempoolminfee).
-
- """
- l1 = node_factory.get_node(random_hsm=True)
- addr = l1.rpc.newaddr('p2tr')['p2tr']
-
- # Fund the node
- bitcoind.rpc.sendtoaddress(addr, 0.01)
- bitcoind.generate_block(1)
- wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
-
- output = only_one(l1.rpc.listfunds()['outputs'])
- assert output['status'] == 'confirmed'
- assert not output.get('reserved', False)
-
- waddr = bitcoind.rpc.getnewaddress()
-
- # Mock sendrawtransaction to simulate bitcoind rejecting the transaction
- # because the feerate is below its mempoolminfee
- def mock_fail_sendrawtx(r):
- # Self-remove after first call so subsequent transactions aren't blocked
- l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', None)
- return {
- 'id': r['id'],
- 'error': {
- 'code': -26,
- 'message': 'min relay fee not met, 253 < 5000',
- },
- 'result': None,
- }
-
- l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_fail_sendrawtx)
-
- with pytest.raises(RpcError, match=r'Error broadcasting transaction'):
- l1.rpc.withdraw(waddr, 'all')
-
- # BUG: UTXOs remain reserved despite the failed broadcast.
- # sendpsbt_done correctly unreserves the reservation it added (72 blocks),
- # but fundpsbt's prior reservation (72 blocks) is NOT cleaned up.
- outputs = l1.rpc.listfunds()['outputs']
- reserved = [o for o in outputs if o.get('reserved', False)]
- assert len(reserved) > 0, \
- "Expected UTXOs to be reserved after failed broadcast (known bug)"
-
- with pytest.raises(RpcError, match=r'Could not afford'):
- l1.rpc.withdraw(waddr, 'all')
-
- # Workaround: build a PSBT from the stuck UTXOs and call unreserveinputs.
- stuck_utxos = [{'txid': o['txid'], 'vout': o['output']} for o in reserved]
- psbt = bitcoind.rpc.createpsbt(stuck_utxos, [])
- l1.rpc.unreserveinputs(psbt)
-
- outputs = l1.rpc.listfunds()['outputs']
- assert not any(o.get('reserved', False) for o in outputs)
-
- l1.rpc.withdraw(waddr, 'all')
- bitcoind.generate_block(1)
- sync_blockheight(bitcoind, [l1])
- assert l1.db_query('SELECT COUNT(*) as c FROM outputs WHERE status=0')[0]['c'] == 0
Why this scored 12/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.