Ejemplo n.º 1
0
def test_balance():
    account = jsonrpc.Account(balances=[
        jsonrpc.Amount(amount=32, currency="XUS"),
        jsonrpc.Amount(amount=33, currency="XDX"),
    ])
    assert utils.balance(account, "XUS") == 32
    assert utils.balance(account, "XDX") == 33
    assert utils.balance(account, "unknown") == 0
Ejemplo n.º 2
0
 def vasp_balance(self, currency: str = testnet.TEST_CURRENCY_CODE) -> int:
     balance = 0
     for vasp in [self.parent_vasp] + self.child_vasps:
         account = self.jsonrpc_client.must_get_account(
             vasp.account_address)
         balance += utils.balance(account, currency)
     return balance
Ejemplo n.º 3
0
async def test_ensure_account_balance_is_always_enough():
    client = create_client()
    faucet = Faucet(client)
    account = LocalAccount.generate()
    await faucet.mint(account.auth_key.hex(), 1, XUS)
    da = DiemAccount(account, [], client)
    account_data = await client.must_get_account(account.account_address)
    amount = utils.balance(account_data, XUS) + 1
    payee = await faucet.gen_account()
    txn = await da.submit_p2p(gen_txn(payee=payee.account_identifier(), amount=amount), (b"", b""))
    await client.wait_for_transaction(txn)