diff options
| author | MarcoFalke <[email protected]> | 2019-05-23 11:37:17 -0400 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2019-05-23 11:37:20 -0400 |
| commit | b4223dd5f11381157aa8dd64e6ae6ac5f2062741 (patch) | |
| tree | f96c6366d65ca60c17f24ece94a42a44b04fc669 | |
| parent | Merge #16063: rpc: Mention getwalletinfo where a rescan is triggered (diff) | |
| parent | wallet_balance.py: Prevent edge cases (diff) | |
| download | discoin-b4223dd5f11381157aa8dd64e6ae6ac5f2062741.tar.xz discoin-b4223dd5f11381157aa8dd64e6ae6ac5f2062741.zip | |
Merge #16079: wallet_balance.py: Prevent edge cases
bb41e632ca wallet_balance.py: Prevent edge cases (Steven Roose)
Pull request description:
I ran into this edge case when running the test on Elements. I had a 0-value output as change.
ACKs for commit bb41e6:
Tree-SHA512: ef4c25289cafcdb4437f11ed537664dff5afedcefab75a46f985d3be70551de2d3bc8e9cfcb22c0f3d7d2eb95ff40df78b8d01dbacbf90c36bca00426937b0a2
| -rwxr-xr-x | test/functional/wallet_balance.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py index 4d1f1ccdc..15f2195e2 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) |