Skip to content

Commit 86d6059

Browse files
committed
QA: Test that change doesn't turn into non-change when spent in an avoid-reuse wallet
1 parent b5795a7 commit 86d6059

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/functional/wallet_avoidreuse.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def run_test(self):
8383

8484
self.nodes[0].generate(110)
8585
self.sync_all()
86+
self.test_change_remains_change(self.nodes[1])
8687
reset_balance(self.nodes[1], self.nodes[0].getnewaddress())
8788
self.test_fund_send_fund_senddirty()
8889
reset_balance(self.nodes[1], self.nodes[0].getnewaddress())
@@ -137,6 +138,29 @@ def test_immutable(self):
137138
# Unload temp wallet
138139
self.nodes[1].unloadwallet(tempwallet)
139140

141+
def test_change_remains_change(self, node):
142+
self.log.info("Test that change doesn't turn into non-change when spent")
143+
144+
reset_balance(node, node.getnewaddress())
145+
addr = node.getnewaddress()
146+
txid = node.sendtoaddress(addr, 1)
147+
out = node.listunspent(minconf=0, query_options={'minimumAmount': 2})
148+
assert len(out) == 1
149+
changeaddr = out[0]['address']
150+
151+
# Make sure it's starting out as change as expected
152+
assert node.getaddressinfo(changeaddr)['ischange']
153+
for logical_tx in node.listtransactions():
154+
assert logical_tx.get('address') != changeaddr
155+
156+
# Spend it
157+
reset_balance(node, node.getnewaddress())
158+
159+
# It should still be change
160+
assert node.getaddressinfo(changeaddr)['ischange']
161+
for logical_tx in node.listtransactions():
162+
assert logical_tx.get('address') != changeaddr
163+
140164
def test_fund_send_fund_senddirty(self):
141165
'''
142166
Test the same as test_fund_send_fund_send, except send the 10 BTC with

0 commit comments

Comments
 (0)