Skip to content

Commit 3bfc5bd

Browse files
committed
test: ensure output is large enough to pay for its fees
Fixes a (rare) intermittency issue in wallet_import_rescan. Since we use `subtract_fee_from_outputs=[0]` in the `send` command, the output amount must at least be as large as the fee we're paying.
1 parent 5f3a057 commit 3bfc5bd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/functional/wallet_import_rescan.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
AddressType,
2525
ADDRESS_BCRT1_UNSPENDABLE,
2626
)
27+
from test_framework.messages import COIN
2728
from test_framework.util import (
2829
assert_equal,
2930
set_node_times,
@@ -270,7 +271,9 @@ def run_test(self):
270271
address_type=variant.address_type.value,
271272
))
272273
variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
273-
variant.initial_amount = get_rand_amount() * 2
274+
# Ensure output is large enough to pay for fees: conservatively assuming txsize of
275+
# 500 vbytes and feerate of 20 sats/vbytes
276+
variant.initial_amount = max(get_rand_amount(), (500 * 20 / COIN) + AMOUNT_DUST)
274277
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)
275278
variant.confirmation_height = 0
276279
variant.timestamp = timestamp

0 commit comments

Comments
 (0)