diff --git a/apps/cic-eth/cic_eth/api/api_task.py b/apps/cic-eth/cic_eth/api/api_task.py index 436a8370..433c1be8 100644 --- a/apps/cic-eth/cic_eth/api/api_task.py +++ b/apps/cic-eth/cic_eth/api/api_task.py @@ -118,7 +118,11 @@ class Api(ApiBase): if proof == None: logg.debug('looking up tokens without external proof check: {}'.format(','.join(token_symbols))) proof = '' - proof = Api.to_v_list(proof, len(token_symbols)) + + l = len(token_symbols) + if len(proof) == 0: + l = 0 + proof = Api.to_v_list(proof, l) chain_spec_dict = self.chain_spec.asdict() diff --git a/apps/cic-eth/tests/task/api/test_app_noncritical.py b/apps/cic-eth/tests/task/api/test_app_noncritical.py index 241fc1f6..85ef8630 100644 --- a/apps/cic-eth/tests/task/api/test_app_noncritical.py +++ b/apps/cic-eth/tests/task/api/test_app_noncritical.py @@ -41,6 +41,8 @@ def test_default_token( def test_to_v_list(): + assert Api.to_v_list('', 0) == [] + assert Api.to_v_list([], 0) == [] assert Api.to_v_list('foo', 1) == [['foo']] assert Api.to_v_list(['foo'], 1) == [['foo']] assert Api.to_v_list(['foo', 'bar'], 2) == [['foo'], ['bar']] @@ -95,6 +97,40 @@ def test_token_single( assert r[0]['address'] == strip_0x(foo_token) +def test_tokens_noproof( + default_chain_spec, + foo_token, + bar_token, + token_registry, + register_tokens, + register_lookups, + cic_registry, + init_database, + init_celery_tasks, + custodial_roles, + foo_token_declaration, + bar_token_declaration, + celery_session_worker, + ): + + api = Api(str(default_chain_spec), queue=None, callback_param='foo') + + t = api.tokens(['FOO'], proof=[]) + r = t.get() + assert len(r) == 1 + assert r[0]['address'] == strip_0x(foo_token) + + t = api.tokens(['FOO'], proof='') + r = t.get() + assert len(r) == 1 + assert r[0]['address'] == strip_0x(foo_token) + + t = api.tokens(['FOO'], proof=None) + r = t.get() + assert len(r) == 1 + assert r[0]['address'] == strip_0x(foo_token) + + def test_tokens( default_chain_spec, foo_token,