2021-02-01 18:12:51 +01:00
|
|
|
# standard imports
|
|
|
|
import os
|
|
|
|
import sys
|
2021-03-29 15:27:53 +02:00
|
|
|
import logging
|
2021-02-01 18:12:51 +01:00
|
|
|
|
2021-04-23 23:31:41 +02:00
|
|
|
# external imports
|
|
|
|
from chainlib.eth.erc20 import ERC20
|
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
# local imports
|
|
|
|
from cic_eth.api import Api
|
2021-04-23 23:31:41 +02:00
|
|
|
from cic_eth.task import BaseTask
|
2021-02-01 18:12:51 +01:00
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
root_dir = os.path.dirname(script_dir)
|
|
|
|
sys.path.insert(0, root_dir)
|
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
# assemble fixtures
|
2021-02-01 18:12:51 +01:00
|
|
|
from tests.fixtures_config import *
|
|
|
|
from tests.fixtures_database import *
|
2021-03-29 15:27:53 +02:00
|
|
|
from tests.fixtures_celery import *
|
|
|
|
from tests.fixtures_role import *
|
|
|
|
from chainlib.eth.pytest import *
|
|
|
|
from eth_contract_registry.pytest import *
|
|
|
|
from cic_eth_registry.pytest.fixtures_contracts import *
|
|
|
|
from cic_eth_registry.pytest.fixtures_tokens import *
|
2021-02-01 18:12:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
2021-03-29 15:27:53 +02:00
|
|
|
def api(
|
|
|
|
default_chain_spec,
|
|
|
|
custodial_roles,
|
|
|
|
):
|
|
|
|
chain_str = str(default_chain_spec)
|
|
|
|
return Api(chain_str, queue=None, callback_param='foo')
|
2021-04-23 23:31:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def foo_token_symbol(
|
|
|
|
default_chain_spec,
|
|
|
|
foo_token,
|
|
|
|
eth_rpc,
|
|
|
|
contract_roles,
|
|
|
|
):
|
|
|
|
|
|
|
|
c = ERC20(default_chain_spec)
|
|
|
|
o = c.symbol(foo_token, sender_address=contract_roles['CONTRACT_DEPLOYER'])
|
|
|
|
r = eth_rpc.do(o)
|
|
|
|
return c.parse_symbol(r)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def default_token(
|
|
|
|
foo_token,
|
|
|
|
foo_token_symbol,
|
|
|
|
):
|
|
|
|
BaseTask.default_token_symbol = foo_token_symbol
|
|
|
|
BaseTask.default_token_address = foo_token
|