Skip to content

Commit

Permalink
Add test to test unconfirmed asset balances
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Mar 4, 2020
1 parent 29298ce commit 521e357
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/functional/wallet_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,37 @@ def run_test(self):
# getbalance with minconf=2 will show the new balance.
assert_equal(self.nodes[1].getbalance(minconf=2)['bitcoin'], Decimal('0'))

# Balances of assets
for blind in [True, False]:
self.log.info("Testing {} issued asset balances".format("blinded" if blind else "unblinded"))
asset = self.nodes[0].issueasset(100, 0, blind)["asset"]

# Balances with unconfirmed issuance.
# They are indicated as confirmed because they are sent by the RPC and thus "trusted".
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo["balance"].get(asset, 0), Decimal('100'))
assert_equal(walletinfo["unconfirmed_balance"].get(asset, 0), Decimal('0'))

# Balances with confirmed issuance.
self.nodes[0].generatetoaddress(1, RANDOM_COINBASE_ADDRESS)
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo["balance"].get(asset, 0), Decimal('100'))
assert_equal(walletinfo["unconfirmed_balance"].get(asset, 0), Decimal('0'))

# Sending coins to other wallet.
self.nodes[0].sendtoaddress(address=self.nodes[1].getnewaddress(), amount="50", assetlabel=asset)
self.sync_all()

# Balances with unconfirmed receive
walletinfo = self.nodes[1].getwalletinfo()
assert_equal(walletinfo["balance"].get(asset, 0), Decimal('0'))
assert_equal(walletinfo["unconfirmed_balance"].get(asset, 0), Decimal('50'))

# Balances with confirmed receive
self.nodes[1].generatetoaddress(1, RANDOM_COINBASE_ADDRESS)
walletinfo = self.nodes[1].getwalletinfo()
assert_equal(walletinfo["balance"].get(asset, 0), Decimal('50'))
assert_equal(walletinfo["unconfirmed_balance"].get(asset, 0), Decimal('0'))

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

0 comments on commit 521e357

Please sign in to comment.