Skip to content

Commit 03f4ed0

Browse files
UdjinM6claude
andcommitted
test: use exact outpoint matching in restart persistence test
Compare the exact set of (txid, vout) pairs instead of just a count, making the assertion more precise and resilient to test-order changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5fd0e88 commit 03f4ed0

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

test/functional/wallet_dust_protection.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,30 @@ def test_existing_utxos_locked_on_restart(self):
156156
self.sync_all()
157157

158158
assert_equal(len(node3.listlockunspent()), 0)
159-
num_dust = len(node3.listunspent())
159+
160+
# Capture exact dust outpoints before restart
161+
THRESHOLD = 10000
162+
expected_outpoints = set()
163+
for utxo in node3.listunspent():
164+
if utxo['amount'] <= THRESHOLD * DUFFS:
165+
expected_outpoints.add((utxo['txid'], utxo['vout']))
166+
assert len(expected_outpoints) > 0, "Test requires at least one dust UTXO on node3"
160167

161168
# Restart node3 WITH dust protection — all existing dust should get locked
162-
self.restart_node(3, ["-dustrelayfee=0", "-dustprotectionthreshold=10000"])
169+
self.restart_node(3, ["-dustrelayfee=0", "-dustprotectionthreshold=%d" % THRESHOLD])
163170
self.connect_nodes(0, 3)
164171

165172
locked = node3.listlockunspent()
166-
assert_equal(len(locked), num_dust)
173+
locked_outpoints = {(entry['txid'], entry['vout']) for entry in locked}
174+
assert_equal(locked_outpoints, expected_outpoints)
167175

168176
# Restart again WITHOUT protection — locks should persist (written to DB)
169177
self.restart_node(3, ["-dustrelayfee=0"])
170178
self.connect_nodes(0, 3)
171179

172180
locked = node3.listlockunspent()
173-
assert_equal(len(locked), num_dust)
181+
locked_outpoints = {(entry['txid'], entry['vout']) for entry in locked}
182+
assert_equal(locked_outpoints, expected_outpoints)
174183

175184
# Cleanup
176185
node3.lockunspent(True, locked)

0 commit comments

Comments
 (0)