v30.3-roots.1 · Commit 10: [PATCH 10/68] fix: harden Roots priority and wallet policy boundaries
test/functional/wallet_change_address.py
Before: test/functional/wallet_change_address.py · After: test/functional/wallet_change_address.py
File metadata
index 1545a46de0ccf1a97f3f8f6c60cbb985b8788fe5..84a20efefc3ea95de948ca1f7e0597870d874446 100755
Download original patch · Release notes
Diff rows 1–50 of 50. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
test/functional/wallet_change_address.py
CHANGED
|
@@ -56,15 +56,18 @@ class WalletChangeAddressTest(BitcoinTestFramework):
|
|
|
56
56
|
addrs = addr1 + addr2
|
|
57
57
|
|
|
58
58
|
# Send 1 + 0.5 coin to each address
|
|
59
|
-
[self.nodes[0].sendtoaddress(addr, 1.0) for addr in addrs]
|
|
60
|
-
[self.nodes[0].sendtoaddress(addr, 0.5) for addr in addrs]
|
|
59
|
+
for amount in (1.0, 0.5):
|
|
60
|
+
for addr in addrs:
|
|
61
|
+
self.nodes[0].sendtoaddress(addr, amount)
|
|
62
|
+
self.nodes[0].syncwithvalidationinterfacequeue()
|
|
61
63
|
self.generate(self.nodes[0], 1)
|
|
62
64
|
|
|
63
65
|
for i in range(20):
|
|
64
66
|
for n in [1, 2]:
|
|
65
67
|
self.log.debug(f"Send transaction from node {n}: expected change index {i}")
|
|
66
68
|
txid = self.nodes[n].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
|
|
67
|
-
tx = self.nodes[n].getrawtransaction(txid, True)
|
|
69
|
+
self.nodes[n].syncwithvalidationinterfacequeue()
|
|
70
|
+
tx = self.nodes[n].decoderawtransaction(self.nodes[n].gettransaction(txid)["hex"])
|
|
68
71
|
# find the change output and ensure that expected change index was used
|
|
69
72
|
self.assert_change_index(self.nodes[n], tx, i)
|
|
70
73
|
|
|
@@ -75,10 +78,9 @@ class WalletChangeAddressTest(BitcoinTestFramework):
|
|
|
75
78
|
w2 = self.nodes[2].get_wallet_rpc("w2")
|
|
76
79
|
addr1 = w1.getnewaddress()
|
|
77
80
|
addr2 = w2.getnewaddress()
|
|
78
|
-
self.nodes[0].sendtoaddress(addr1, 3.0)
|
|
79
|
-
self.nodes[0].sendtoaddress(addr1, 0.1)
|
|
80
|
-
self.nodes[0].sendtoaddress(addr2, 3.0)
|
|
81
|
-
self.nodes[0].sendtoaddress(addr2, 0.1)
|
|
81
|
+
for addr, amount in ((addr1, 3.0), (addr1, 0.1), (addr2, 3.0), (addr2, 0.1)):
|
|
82
|
+
self.nodes[0].sendtoaddress(addr, amount)
|
|
83
|
+
self.nodes[0].syncwithvalidationinterfacequeue()
|
|
82
84
|
self.generate(self.nodes[0], 1)
|
|
83
85
|
|
|
84
86
|
sendTo1 = self.nodes[0].getnewaddress()
|
|
@@ -88,7 +90,7 @@ class WalletChangeAddressTest(BitcoinTestFramework):
|
|
|
88
90
|
# The avoid partial spends wallet will always create a change output
|
|
89
91
|
node = self.nodes[2]
|
|
90
92
|
res = w2.send({sendTo1: "1.0", sendTo2: "1.0", sendTo3: "0.9999"}, options={"change_position": 0})
|
|
91
|
-
tx = node.getrawtransaction(res["txid"], True)
|
|
93
|
+
tx = node.decoderawtransaction(w2.gettransaction(res["txid"])["hex"])
|
|
92
94
|
self.assert_change_pos(w2, tx, 0)
|
|
93
95
|
|
|
94
96
|
# The default wallet will internally create a tx without change first,
|
|
@@ -96,7 +98,7 @@ class WalletChangeAddressTest(BitcoinTestFramework):
|
|
|
96
98
|
# Ensure that the user-configured change position is kept
|
|
97
99
|
node = self.nodes[1]
|
|
98
100
|
res = w1.send({sendTo1: "1.0", sendTo2: "1.0", sendTo3: "0.9999"}, options={"change_position": 0})
|
|
99
|
-
tx = node.getrawtransaction(res["txid"], True)
|
|
101
|
+
tx = node.decoderawtransaction(w1.gettransaction(res["txid"])["hex"])
|
|
100
102
|
# If the wallet ignores the user's change_position there is still a 25%
|
|
101
103
|
# that the random change position passes the test
|
|
102
104
|
self.assert_change_pos(w1, tx, 0)
|