Skip to content

Commit a13647b

Browse files
committed
[qa] Add test for too-large wallet output groups
1 parent 57ec1c9 commit a13647b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/functional/wallet_groups.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"""Test wallet group functionality."""
66

77
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.mininode import FromHex, ToHex
9+
from test_framework.messages import CTransaction
810
from test_framework.util import (
911
assert_equal,
1012
)
@@ -63,5 +65,29 @@ def run_test (self):
6365
assert_approx(v[0], 0.2)
6466
assert_approx(v[1], 1.3, 0.0001)
6567

68+
# Empty out node2's wallet
69+
self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=self.nodes[2].getbalance(), subtractfeefromamount=True)
70+
self.sync_all()
71+
self.nodes[0].generate(1)
72+
73+
# Fill node2's wallet with 10000 outputs corresponding to the same
74+
# scriptPubKey
75+
for i in range(5):
76+
raw_tx = self.nodes[0].createrawtransaction([{"txid":"0"*64, "vout":0}], [{addr2[0]: 0.05}])
77+
tx = FromHex(CTransaction(), raw_tx)
78+
tx.vin = []
79+
tx.vout = [tx.vout[0]] * 2000
80+
funded_tx = self.nodes[0].fundrawtransaction(ToHex(tx))
81+
signed_tx = self.nodes[0].signrawtransactionwithwallet(funded_tx['hex'])
82+
self.nodes[0].sendrawtransaction(signed_tx['hex'])
83+
self.nodes[0].generate(1)
84+
85+
self.sync_all()
86+
87+
# Check that we can create a transaction that only requires ~100 of our
88+
# utxos, without pulling in all outputs and creating a transaction that
89+
# is way too big.
90+
assert self.nodes[2].sendtoaddress(address=addr2[0], amount=5)
91+
6692
if __name__ == '__main__':
6793
WalletGroupTest().main ()

0 commit comments

Comments
 (0)