Skip to content

Commit

Permalink
[Tests] Check last_processed_block in getwalletinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra authored and furszy committed Apr 8, 2021
1 parent dc2d22a commit a700fdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/functional/mining_pos_coldStaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,15 @@ def run_test(self):

def checkBalances(self):
w_info = self.nodes[0].getwalletinfo()
assert_equal(self.nodes[0].getblockcount(), w_info['last_processed_block'])
self.log.info("OWNER - Delegated %f / Cold %f [%f / %f]" % (
float(w_info["delegated_balance"]), w_info["cold_staking_balance"],
float(w_info["immature_delegated_balance"]), w_info["immature_cold_staking_balance"]))
assert_equal(float(w_info["delegated_balance"]), self.expected_balance)
assert_equal(float(w_info["immature_delegated_balance"]), self.expected_immature_balance)
assert_equal(float(w_info["cold_staking_balance"]), 0)
w_info = self.nodes[1].getwalletinfo()
assert_equal(self.nodes[1].getblockcount(), w_info['last_processed_block'])
self.log.info("STAKER - Delegated %f / Cold %f [%f / %f]" % (
float(w_info["delegated_balance"]), w_info["cold_staking_balance"],
float(w_info["immature_delegated_balance"]), w_info["immature_cold_staking_balance"]))
Expand Down
1 change: 1 addition & 0 deletions test/functional/mining_pos_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def disconnect_all(self):

def get_tot_balance(self, nodeid):
wi = self.nodes[nodeid].getwalletinfo()
assert_equal(self.nodes[nodeid].getblockcount(), wi['last_processed_block'])
return wi['balance'] + wi['immature_balance']

def check_money_supply(self, expected_piv):
Expand Down
1 change: 1 addition & 0 deletions test/functional/sapling_wallet_anchorfork.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def run_test (self):
self.sync_all()

walletinfo = self.nodes[0].getwalletinfo()
assert_equal(self.nodes[0].getblockcount(), walletinfo['last_processed_block'])
assert_equal(walletinfo['immature_balance'], 1000)
assert_equal(walletinfo['balance'], 0)

Expand Down
11 changes: 10 additions & 1 deletion test/functional/wallet_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def setup_network(self):
def get_vsize(self, txn):
return self.nodes[0].decoderawtransaction(txn)['size']

def check_wallet_processed_blocks(self, nodeid, walletinfo):
assert_equal(self.nodes[nodeid].getblockcount(), walletinfo['last_processed_block'])

def run_test(self):
# Check that there's no UTXO on none of the nodes
assert_equal(len(self.nodes[0].listunspent()), 0)
Expand All @@ -43,6 +46,7 @@ def run_test(self):
self.nodes[0].generate(1)

walletinfo = self.nodes[0].getwalletinfo()
self.check_wallet_processed_blocks(0, walletinfo)
assert_equal(walletinfo['immature_balance'], 250)
assert_equal(walletinfo['balance'], 0)

Expand All @@ -54,13 +58,17 @@ def run_test(self):
assert_equal(self.nodes[1].getbalance(), 250)
assert_equal(self.nodes[2].getbalance(), 0)

walletinfo = self.nodes[0].getwalletinfo()
self.check_wallet_processed_blocks(0, walletinfo)
self.check_wallet_processed_blocks(1, self.nodes[1].getwalletinfo())
self.check_wallet_processed_blocks(2, self.nodes[2].getwalletinfo())

# Check that only first and second nodes have UTXOs
utxos = self.nodes[0].listunspent()
assert_equal(len(utxos), 1)
assert_equal(len(self.nodes[1].listunspent()), 1)
assert_equal(len(self.nodes[2].listunspent()), 0)

walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 0)

# Exercise locking of unspent outputs
Expand Down Expand Up @@ -185,6 +193,7 @@ def run_test(self):
assert_equal(balance_nodes, [self.nodes[i].getbalance() for i in range(3)])

# Exercise listsinceblock with the last two blocks
self.check_wallet_processed_blocks(0, self.nodes[0].getwalletinfo())
coinbase_tx_1 = self.nodes[0].listsinceblock(blocks[0])
assert_equal(coinbase_tx_1["lastblock"], blocks[1])
assert_equal(len(coinbase_tx_1["transactions"]), 1)
Expand Down

0 comments on commit a700fdf

Please sign in to comment.