From 14449f5c6d028f3e73079add90dd7b0e8ea321c2 Mon Sep 17 00:00:00 2001 From: nolash Date: Wed, 22 Dec 2021 20:01:59 +0000 Subject: [PATCH] Rehabilitate tests for cic-eth --- apps/cic-eth/cic_eth/cli/config.py | 13 +++++++++++-- apps/cic-eth/cic_eth/eth/gas.py | 2 +- apps/cic-eth/requirements.txt | 2 +- apps/cic-eth/test_requirements.txt | 2 +- apps/cic-eth/tests/filters/test_token_filter.py | 6 ++++-- apps/cic-eth/tests/task/api/test_admin.py | 1 - apps/cic-eth/tests/task/api/test_app_noncritical.py | 6 ++++++ apps/cic-eth/tests/task/test_task_gas.py | 2 +- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/apps/cic-eth/cic_eth/cli/config.py b/apps/cic-eth/cic_eth/cli/config.py index 24ffcf11..ebc45018 100644 --- a/apps/cic-eth/cic_eth/cli/config.py +++ b/apps/cic-eth/cic_eth/cli/config.py @@ -63,22 +63,31 @@ class Config(BaseConfig): config.get('REDIS_HOST'), config.get('REDIS_PORT'), ) + db = getattr(args, 'redis_db', None) + if db != None: + db = str(db) + redis_url = ( 'redis', hostport, - getattr(args, 'redis_db', None), + db, ) + celery_config_url = urllib.parse.urlsplit(config.get('CELERY_BROKER_URL')) hostport = urlhostmerge( celery_config_url[1], getattr(args, 'celery_host', None), getattr(args, 'celery_port', None), ) + db = getattr(args, 'redis_db', None) + if db != None: + db = str(db) celery_arg_url = ( getattr(args, 'celery_scheme', None), hostport, - getattr(args, 'celery_db', None), + db, ) + celery_url = urlmerge(redis_url, celery_config_url, celery_arg_url) celery_url_string = urllib.parse.urlunsplit(celery_url) local_celery_args_override['CELERY_BROKER_URL'] = celery_url_string diff --git a/apps/cic-eth/cic_eth/eth/gas.py b/apps/cic-eth/cic_eth/eth/gas.py index 95e7ab58..9b0717c8 100644 --- a/apps/cic-eth/cic_eth/eth/gas.py +++ b/apps/cic-eth/cic_eth/eth/gas.py @@ -92,7 +92,7 @@ def apply_gas_value_cache_local(address, method, value, tx_hash, session=None): if o == None: o = GasCache(address, method, value, tx_hash) - elif tx.gas_used > o.value: + elif value > o.value: o.value = value o.tx_hash = strip_0x(tx_hash) diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index b87831c4..72118a58 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -2,6 +2,6 @@ celery==4.4.7 semver==2.13.0 chainlib-eth~=0.0.14 urlybird~=0.0.1 -cic-eth-registry~=0.6.4 +cic-eth-registry~=0.6.5 cic-types~=0.2.1a8 cic-eth-aux-erc20-demurrage-token~=0.0.3 diff --git a/apps/cic-eth/test_requirements.txt b/apps/cic-eth/test_requirements.txt index bcd0a4b0..fdbdcb21 100644 --- a/apps/cic-eth/test_requirements.txt +++ b/apps/cic-eth/test_requirements.txt @@ -6,5 +6,5 @@ pytest-redis==2.0.0 redis==3.5.3 eth-tester==0.5.0b3 py-evm==0.3.0a20 -eth-erc20==0.1.4 +eth-erc20~=0.1.5 erc20-transfer-authorization~=0.3.6 diff --git a/apps/cic-eth/tests/filters/test_token_filter.py b/apps/cic-eth/tests/filters/test_token_filter.py index df2bfdba..d37888cd 100644 --- a/apps/cic-eth/tests/filters/test_token_filter.py +++ b/apps/cic-eth/tests/filters/test_token_filter.py @@ -40,7 +40,9 @@ def test_filter_gas( foo_token, token_registry, register_lookups, - celery_session_worker, + register_tokens, + #celery_session_worker, + celery_worker, cic_registry, ): @@ -69,7 +71,7 @@ def test_filter_gas( tx = Tx(tx_src, block=block) tx.apply_receipt(rcpt) t = fltr.filter(eth_rpc, block, tx, db_session=init_database) - assert t == None + assert t.get() == None nonce_oracle = RPCNonceOracle(contract_roles['CONTRACT_DEPLOYER'], eth_rpc) c = TokenUniqueSymbolIndex(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) diff --git a/apps/cic-eth/tests/task/api/test_admin.py b/apps/cic-eth/tests/task/api/test_admin.py index d732fb96..dcfe2011 100644 --- a/apps/cic-eth/tests/task/api/test_admin.py +++ b/apps/cic-eth/tests/task/api/test_admin.py @@ -288,7 +288,6 @@ def test_fix_nonce( init_database.commit() - logg.debug('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') txs = get_nonce_tx_local(default_chain_spec, 3, agent_roles['ALICE'], session=init_database) ks = txs.keys() assert len(ks) == 2 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 a7a3177b..4e8e7eed 100644 --- a/apps/cic-eth/tests/task/api/test_app_noncritical.py +++ b/apps/cic-eth/tests/task/api/test_app_noncritical.py @@ -191,11 +191,17 @@ def test_tokens( break api_param = str(uuid.uuid4()) + fp = os.path.join(CallbackTask.mmap_path, api_param) + f = open(fp, 'wb+') + f.write(b'\x00') + f.close() + api = Api(str(default_chain_spec), queue=None, callback_param=api_param, callback_task='cic_eth.pytest.mock.callback.test_callback') t = api.tokens(['BAR'], proof=[[bar_token_declaration]]) r = t.get() logg.debug('rr {} {}'.format(r, t.children)) + while True: fp = os.path.join(CallbackTask.mmap_path, api_param) try: diff --git a/apps/cic-eth/tests/task/test_task_gas.py b/apps/cic-eth/tests/task/test_task_gas.py index 317f622d..63e09667 100644 --- a/apps/cic-eth/tests/task/test_task_gas.py +++ b/apps/cic-eth/tests/task/test_task_gas.py @@ -45,7 +45,7 @@ def test_task_gas_limit( eth_signer, default_chain_spec, agent_roles, - celery_worker, + celery_session_worker, ): rpc = RPCConnection.connect(default_chain_spec, 'default') gas_oracle = BaseTask().create_gas_oracle(rpc)