diff --git a/apps/cic-eth/tests/conftest.py b/apps/cic-eth/tests/conftest.py index 5c4c80d7..eca7cc8c 100644 --- a/apps/cic-eth/tests/conftest.py +++ b/apps/cic-eth/tests/conftest.py @@ -3,8 +3,12 @@ import os import sys import logging +# external imports +from chainlib.eth.erc20 import ERC20 + # local imports from cic_eth.api import Api +from cic_eth.task import BaseTask script_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.dirname(script_dir) @@ -28,3 +32,26 @@ def api( ): chain_str = str(default_chain_spec) return Api(chain_str, queue=None, callback_param='foo') + + +@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 diff --git a/apps/cic-eth/tests/fixtures_celery.py b/apps/cic-eth/tests/fixtures_celery.py index 33cadc31..26f640d3 100644 --- a/apps/cic-eth/tests/fixtures_celery.py +++ b/apps/cic-eth/tests/fixtures_celery.py @@ -34,6 +34,7 @@ def celery_includes(): 'cic_eth.admin.ctrl', 'cic_eth.admin.nonce', 'cic_eth.admin.debug', + 'cic_eth.admin.token', 'cic_eth.eth.account', 'cic_eth.callbacks.noop', 'cic_eth.callbacks.http', diff --git a/apps/cic-eth/tests/unit/admin/test_default_token.py b/apps/cic-eth/tests/unit/admin/test_default_token.py new file mode 100644 index 00000000..d49ed3fe --- /dev/null +++ b/apps/cic-eth/tests/unit/admin/test_default_token.py @@ -0,0 +1,21 @@ +# external imports +import celery + + +def test_default_token( + default_token, + celery_session_worker, + foo_token, + foo_token_symbol, + ): + + s = celery.signature( + 'cic_eth.admin.token.default_token', + [], + queue=None, + ) + t = s.apply_async() + r = t.get() + + assert r['address'] == foo_token + assert r['symbol'] == foo_token_symbol