Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_groups.py
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# - node[2] should pick one (1.0 + 0.5) UTXO group corresponding to a | # - node[2] should pick one (1.0 + 0.5) UTXO group corresponding to a | ||||
# given address, and leave the rest | # given address, and leave the rest | ||||
txid1 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) | txid1 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) | ||||
tx1 = self.nodes[1].getrawtransaction(txid1, True) | tx1 = self.nodes[1].getrawtransaction(txid1, True) | ||||
# txid1 should have 1 input and 2 outputs | # txid1 should have 1 input and 2 outputs | ||||
assert_equal(1, len(tx1["vin"])) | assert_equal(1, len(tx1["vin"])) | ||||
assert_equal(2, len(tx1["vout"])) | assert_equal(2, len(tx1["vout"])) | ||||
# one output should be 0.2, the other should be ~0.3 | # one output should be 0.2, the other should be ~0.3 | ||||
v = [vout["value"] for vout in tx1["vout"]] | v = sorted([vout["value"] for vout in tx1["vout"]]) | ||||
v.sort() | |||||
assert_approx(v[0], 0.2) | assert_approx(v[0], 0.2) | ||||
assert_approx(v[1], 0.3, 0.0001) | assert_approx(v[1], 0.3, 0.0001) | ||||
txid2 = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) | txid2 = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) | ||||
tx2 = self.nodes[2].getrawtransaction(txid2, True) | tx2 = self.nodes[2].getrawtransaction(txid2, True) | ||||
# txid2 should have 2 inputs and 2 outputs | # txid2 should have 2 inputs and 2 outputs | ||||
assert_equal(2, len(tx2["vin"])) | assert_equal(2, len(tx2["vin"])) | ||||
assert_equal(2, len(tx2["vout"])) | assert_equal(2, len(tx2["vout"])) | ||||
# one output should be 0.2, the other should be ~1.3 | # one output should be 0.2, the other should be ~1.3 | ||||
v = [vout["value"] for vout in tx2["vout"]] | v = sorted([vout["value"] for vout in tx2["vout"]]) | ||||
v.sort() | |||||
assert_approx(v[0], 0.2) | assert_approx(v[0], 0.2) | ||||
assert_approx(v[1], 1.3, 0.0001) | assert_approx(v[1], 1.3, 0.0001) | ||||
# Empty out node2's wallet | # Empty out node2's wallet | ||||
self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress( | self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress( | ||||
), amount=self.nodes[2].getbalance(), subtractfeefromamount=True) | ), amount=self.nodes[2].getbalance(), subtractfeefromamount=True) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
Show All 25 Lines |