Skip to content

Commit

Permalink
Merge #828: Add test to test unconfirmed asset balances
Browse files Browse the repository at this point in the history
521e357 Add test to test unconfirmed asset balances (Steven Roose)

Pull request description:

  Addresses #827.

Tree-SHA512: 00f75d5b43b2f676b83e2929eb9b213e48ccb65f7c421f66475bf90d56a4607aa67f1f9c3edc78ced01a694c9f5e4fb3aba7a8110e15cef370fd8707958a62c5
  • Loading branch information
stevenroose committed Mar 16, 2020
2 parents 29298ce + 521e357 commit bef78a0
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 bef78a0

Please sign in to comment.