From bb41e632ca94bea9b9a39592803f8faafbaa25f2 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 23 May 2019 15:40:16 +0100 Subject: wallet_balance.py: Prevent edge cases --- test/functional/wallet_balance.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/functional/wallet_balance.py') diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py index 4d1f1ccdc1..15f2195e21 100755 --- a/test/functional/wallet_balance.py +++ b/test/functional/wallet_balance.py @@ -28,12 +28,17 @@ def create_transactions(node, address, amt, fees): for utxo in utxos: inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]}) ins_total += utxo['amount'] - if ins_total + max(fees) > amt: + if ins_total >= amt + max(fees): break + # make sure there was enough utxos + assert ins_total >= amt + max(fees) txs = [] for fee in fees: - outputs = {address: amt, node.getrawchangeaddress(): ins_total - amt - fee} + outputs = {address: amt} + # prevent 0 change output + if ins_total > amt + fee: + outputs[node.getrawchangeaddress()] = ins_total - amt - fee raw_tx = node.createrawtransaction(inputs, outputs, 0, True) raw_tx = node.signrawtransactionwithwallet(raw_tx) assert_equal(raw_tx['complete'], True) -- cgit v1.2.3