From 40b2e6645228fe0870437298c19ede95cce40940 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 6 Apr 2021 10:17:43 +0200 Subject: [PATCH] Fix remaining tests not using chain_spec in method refactors --- apps/cic-eth/cic_eth/eth/erc20.py | 4 ++-- apps/cic-eth/cic_eth/eth/tx.py | 2 ++ apps/cic-eth/cic_eth/ext/address.py | 2 +- apps/cic-eth/cic_eth/queue/state.py | 4 ++-- apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py | 1 + apps/cic-eth/cic_eth/runnable/daemons/retry.py | 2 +- apps/cic-eth/requirements.txt | 4 ++-- apps/cic-eth/tests/task/api/test_app.py | 3 ++- apps/cic-eth/tests/task/test_task_account.py | 2 +- apps/cic-eth/tests/unit/ext/test_ext_tx.py | 4 ++-- apps/contract-migration/docker/Dockerfile | 4 ++-- apps/contract-migration/scripts/import_users.py | 6 ------ 12 files changed, 18 insertions(+), 20 deletions(-) diff --git a/apps/cic-eth/cic_eth/eth/erc20.py b/apps/cic-eth/cic_eth/eth/erc20.py index 845ec0ea..5bde32b9 100644 --- a/apps/cic-eth/cic_eth/eth/erc20.py +++ b/apps/cic-eth/cic_eth/eth/erc20.py @@ -61,8 +61,8 @@ def balance(tokens, holder_address, chain_spec_dict): for t in tokens: address = t['address'] - token = ERC20Token(rpc, address) - c = ERC20() + token = ERC20Token(chain_spec, rpc, address) + c = ERC20(chain_spec) o = c.balance_of(address, holder_address, sender_address=caller_address) r = rpc.do(o) t['balance_network'] = c.parse_balance(r) diff --git a/apps/cic-eth/cic_eth/eth/tx.py b/apps/cic-eth/cic_eth/eth/tx.py index 05bef05d..4883e872 100644 --- a/apps/cic-eth/cic_eth/eth/tx.py +++ b/apps/cic-eth/cic_eth/eth/tx.py @@ -171,6 +171,7 @@ def sync_tx(self, tx_hash_hex, chain_spec_dict): except NotFoundEthException as e: pass + # TODO: apply receipt in tx object to validate and normalize input if rcpt != None: success = rcpt['status'] == 1 logg.debug('sync tx {} mined block {} success {}'.format(tx_hash_hex, rcpt['blockNumber'], success)) @@ -180,6 +181,7 @@ def sync_tx(self, tx_hash_hex, chain_spec_dict): [ tx_hash_hex, rcpt['blockNumber'], + rcpt['transactionIndex'], not success, ], queue=queue, diff --git a/apps/cic-eth/cic_eth/ext/address.py b/apps/cic-eth/cic_eth/ext/address.py index 449a5f3c..3db76925 100644 --- a/apps/cic-eth/cic_eth/ext/address.py +++ b/apps/cic-eth/cic_eth/ext/address.py @@ -23,7 +23,7 @@ def translate_address(address, trusted_addresses, chain_spec, sender_address=ZER registry = CICRegistry(chain_spec, rpc) declarator_address = registry.by_name('AddressDeclarator', sender_address=sender_address) - c = AddressDeclarator() + c = AddressDeclarator(chain_spec) for trusted_address in trusted_addresses: o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address) diff --git a/apps/cic-eth/cic_eth/queue/state.py b/apps/cic-eth/cic_eth/queue/state.py index 5c86233f..89d5ce40 100644 --- a/apps/cic-eth/cic_eth/queue/state.py +++ b/apps/cic-eth/cic_eth/queue/state.py @@ -20,10 +20,10 @@ def set_sent(chain_spec_dict, tx_hash, fail=False): @celery_app.task(base=CriticalSQLAlchemyTask) -def set_final(chain_spec_dict, tx_hash, block=None, fail=False): +def set_final(chain_spec_dict, tx_hash, block=None, tx_index=None, fail=False): chain_spec = ChainSpec.from_dict(chain_spec_dict) session = SessionBase.create_session() - r = chainqueue.state.set_final(chain_spec, tx_hash, block, fail, session=session) + r = chainqueue.state.set_final(chain_spec, tx_hash, block=block, tx_index=tx_index, fail=fail, session=session) session.close() return r diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py index d226c263..4e06e4d8 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py @@ -39,6 +39,7 @@ class TxFilter(SyncFilter): self.chain_spec.asdict(), add_0x(tx_hash_hex), tx.block.number, + tx.index, tx.status == Status.ERROR, ], queue=self.queue, diff --git a/apps/cic-eth/cic_eth/runnable/daemons/retry.py b/apps/cic-eth/cic_eth/runnable/daemons/retry.py index 6fefc94d..1044101b 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/retry.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/retry.py @@ -80,7 +80,7 @@ straggler_delay = int(config.get('CIC_TX_RETRY_DELAY')) # logg.debug('submitting tx {} for retry'.format(tx_hash)) # s_check = celery.signature( # 'cic_eth.admin.ctrl.check_lock', - [ +# [ # tx_hash, # chain_str, # LockEnum.QUEUE, diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 7efa8df2..e8f809db 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -2,7 +2,7 @@ cic-base~=0.1.2a60 celery==4.4.7 crypto-dev-signer~=0.4.14a17 confini~=0.3.6rc3 -cic-eth-registry~=0.5.4a11 +cic-eth-registry~=0.5.4a12 #cic-bancor~=0.0.6 redis==3.5.3 alembic==1.4.2 @@ -19,7 +19,7 @@ eth-address-index~=0.1.1a7 chainlib~=0.0.2a4 hexathon~=0.0.1a7 chainsyncer~=0.0.1a21 -chainqueue~=0.0.1a5 +chainqueue~=0.0.1a6 pysha3==1.0.2 coincurve==15.0.0 sarafu-faucet~=0.0.2a16 diff --git a/apps/cic-eth/tests/task/api/test_app.py b/apps/cic-eth/tests/task/api/test_app.py index 5e1733a2..1d3e64aa 100644 --- a/apps/cic-eth/tests/task/api/test_app.py +++ b/apps/cic-eth/tests/task/api/test_app.py @@ -38,11 +38,12 @@ def test_transfer_api( agent_roles, cic_registry, register_tokens, + register_lookups, celery_session_worker, ): #token = CICRegistry.get_address(default_chain_spec, bancor_tokens[0]) - foo_token_cache = ERC20Token(eth_rpc, foo_token) + foo_token_cache = ERC20Token(default_chain_spec, eth_rpc, foo_token) api = Api(str(default_chain_spec), callback_param='transfer', callback_task='cic_eth.callbacks.noop.noop', queue=None) t = api.transfer(custodial_roles['FOO_TOKEN_GIFTER'], agent_roles['ALICE'], 1024, foo_token_cache.symbol) diff --git a/apps/cic-eth/tests/task/test_task_account.py b/apps/cic-eth/tests/task/test_task_account.py index 412e1f07..010f0e51 100644 --- a/apps/cic-eth/tests/task/test_task_account.py +++ b/apps/cic-eth/tests/task/test_task_account.py @@ -116,7 +116,7 @@ def test_register_account( init_eth_tester.mine_block() - c = AccountRegistry() + c = AccountRegistry(default_chain_spec) o = c.have(account_registry, eth_empty_accounts[0], sender_address=call_sender) r = eth_rpc.do(o) assert int(strip_0x(r), 16) == 1 diff --git a/apps/cic-eth/tests/unit/ext/test_ext_tx.py b/apps/cic-eth/tests/unit/ext/test_ext_tx.py index d942c4ac..2fadca4b 100644 --- a/apps/cic-eth/tests/unit/ext/test_ext_tx.py +++ b/apps/cic-eth/tests/unit/ext/test_ext_tx.py @@ -43,7 +43,7 @@ def test_filter_process( nonce_oracle = RPCNonceOracle(agent_roles['ALICE'], eth_rpc) init_eth_tester.mine_blocks(13) - c = ERC20(signer=eth_signer, nonce_oracle=nonce_oracle) + c = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 1024) eth_rpc.do(o) o = receipt(tx_hash_hex) @@ -56,7 +56,7 @@ def test_filter_process( # external tx init_eth_tester.mine_blocks(28) - c = ERC20(signer=eth_signer, nonce_oracle=nonce_oracle) + c = ERC20(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.transfer(foo_token, agent_roles['ALICE'], agent_roles['BOB'], 512) eth_rpc.do(o) o = receipt(tx_hash_hex) diff --git a/apps/contract-migration/docker/Dockerfile b/apps/contract-migration/docker/Dockerfile index bfdfe4e2..14784233 100644 --- a/apps/contract-migration/docker/Dockerfile +++ b/apps/contract-migration/docker/Dockerfile @@ -57,8 +57,8 @@ WORKDIR /home/grassroots USER grassroots ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 -ARG cic_base_version=0.1.2a60 -ARG cic_eth_version=0.11.0a4 +ARG cic_base_version=0.1.2a61 +ARG cic_eth_version=0.11.0a5 ARG sarafu_faucet_version=0.0.2a16 ARG cic_contracts_version=0.0.2a2 RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version \ diff --git a/apps/contract-migration/scripts/import_users.py b/apps/contract-migration/scripts/import_users.py index d7a8e6e0..acba257f 100644 --- a/apps/contract-migration/scripts/import_users.py +++ b/apps/contract-migration/scripts/import_users.py @@ -124,10 +124,6 @@ def register_eth(i, u): return address -def register_ussd(u): - pass - - if __name__ == '__main__': #fi = open(os.path.join(user_out_dir, 'addresses.csv'), 'a') @@ -155,8 +151,6 @@ if __name__ == '__main__': sub_chain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id()) u.identities['evm'][sub_chain_str] = [new_address] - register_ussd(u) - new_address_clean = strip_0x(new_address) filepath = os.path.join( user_new_dir,