Rehabilitate tests for cic-eth

This commit is contained in:
nolash 2021-12-22 20:01:59 +00:00
parent 15618fa061
commit 14449f5c6d
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
8 changed files with 25 additions and 9 deletions

View File

@ -63,22 +63,31 @@ class Config(BaseConfig):
config.get('REDIS_HOST'), config.get('REDIS_HOST'),
config.get('REDIS_PORT'), config.get('REDIS_PORT'),
) )
db = getattr(args, 'redis_db', None)
if db != None:
db = str(db)
redis_url = ( redis_url = (
'redis', 'redis',
hostport, hostport,
getattr(args, 'redis_db', None), db,
) )
celery_config_url = urllib.parse.urlsplit(config.get('CELERY_BROKER_URL')) celery_config_url = urllib.parse.urlsplit(config.get('CELERY_BROKER_URL'))
hostport = urlhostmerge( hostport = urlhostmerge(
celery_config_url[1], celery_config_url[1],
getattr(args, 'celery_host', None), getattr(args, 'celery_host', None),
getattr(args, 'celery_port', None), getattr(args, 'celery_port', None),
) )
db = getattr(args, 'redis_db', None)
if db != None:
db = str(db)
celery_arg_url = ( celery_arg_url = (
getattr(args, 'celery_scheme', None), getattr(args, 'celery_scheme', None),
hostport, hostport,
getattr(args, 'celery_db', None), db,
) )
celery_url = urlmerge(redis_url, celery_config_url, celery_arg_url) celery_url = urlmerge(redis_url, celery_config_url, celery_arg_url)
celery_url_string = urllib.parse.urlunsplit(celery_url) celery_url_string = urllib.parse.urlunsplit(celery_url)
local_celery_args_override['CELERY_BROKER_URL'] = celery_url_string local_celery_args_override['CELERY_BROKER_URL'] = celery_url_string

View File

@ -92,7 +92,7 @@ def apply_gas_value_cache_local(address, method, value, tx_hash, session=None):
if o == None: if o == None:
o = GasCache(address, method, value, tx_hash) o = GasCache(address, method, value, tx_hash)
elif tx.gas_used > o.value: elif value > o.value:
o.value = value o.value = value
o.tx_hash = strip_0x(tx_hash) o.tx_hash = strip_0x(tx_hash)

View File

@ -2,6 +2,6 @@ celery==4.4.7
semver==2.13.0 semver==2.13.0
chainlib-eth~=0.0.14 chainlib-eth~=0.0.14
urlybird~=0.0.1 urlybird~=0.0.1
cic-eth-registry~=0.6.4 cic-eth-registry~=0.6.5
cic-types~=0.2.1a8 cic-types~=0.2.1a8
cic-eth-aux-erc20-demurrage-token~=0.0.3 cic-eth-aux-erc20-demurrage-token~=0.0.3

View File

@ -6,5 +6,5 @@ pytest-redis==2.0.0
redis==3.5.3 redis==3.5.3
eth-tester==0.5.0b3 eth-tester==0.5.0b3
py-evm==0.3.0a20 py-evm==0.3.0a20
eth-erc20==0.1.4 eth-erc20~=0.1.5
erc20-transfer-authorization~=0.3.6 erc20-transfer-authorization~=0.3.6

View File

@ -40,7 +40,9 @@ def test_filter_gas(
foo_token, foo_token,
token_registry, token_registry,
register_lookups, register_lookups,
celery_session_worker, register_tokens,
#celery_session_worker,
celery_worker,
cic_registry, cic_registry,
): ):
@ -69,7 +71,7 @@ def test_filter_gas(
tx = Tx(tx_src, block=block) tx = Tx(tx_src, block=block)
tx.apply_receipt(rcpt) tx.apply_receipt(rcpt)
t = fltr.filter(eth_rpc, block, tx, db_session=init_database) 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) nonce_oracle = RPCNonceOracle(contract_roles['CONTRACT_DEPLOYER'], eth_rpc)
c = TokenUniqueSymbolIndex(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) c = TokenUniqueSymbolIndex(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle)

View File

@ -288,7 +288,6 @@ def test_fix_nonce(
init_database.commit() init_database.commit()
logg.debug('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
txs = get_nonce_tx_local(default_chain_spec, 3, agent_roles['ALICE'], session=init_database) txs = get_nonce_tx_local(default_chain_spec, 3, agent_roles['ALICE'], session=init_database)
ks = txs.keys() ks = txs.keys()
assert len(ks) == 2 assert len(ks) == 2

View File

@ -191,11 +191,17 @@ def test_tokens(
break break
api_param = str(uuid.uuid4()) 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') 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]]) t = api.tokens(['BAR'], proof=[[bar_token_declaration]])
r = t.get() r = t.get()
logg.debug('rr {} {}'.format(r, t.children)) logg.debug('rr {} {}'.format(r, t.children))
while True: while True:
fp = os.path.join(CallbackTask.mmap_path, api_param) fp = os.path.join(CallbackTask.mmap_path, api_param)
try: try:

View File

@ -45,7 +45,7 @@ def test_task_gas_limit(
eth_signer, eth_signer,
default_chain_spec, default_chain_spec,
agent_roles, agent_roles,
celery_worker, celery_session_worker,
): ):
rpc = RPCConnection.connect(default_chain_spec, 'default') rpc = RPCConnection.connect(default_chain_spec, 'default')
gas_oracle = BaseTask().create_gas_oracle(rpc) gas_oracle = BaseTask().create_gas_oracle(rpc)