Skip to content

Commit 7058550

Browse files
mxaddictalex v
authored andcommitted
Updates to make the wallet.py and stakeimmaturebalance.py test more reliable (#624)
* Updates to make the wallet.py test more reliable * Updated qa/rpc-tests/stakeimmaturebalance.py to be more reliable
1 parent e6f3c23 commit 7058550

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

qa/rpc-tests/stakeimmaturebalance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def setup_network(self, split=False):
2929
def run_test(self):
3030
addr = self.nodes[1].getnewaddress()
3131
activate_staticr(self.nodes[0])
32-
self.nodes[0].sendtoaddress(addr, satoshi_round(float(self.nodes[0].getbalance()) - SENDING_FEE))
32+
self.nodes[0].sendtoaddress(addr, satoshi_round(self.nodes[0].getbalance()), "", "", "", True)
3333
slow_gen(self.nodes[0], 1)
3434
logging.info('Checking stake weight')
35-
assert(self.nodes[0].getbalance() - BLOCK_REWARD < 1), 'Wallet balance not sent'
35+
assert(self.nodes[0].getbalance() - BLOCK_REWARD == 0), 'Wallet balance not sent'
3636
assert(self.nodes[0].getwalletinfo()['immature_balance'] > 0), 'No immature balance'
3737
assert(self.nodes[0].getstakinginfo()['weight'] == 0), 'Immature balance affecting staking weight'
3838

qa/rpc-tests/wallet.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,27 @@ def run_test(self):
231231
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
232232
assert_equal(self.nodes[2].getbalance(), node_2_bal)
233233

234-
235234
#create another tx
236235
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
237236

237+
block_count = self.nodes[0].getblockcount()
238+
238239
#restart the nodes with -walletbroadcast=1
239240
stop_nodes(self.nodes)
240241
wait_navcoinds()
241-
self.nodes = start_nodes(3, self.options.tmpdir)
242+
self.nodes = start_nodes(3, self.options.tmpdir, [['-staking=0'], ['-staking=0'], ['-staking=0']])
242243
connect_nodes_bi(self.nodes,0,1)
243244
connect_nodes_bi(self.nodes,1,2)
244245
connect_nodes_bi(self.nodes,2,0)
245246

247+
slow_gen(self.nodes[0], 2)
246248
self.sync_all()
247-
slow_gen(self.nodes[0], 1)
248-
self.sync_all()
249+
250+
block_count_new = self.nodes[0].getblockcount()
249251

250252
# We need to adjust the balance since new block/s got confirmed
251253
# And we sent 2 NAV to it
252-
node_2_bal += 2 * BLOCK_REWARD + 2
254+
node_2_bal += (block_count_new - block_count) * BLOCK_REWARD + 2
253255

254256
#tx should be added to balance because after restarting the nodes tx should be broadcastet
255257
assert_equal(self.nodes[2].getbalance(), node_2_bal)

0 commit comments

Comments
 (0)