Skip to content

Commit fa14d99

Browse files
author
MarcoFalke
committed
[qa] check if wallet or blochchain maintenance changes the balance
1 parent fa0765d commit fa14d99

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

qa/rpc-tests/wallet.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ def run_test (self):
197197
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
198198
self.nodes[1].generate(1)
199199
self.sync_all()
200+
node_2_bal += 2
200201
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
201-
assert_equal(self.nodes[2].getbalance(), node_2_bal + Decimal('2')) #should not be
202+
assert_equal(self.nodes[2].getbalance(), node_2_bal)
202203

203204
#create another tx
204205
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
@@ -214,9 +215,10 @@ def run_test (self):
214215

215216
self.nodes[0].generate(1)
216217
sync_blocks(self.nodes)
218+
node_2_bal += 2
217219

218220
#tx should be added to balance because after restarting the nodes tx should be broadcastet
219-
assert_equal(self.nodes[2].getbalance(), node_2_bal + Decimal('4')) #should not be
221+
assert_equal(self.nodes[2].getbalance(), node_2_bal)
220222

221223
#send a tx with value in a string (PR#6380 +)
222224
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "2")
@@ -249,6 +251,29 @@ def run_test (self):
249251

250252
assert_equal("not an integer" in errorString, True)
251253

254+
#check if wallet or blochchain maintenance changes the balance
255+
self.sync_all()
256+
self.nodes[0].generate(1)
257+
self.sync_all()
258+
balance_nodes = [self.nodes[i].getbalance() for i in range(3)]
259+
260+
maintenance = [
261+
'-rescan',
262+
'-reindex',
263+
'-zapwallettxes=1',
264+
'-zapwallettxes=2',
265+
'-salvagewallet',
266+
]
267+
for m in maintenance:
268+
stop_nodes(self.nodes)
269+
wait_bitcoinds()
270+
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
271+
connect_nodes_bi(self.nodes,0,1)
272+
connect_nodes_bi(self.nodes,1,2)
273+
connect_nodes_bi(self.nodes,0,2)
274+
self.sync_all()
275+
assert_equal(balance_nodes, [self.nodes[i].getbalance() for i in range(3)])
276+
252277

253278
if __name__ == '__main__':
254279
WalletTest ().main ()

0 commit comments

Comments
 (0)