cic-internal-integration/apps/cic-eth/tests/task/api/test_balance.py

61 lines
1.3 KiB
Python
Raw Permalink Normal View History

# standard imports
import os
import logging
# external imports
2021-10-07 17:12:35 +02:00
import pytest
from chainlib.eth.address import to_checksum_address
2021-10-07 17:12:35 +02:00
from hexathon import add_0x
# local imports
from cic_eth.api.api_task import Api
logg = logging.getLogger()
2021-10-07 17:12:35 +02:00
def test_balance_simple_api(
default_chain_spec,
init_database,
cic_registry,
foo_token,
2021-10-07 17:12:35 +02:00
register_lookups,
register_tokens,
api,
celery_session_worker,
):
chain_str = str(default_chain_spec)
2021-10-07 17:12:35 +02:00
a = add_0x(to_checksum_address(os.urandom(20).hex()))
t = api.balance(a, 'FOO', include_pending=False)
r = t.get_leaf()
assert t.successful()
logg.debug(r)
assert r[0].get('balance_network') != None
def test_balance_complex_api(
default_chain_spec,
init_database,
cic_registry,
foo_token,
2021-10-07 17:12:35 +02:00
register_lookups,
register_tokens,
api,
celery_session_worker,
):
chain_str = str(default_chain_spec)
2021-10-07 17:12:35 +02:00
a = add_0x(to_checksum_address(os.urandom(20).hex()))
t = api.balance(a, 'FOO', include_pending=True)
r = t.get_leaf()
assert t.successful()
logg.debug(r)
assert r[0].get('balance_incoming') != None
assert r[0].get('balance_outgoing') != None
assert r[0].get('balance_network') != None