|
5 | 5 | """Test wallet group functionality."""
|
6 | 6 |
|
7 | 7 | from test_framework.test_framework import BitcoinTestFramework
|
| 8 | +from test_framework.mininode import FromHex, ToHex |
| 9 | +from test_framework.messages import CTransaction |
8 | 10 | from test_framework.util import (
|
9 | 11 | assert_equal,
|
10 | 12 | )
|
@@ -63,5 +65,29 @@ def run_test (self):
|
63 | 65 | assert_approx(v[0], 0.2)
|
64 | 66 | assert_approx(v[1], 1.3, 0.0001)
|
65 | 67 |
|
| 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 | + |
66 | 92 | if __name__ == '__main__':
|
67 | 93 | WalletGroupTest().main ()
|
0 commit comments