Skip to content

Commit e67ab17

Browse files
committed
test: fix flaky wallet_send functional test
Rather than asserting that the exact fees are the same, check the fee rate rounded to nearest interger. This will account for small differences in fees caused by variability in ECDSA signature lengths.
1 parent 3c49e69 commit e67ab17

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/functional/wallet_send.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def run_test(self):
563563
options={"inputs": [ext_utxo], "input_weights": [{"txid": ext_utxo["txid"], "vout": ext_utxo["vout"], "weight": 1000}]}
564564
)
565565

566+
target_fee_rate_sat_vb = 10
566567
# Funding should also work when input weights are provided
567568
res = self.test_send(
568569
from_wallet=ext_wallet,
@@ -572,14 +573,17 @@ def run_test(self):
572573
add_inputs=True,
573574
psbt=True,
574575
include_watching=True,
575-
fee_rate=10
576+
fee_rate=target_fee_rate_sat_vb
576577
)
577578
signed = ext_wallet.walletprocesspsbt(res["psbt"])
578579
signed = ext_fund.walletprocesspsbt(res["psbt"])
579580
assert signed["complete"]
580581
testres = self.nodes[0].testmempoolaccept([signed["hex"]])[0]
581582
assert_equal(testres["allowed"], True)
582-
assert_fee_amount(testres["fees"]["base"], testres["vsize"], Decimal(0.0001))
583+
actual_fee_rate_sat_vb = Decimal(testres["fees"]["base"]) * Decimal(1e8) / Decimal(testres["vsize"])
584+
# Due to ECDSA signatures not always being the same length, the actual fee rate may be slightly different
585+
# but rounded to nearest integer, it should be the same as the target fee rate
586+
assert_equal(round(actual_fee_rate_sat_vb), target_fee_rate_sat_vb)
583587

584588
if __name__ == '__main__':
585589
WalletSendTest().main()

0 commit comments

Comments
 (0)