chaind-eth

Queue server for ethereum
Log | Files | Refs | README | LICENSE

commit 786e1a6029401701b027e50876e92497154fe67f
parent 574ddcba1ac2ad1728b581d617e49f4fb418edcb
Author: nolash <dev@holbrook.no>
Date:   Wed, 20 Oct 2021 14:31:02 +0200

Patch unnormalized address in query to chainqueue

Diffstat:
Mchaind_eth/dispatch.py | 4++++
Mrequirements.txt | 6+++---
Mrun_tests.sh | 2++
Mtests/chaind_eth_base.py | 7++++---
Mtests/test_adapter.py | 2+-
Mtests/test_dispatch.py | 11++++++-----
Mtests/test_filter.py | 3++-
7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/chaind_eth/dispatch.py b/chaind_eth/dispatch.py @@ -8,6 +8,7 @@ from chainlib.error import JSONRPCException from chainqueue.enum import StatusBits from chainqueue.sql.query import count_tx from hexathon import strip_0x +from chainqueue.encode import TxNormalizer #logg = logging.getLogger(__name__) logg = logging.getLogger() @@ -23,6 +24,7 @@ class Dispatcher: self.chain_spec = chain_spec self.adapter = adapter self.limit = limit + self.tx_normalizer = TxNormalizer() def __init_count(self, address, session): @@ -36,10 +38,12 @@ class Dispatcher: def get_count(self, address, session): + address = self.tx_normalizer.wallet_address(address) return self.__init_count(address, session) def inc_count(self, address, session): + address = self.tx_normalizer.wallet_address(address) self.__init_count(address, session) self.address_counts[address] -= 1 diff --git a/requirements.txt b/requirements.txt @@ -1,4 +1,4 @@ -chaind<=0.0.3,>=0.0.3a5 +chaind<=0.0.3,>=0.0.3a6 hexathon~=0.0.1a8 -chainlib-eth<=0.1.0,>=0.0.9a10 -eth-address-index<=0.3.0,>=0.2.3a5 +chainlib-eth<=0.1.0,>=0.0.10a10 +eth-token-index<=0.3.0,>=0.2.4a1 diff --git a/run_tests.sh b/run_tests.sh @@ -2,9 +2,11 @@ set -e set -x +set -a export PYTHONPATH=${PYTHONPATH:.} for f in `ls tests/*.py`; do python $f done +set +a set +x set +e diff --git a/tests/chaind_eth_base.py b/tests/chaind_eth_base.py @@ -22,10 +22,10 @@ class TestBase(EthTesterCase): def setUp(self): super(TestBase, self).setUp() - self.db_chainsyncer = ChainSyncerDb() + self.db_chainsyncer = ChainSyncerDb(debug=bool(os.environ.get('DATABASE_DEBUG'))) self.session_chainsyncer = self.db_chainsyncer.bind_session() - self.db_chainqueue = ChainQueueDb() + self.db_chainqueue = ChainQueueDb(debug=bool(os.environ.get('DATABASE_DEBUG'))) self.session_chainqueue = self.db_chainqueue.bind_session() self.interface = EthChainInterface() @@ -40,7 +40,8 @@ class TestBase(EthTesterCase): class TestSQLBase(TestBase): - example_tx = bytes.fromhex('f8650d8405f5e10082520894ee38d3a40e177608d41978778206831f60dd0fa88204008077a040adee2ad0a0e566bced4b76a8899549e86719eb8866b87674b6fdc88479c201a030b3ca061bb330f4d78bc9cb8144c8e570339496f56b7809387de2ffeaa585d5') + example_tx_hex = 'f8650d8405f5e10082520894ee38d3a40e177608d41978778206831f60dd0fa88204008077a040adee2ad0a0e566bced4b76a8899549e86719eb8866b87674b6fdc88479c201a030b3ca061bb330f4d78bc9cb8144c8e570339496f56b7809387de2ffeaa585d5' + example_tx = bytes.fromhex(example_tx_hex) example_tx_sender = add_0x(to_checksum_address('eb3907ecad74a0013c259d5874ae7f22dcbcc95c')) dsn = dsn_from_config(db_config) diff --git a/tests/test_adapter.py b/tests/test_adapter.py @@ -19,7 +19,7 @@ class TestAdapter(TestSQLBase): def test_eth_adapter_add(self): - self.adapter.add(self.example_tx, self.chain_spec, session=self.session_chainqueue) + self.adapter.add(self.example_tx_hex, self.chain_spec, session=self.session_chainqueue) if __name__ == '__main__': diff --git a/tests/test_dispatch.py b/tests/test_dispatch.py @@ -37,14 +37,15 @@ class TestDispatcher(TestSQLBase): tx_raw_rlp_signed_bytes = bytes.fromhex(strip_0x(tx_raw_rlp_signed)) dispatcher = Dispatcher(self.chain_spec, self.adapter, 1) - self.adapter.add(tx_raw_rlp_signed_bytes, self.chain_spec, session=self.session_chainqueue) - assert dispatcher.get_count(self.example_tx_sender, self.session_chainqueue) == 1 + self.adapter.add(tx_raw_rlp_signed, self.chain_spec, session=self.session_chainqueue) + #self.assertEqual(dispatcher.get_count(self.example_tx_sender, self.session_chainqueue), 1) + self.assertEqual(dispatcher.get_count(self.accounts[0], self.session_chainqueue), 1) + dispatcher.process(self.rpc, self.session_chainqueue) tx_obj = unpack(tx_raw_rlp_signed_bytes, self.chain_spec) o = get_tx(self.chain_spec, tx_obj['hash'], session=self.session_chainqueue) - assert o['status'] & StatusBits.IN_NETWORK > 0 - - assert dispatcher.get_count(self.accounts[0], self.session_chainqueue) == 0 + self.assertGreater(o['status'] & StatusBits.IN_NETWORK, 0) + self.assertEqual(dispatcher.get_count(self.accounts[0], self.session_chainqueue), 0) if __name__ == '__main__': diff --git a/tests/test_filter.py b/tests/test_filter.py @@ -76,7 +76,8 @@ class TestFilter(TestBase): adapter = EthAdapter(backend) tx_raw_rlp_signed_bytes = bytes.fromhex(strip_0x(tx_raw_rlp_signed)) - adapter.add(tx_raw_rlp_signed_bytes, self.chain_spec, session=self.session_chainqueue) + #adapter.add(tx_raw_rlp_signed_bytes, self.chain_spec, session=self.session_chainqueue) + adapter.add(tx_raw_rlp_signed, self.chain_spec, session=self.session_chainqueue) set_ready(self.chain_spec, tx_hash, session=self.session_chainqueue) set_reserved(self.chain_spec, tx_hash, session=self.session_chainqueue)