@@ -83,6 +83,7 @@ def run_test(self):
83
83
84
84
self .nodes [0 ].generate (110 )
85
85
self .sync_all ()
86
+ self .test_change_remains_change (self .nodes [1 ])
86
87
reset_balance (self .nodes [1 ], self .nodes [0 ].getnewaddress ())
87
88
self .test_fund_send_fund_senddirty ()
88
89
reset_balance (self .nodes [1 ], self .nodes [0 ].getnewaddress ())
@@ -137,6 +138,30 @@ def test_immutable(self):
137
138
# Unload temp wallet
138
139
self .nodes [1 ].unloadwallet (tempwallet )
139
140
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_equal (len (out ), 1 )
149
+ assert_equal (out [0 ]['txid' ], txid )
150
+ changeaddr = out [0 ]['address' ]
151
+
152
+ # Make sure it's starting out as change as expected
153
+ assert node .getaddressinfo (changeaddr )['ischange' ]
154
+ for logical_tx in node .listtransactions ():
155
+ assert logical_tx .get ('address' ) != changeaddr
156
+
157
+ # Spend it
158
+ reset_balance (node , node .getnewaddress ())
159
+
160
+ # It should still be change
161
+ assert node .getaddressinfo (changeaddr )['ischange' ]
162
+ for logical_tx in node .listtransactions ():
163
+ assert logical_tx .get ('address' ) != changeaddr
164
+
140
165
def test_fund_send_fund_senddirty (self ):
141
166
'''
142
167
Test the same as test_fund_send_fund_send, except send the 10 BTC with
0 commit comments