Skip to content

Commit

Permalink
Updates to make the wallet.py and stakeimmaturebalance.py test more r…
Browse files Browse the repository at this point in the history
…eliable (#624)

* Updates to make the wallet.py test more reliable

* Updated qa/rpc-tests/stakeimmaturebalance.py to be more reliable
  • Loading branch information
mxaddict authored and alex v committed Nov 21, 2019
1 parent e6f3c23 commit 7058550
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions qa/rpc-tests/stakeimmaturebalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def setup_network(self, split=False):
def run_test(self):
addr = self.nodes[1].getnewaddress()
activate_staticr(self.nodes[0])
self.nodes[0].sendtoaddress(addr, satoshi_round(float(self.nodes[0].getbalance()) - SENDING_FEE))
self.nodes[0].sendtoaddress(addr, satoshi_round(self.nodes[0].getbalance()), "", "", "", True)
slow_gen(self.nodes[0], 1)
logging.info('Checking stake weight')
assert(self.nodes[0].getbalance() - BLOCK_REWARD < 1), 'Wallet balance not sent'
assert(self.nodes[0].getbalance() - BLOCK_REWARD == 0), 'Wallet balance not sent'
assert(self.nodes[0].getwalletinfo()['immature_balance'] > 0), 'No immature balance'
assert(self.nodes[0].getstakinginfo()['weight'] == 0), 'Immature balance affecting staking weight'

Expand Down
12 changes: 7 additions & 5 deletions qa/rpc-tests/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,25 +231,27 @@ def run_test(self):
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
assert_equal(self.nodes[2].getbalance(), node_2_bal)


#create another tx
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)

block_count = self.nodes[0].getblockcount()

#restart the nodes with -walletbroadcast=1
stop_nodes(self.nodes)
wait_navcoinds()
self.nodes = start_nodes(3, self.options.tmpdir)
self.nodes = start_nodes(3, self.options.tmpdir, [['-staking=0'], ['-staking=0'], ['-staking=0']])
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,2,0)

slow_gen(self.nodes[0], 2)
self.sync_all()
slow_gen(self.nodes[0], 1)
self.sync_all()

block_count_new = self.nodes[0].getblockcount()

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

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

0 comments on commit 7058550

Please sign in to comment.