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.
This commit is contained in:
stickies-v 2024-01-19 14:12:40 +00:00
parent 5f3a0574c4
commit 3bfc5bd36e
No known key found for this signature in database
GPG key ID: 5CB1CE6E5E66A757

View file

@ -24,6 +24,7 @@ from test_framework.address import (
AddressType,
ADDRESS_BCRT1_UNSPENDABLE,
)
from test_framework.messages import COIN
from test_framework.util import (
assert_equal,
set_node_times,
@ -270,7 +271,9 @@ class ImportRescanTest(BitcoinTestFramework):
address_type=variant.address_type.value,
))
variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
variant.initial_amount = get_rand_amount() * 2
# Ensure output is large enough to pay for fees: conservatively assuming txsize of
# 500 vbytes and feerate of 20 sats/vbytes
variant.initial_amount = max(get_rand_amount(), (500 * 20 / COIN) + AMOUNT_DUST)
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)
variant.confirmation_height = 0
variant.timestamp = timestamp