From 3470399a32a320170cdbd05eadb408da012243d3 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 25 Jul 2021 18:05:13 +0200 Subject: [PATCH] Rehabilitate tx list test in cic-eth --- apps/cic-cache/requirements.txt | 2 +- apps/cic-eth/cic_eth/ext/tx.py | 5 ++--- apps/cic-eth/requirements.txt | 2 +- apps/cic-eth/tests/check/test_check_gas.py | 2 +- apps/cic-eth/tests/unit/ext/test_ext_tx.py | 19 +++++++++---------- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/cic-cache/requirements.txt b/apps/cic-cache/requirements.txt index d80a025d..dd3a6b0b 100644 --- a/apps/cic-cache/requirements.txt +++ b/apps/cic-cache/requirements.txt @@ -10,5 +10,5 @@ celery==4.4.7 redis==3.5.3 chainsyncer[sql]>=0.0.6a1,<0.1.0 erc20-faucet>=0.2.4a2, <0.3.0 -chainlib-eth>=0.0.7a2,<0.1.0 +chainlib-eth>=0.0.7a3,<0.1.0 eth-address-index>=0.1.4a1,<0.2.0 diff --git a/apps/cic-eth/cic_eth/ext/tx.py b/apps/cic-eth/cic_eth/ext/tx.py index eb8ccff9..3adefa2e 100644 --- a/apps/cic-eth/cic_eth/ext/tx.py +++ b/apps/cic-eth/cic_eth/ext/tx.py @@ -26,6 +26,7 @@ from chainqueue.db.enum import StatusEnum from chainqueue.sql.query import get_tx_cache from eth_erc20 import ERC20 from erc20_faucet import Faucet +from potaahto.symbols import snake_and_camel # local imports from cic_eth.queue.time import tx_times @@ -107,7 +108,6 @@ def list_tx_by_bloom(self, bloomspec, address, chain_spec_dict): logg.debug('filter matched block {}'.format(block_height)) o = block_by_number(block_height) block = rpc.do(o) - logg.debug('block {}'.format(block)) for tx_index in range(0, len(block['transactions'])): tx_index_bytes = tx_index.to_bytes(4, 'big') @@ -115,9 +115,8 @@ def list_tx_by_bloom(self, bloomspec, address, chain_spec_dict): if tx_filter.check(composite): logg.debug('filter matched block {} tx {}'.format(block_height, tx_index)) + o = transaction_by_block(block['hash'], tx_index) try: - #tx = c.w3.eth.getTransactionByBlock(block_height, tx_index) - o = transaction_by_block(block['hash'], tx_index) tx = rpc.do(o) except Exception as e: logg.debug('false positive on block {} tx {} ({})'.format(block_height, tx_index, e)) diff --git a/apps/cic-eth/requirements.txt b/apps/cic-eth/requirements.txt index 5fe83ad4..52233522 100644 --- a/apps/cic-eth/requirements.txt +++ b/apps/cic-eth/requirements.txt @@ -1,3 +1,3 @@ celery==4.4.7 -chainlib-eth>=0.0.7a2,<0.1.0 +chainlib-eth>=0.0.7a3,<0.1.0 semver==2.13.0 diff --git a/apps/cic-eth/tests/check/test_check_gas.py b/apps/cic-eth/tests/check/test_check_gas.py index ea0ffb88..056120c8 100644 --- a/apps/cic-eth/tests/check/test_check_gas.py +++ b/apps/cic-eth/tests/check/test_check_gas.py @@ -11,7 +11,7 @@ def test_check_gas( whoever, ): - config.add(str(default_chain_spec), 'CIC_CHAIN_SPEC', exists_ok=True) + config.add(str(default_chain_spec), 'CHAIN_SPEC', exists_ok=True) config.add(100, 'ETH_GAS_GIFTER_MINIMUM_BALANCE', exists_ok=True) assert health(config=config) 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 90241865..43ce9861 100644 --- a/apps/cic-eth/tests/unit/ext/test_ext_tx.py +++ b/apps/cic-eth/tests/unit/ext/test_ext_tx.py @@ -20,7 +20,6 @@ from cic_eth.db.models.nonce import ( logg = logging.getLogger() -# TODO: This test fails when not run alone. Identify which fixture leaves a dirty state def test_filter_process( init_database, default_chain_spec, @@ -31,7 +30,7 @@ def test_filter_process( init_custodial, cic_registry, foo_token, - celery_session_worker, + celery_worker, ): b = moolb.Bloom(1024, 3) @@ -48,10 +47,10 @@ def test_filter_process( eth_rpc.do(o) o = receipt(tx_hash_hex) r = eth_rpc.do(o) - a = r['block_number'] - b.add(a.to_bytes(4, 'big')) - a = r['block_number'] + r['transaction_index'] - t.add(a.to_bytes(4, 'big')) + block_bytes = r['block_number'].to_bytes(4, 'big') + b.add(block_bytes) + tx_index_bytes = r['transaction_index'].to_bytes(4, 'big') + t.add(block_bytes + tx_index_bytes) tx_hashes.append(tx_hash_hex) # external tx @@ -61,10 +60,10 @@ def test_filter_process( eth_rpc.do(o) o = receipt(tx_hash_hex) r = eth_rpc.do(o) - a = r['block_number'] - b.add(a.to_bytes(4, 'big')) - a = r['block_number'] + r['transaction_index'] - t.add(a.to_bytes(4, 'big')) + block_bytes = r['block_number'].to_bytes(4, 'big') + b.add(block_bytes) + tx_index_bytes = r['transaction_index'].to_bytes(4, 'big') + t.add(block_bytes + tx_index_bytes) tx_hashes.append(tx_hash_hex) init_eth_tester.mine_blocks(10)