chainqueue

Blockchain transaction queue control
Log | Files | Refs | LICENSE

commit f41573d205a182833abe354ac77d75a5423e02c2
parent b177bc8aa6fd6564dd1b889b38cdd73841b00e7c
Author: nolash <dev@holbrook.no>
Date:   Tue,  6 Apr 2021 10:33:23 +0200

Add chain spec to method calls in tests

Diffstat:
Mchainqueue/db/migrations/default/versions/c537a0fd8466_outgoing_queue.py | 1+
Mchainqueue/db/models/otx.py | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
Mchainqueue/query.py | 6+++---
Mchainqueue/state.py | 12+++++-------
Msetup.cfg | 2+-
Mtests/test_otx.py | 76++++++++++++++++++++++++++++++++++++++--------------------------------------
Mtests/test_otx_status_log.py | 8++++----
Mtests/test_query.py | 4++--
Mtests/test_tx_cache.py | 8++++----
9 files changed, 124 insertions(+), 91 deletions(-)

diff --git a/chainqueue/db/migrations/default/versions/c537a0fd8466_outgoing_queue.py b/chainqueue/db/migrations/default/versions/c537a0fd8466_outgoing_queue.py @@ -21,6 +21,7 @@ def upgrade(): 'otx', sa.Column('id', sa.Integer, primary_key=True), sa.Column('date_created', sa.DateTime, nullable=False), + sa.Column('date_updated', sa.DateTime, nullable=False), sa.Column('nonce', sa.Integer, nullable=False), sa.Column('tx_hash', sa.Text, nullable=False), sa.Column('signed_tx', sa.Text, nullable=False), diff --git a/chainqueue/db/models/otx.py b/chainqueue/db/models/otx.py @@ -42,6 +42,7 @@ class Otx(SessionBase): nonce = Column(Integer) date_created = Column(DateTime, default=datetime.datetime.utcnow) + date_updated = Column(DateTime, default=datetime.datetime.utcnow) tx_hash = Column(String(66)) signed_tx = Column(Text) status = Column(Integer) @@ -50,6 +51,7 @@ class Otx(SessionBase): def __set_status(self, status, session): self.status |= status + self.date_updated = datetime.datetime.utcnow() session.add(self) session.flush() @@ -57,6 +59,7 @@ class Otx(SessionBase): def __reset_status(self, status, session): status_edit = ~status & self.status self.status &= status_edit + self.date_updated = datetime.datetime.utcnow() session.add(self) session.flush() @@ -90,6 +93,7 @@ class Otx(SessionBase): SessionBase.release_session(session) raise TxStateChangeError('Attempted set block {} when block was already {}'.format(block, self.block)) self.block = block + self.date_updated = datetime.datetime.utcnow() session.add(self) session.flush() @@ -109,11 +113,13 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('GAS_ISSUES cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('GAS_ISSUES cannot be set on an entry with FINAL state set ({})'.format(status)) if self.status & StatusBits.IN_NETWORK: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('GAS_ISSUES cannot be set on an entry with IN_NETWORK state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('GAS_ISSUES cannot be set on an entry with IN_NETWORK state set ({})'.format(status)) self.__set_status(StatusBits.GAS_ISSUES, session) self.__reset_status(StatusBits.QUEUED | StatusBits.DEFERRED, session) @@ -135,14 +141,17 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('FUBAR cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('FUBAR cannot be set on an entry with FINAL state set ({})'.format(status)) if is_error_status(self.status): + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('FUBAR cannot be set on an entry with an error state already set ({})'.format(status_str(self.status))) + raise TxStateChangeError('FUBAR cannot be set on an entry with an error state already set ({})'.format(status)) if not self.status & StatusBits.RESERVED: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('FUBAR on tx that has not been RESEREVED ({})'.format(status_str(self.status))) + raise TxStateChangeError('FUBAR on tx that has not been RESEREVED ({})'.format(status)) self.__set_status(StatusBits.UNKNOWN_ERROR | StatusBits.FINAL, session) @@ -164,17 +173,21 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('REJECTED cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('REJECTED cannot be set on an entry with FINAL state set ({})'.format(status)) if self.status & StatusBits.IN_NETWORK: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('REJECTED cannot be set on an entry already IN_NETWORK ({})'.format(status_str(self.status))) + raise TxStateChangeError('REJECTED cannot be set on an entry already IN_NETWORK ({})'.format(status)) if is_error_status(self.status): + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('REJECTED cannot be set on an entry with an error state already set ({})'.format(status_str(self.status))) + raise TxStateChangeError('REJECTED cannot be set on an entry with an error state already set ({})'.format(status)) if not self.status & StatusBits.RESERVED: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('REJECTED on tx that has not been RESEREVED ({})'.format(status_str(self.status))) + raise TxStateChangeError('REJECTED on tx that has not been RESEREVED ({})'.format(status)) @@ -195,14 +208,15 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry with FINAL state set ({})'.format(status)) if self.status & StatusBits.IN_NETWORK: SessionBase.release_session(session) - raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry already IN_NETWORK ({})'.format(status_str(self.status))) + raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry already IN_NETWORK ({})'.format(status)) if self.status & StatusBits.OBSOLETE: SessionBase.release_session(session) - raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry already OBSOLETE ({})'.format(status_str(self.status))) + raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry already OBSOLETE ({})'.format(status)) self.__set_status(StatusBits.OBSOLETE, session) #if manual: @@ -221,8 +235,9 @@ class Otx(SessionBase): if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('OVERRIDDEN/OBSOLETED cannot be set on an entry with FINAL state set ({})'.format(status)) self.__set_status(StatusBits.MANUAL, session) @@ -244,11 +259,13 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = status_str(self.status) SessionBase.release_session(session) - raise TxStateChangeError('RETRY cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('RETRY cannot be set on an entry with FINAL state set ({})'.format(status)) if not is_error_status(self.status) and not StatusBits.IN_NETWORK & self.status > 0: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('RETRY cannot be set on an entry that has no error ({})'.format(status_str(self.status))) + raise TxStateChangeError('RETRY cannot be set on an entry that has no error ({})'.format(status)) self.__set_status(StatusBits.QUEUED, session) self.__reset_status(StatusBits.GAS_ISSUES, session) @@ -272,11 +289,13 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('READYSEND cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('READYSEND cannot be set on an entry with FINAL state set ({})'.format(status)) if is_error_status(self.status): + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('READYSEND cannot be set on an errored state ({})'.format(status_str(self.status))) + raise TxStateChangeError('READYSEND cannot be set on an errored state ({})'.format(status)) self.__set_status(StatusBits.QUEUED, session) self.__reset_status(StatusBits.GAS_ISSUES, session) @@ -300,12 +319,14 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SENT cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SENT cannot be set on an entry with FINAL state set ({})'.format(status)) if not self.status & StatusBits.RESERVED: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SENT on tx that has not been RESEREVED ({})'.format(status_str(self.status))) + raise TxStateChangeError('SENT on tx that has not been RESEREVED ({})'.format(status)) self.__set_status(StatusBits.IN_NETWORK, session) self.__reset_status(StatusBits.RESERVED | StatusBits.DEFERRED | StatusBits.QUEUED | StatusBits.LOCAL_ERROR | StatusBits.NODE_ERROR, session) @@ -329,14 +350,17 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SENDFAIL cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SENDFAIL cannot be set on an entry with FINAL state set ({})'.format(status)) if self.status & StatusBits.IN_NETWORK: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SENDFAIL cannot be set on an entry with IN_NETWORK state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SENDFAIL cannot be set on an entry with IN_NETWORK state set ({})'.format(status)) if not self.status & StatusBits.RESERVED: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SENDFAIL on tx that has not been RESEREVED ({})'.format(status_str(self.status))) + raise TxStateChangeError('SENDFAIL on tx that has not been RESEREVED ({})'.format(status)) self.__set_status(StatusBits.LOCAL_ERROR | StatusBits.DEFERRED, session) self.__reset_status(StatusBits.RESERVED | StatusBits.QUEUED | StatusBits.GAS_ISSUES, session) @@ -360,14 +384,17 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.QUEUED == 0: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('RESERVED cannot be set on an entry without QUEUED state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('RESERVED cannot be set on an entry without QUEUED state set ({})'.format(status)) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('RESERVED cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('RESERVED cannot be set on an entry with FINAL state set ({})'.format(status)) if self.status & StatusBits.IN_NETWORK: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('RESERVED cannot be set on an entry with IN_NETWORK state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('RESERVED cannot be set on an entry with IN_NETWORK state set ({})'.format(status)) self.__reset_status(StatusBits.QUEUED, session) self.__set_status(StatusBits.RESERVED, session) @@ -394,11 +421,13 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('REVERTED cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('REVERTED cannot be set on an entry with FINAL state set ({})'.format(status)) if not self.status & StatusBits.IN_NETWORK: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('REVERTED cannot be set on an entry without IN_NETWORK state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('REVERTED cannot be set on an entry without IN_NETWORK state set ({})'.format(status)) if block != None: self.block = block @@ -425,13 +454,15 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('CANCEL cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('CANCEL cannot be set on an entry with FINAL state set ({})'.format(status)) if confirmed: + status = self.status if self.status > 0 and self.status & (StatusBits.OBSOLETE & StatusBits.IN_NETWORK) == 0: SessionBase.release_session(session) - raise TxStateChangeError('CANCEL can only be set on an entry marked OBSOLETE ({})'.format(status_str(self.status))) + raise TxStateChangeError('CANCEL can only be set on an entry marked OBSOLETE ({})'.format(status)) self.__set_status(StatusEnum.FINAL, session) self.__set_status(StatusEnum.OBSOLETED, session) @@ -456,14 +487,17 @@ class Otx(SessionBase): session = SessionBase.bind_session(session) if self.status & StatusBits.FINAL: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SUCCESS cannot be set on an entry with FINAL state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SUCCESS cannot be set on an entry with FINAL state set ({})'.format(status)) if not self.status & StatusBits.IN_NETWORK: + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SUCCESS cannot be set on an entry without IN_NETWORK state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SUCCESS cannot be set on an entry without IN_NETWORK state set ({})'.format(status)) if is_error_status(self.status): + status = self.status SessionBase.release_session(session) - raise TxStateChangeError('SUCCESS cannot be set on an entry with error state set ({})'.format(status_str(self.status))) + raise TxStateChangeError('SUCCESS cannot be set on an entry with error state set ({})'.format(status)) if block != None: self.block = block diff --git a/chainqueue/query.py b/chainqueue/query.py @@ -50,8 +50,6 @@ def get_tx_cache(chain_spec, tx_hash, session=None): q = q.filter(TxCache.otx_id==otx.id) txc = q.first() - SessionBase.release_session(session) - # TODO: DRY, get_tx_cache / get_tx tx = { 'tx_hash': add_0x(otx.tx_hash), @@ -72,6 +70,8 @@ def get_tx_cache(chain_spec, tx_hash, session=None): 'date_checked': txc.date_checked, } + SessionBase.release_session(session) + return tx @@ -195,7 +195,7 @@ def get_status_tx_cache(chain_spec, status, not_status=None, before=None, exact= q = session.query(Otx) q = q.join(TxCache) if before != None: - q = q.filter(TxCache.date_updated<before) + q = q.filter(Otx.date_updated<before) if exact: q = q.filter(Otx.status==status) else: diff --git a/chainqueue/state.py b/chainqueue/state.py @@ -54,14 +54,13 @@ def set_sent(chain_spec, tx_hash, fail=False, session=None): SessionBase.release_session(session) raise(e) - session.commit() SessionBase.release_session(session) return tx_hash -def set_final(chain_spec, tx_hash, block=None, fail=False, session=None): +def set_final(chain_spec, tx_hash, block=None, tx_index=None, fail=False, session=None): """Used to set the status of an incoming transaction result. :param tx_hash: Transaction hash of record to modify @@ -86,7 +85,6 @@ def set_final(chain_spec, tx_hash, block=None, fail=False, session=None): o.minefail(block, session=session) else: o.success(block, session=session) - session.commit() except TxStateChangeError as e: logg.exception('set final fail: {}'.format(e)) SessionBase.release_session(session) @@ -96,10 +94,10 @@ def set_final(chain_spec, tx_hash, block=None, fail=False, session=None): SessionBase.release_session(session) raise(e) - q = session.query(TxCache) - q = q.join(Otx) - q = q.filter(Otx.tx_hash==strip_0x(tx_hash)) - o = q.first() + if block != None: + TxCache.set_final(o.tx_hash, block, tx_index, session=session) + + session.commit() SessionBase.release_session(session) diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainqueue -version = 0.0.1a5 +version = 0.0.1a6 description = Generic blockchain transaction queue control author = Louis Holbrook author_email = dev@holbrook.no diff --git a/tests/test_otx.py b/tests/test_otx.py @@ -24,93 +24,93 @@ logg = logging.getLogger() class TestOtx(TestOtxBase): def test_ideal_state_sequence(self): - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status, StatusBits.QUEUED) - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status, StatusBits.RESERVED) - set_sent(self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status, StatusBits.IN_NETWORK) - set_final(self.tx_hash, block=1024) + set_final(self.chain_spec, self.tx_hash, block=1024) self.session.refresh(otx) self.assertFalse(is_alive(otx.status)) self.assertFalse(is_error_status(otx.status)) def test_send_fail_and_retry(self): - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status, StatusBits.QUEUED) - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status, StatusBits.RESERVED) - set_sent(self.tx_hash, fail=True) + set_sent(self.chain_spec, self.tx_hash, fail=True) self.session.refresh(otx) self.assertTrue(is_error_status(otx.status)) - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.QUEUED, StatusBits.QUEUED) self.assertTrue(is_error_status(otx.status)) - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.RESERVED, StatusBits.RESERVED) self.assertTrue(is_error_status(otx.status)) - set_sent(self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status, StatusBits.IN_NETWORK) self.assertFalse(is_error_status(otx.status)) - set_final(self.tx_hash, block=1024) + set_final(self.chain_spec, self.tx_hash, block=1024) self.session.refresh(otx) self.assertFalse(is_alive(otx.status)) self.assertFalse(is_error_status(otx.status)) def test_fubar(self): - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status, StatusBits.QUEUED) - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.RESERVED, StatusBits.RESERVED) - set_fubar(self.tx_hash) + set_fubar(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertTrue(is_error_status(otx.status)) self.assertEqual(otx.status & StatusBits.UNKNOWN_ERROR, StatusBits.UNKNOWN_ERROR) def test_reject(self): - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status, StatusBits.QUEUED) - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.RESERVED, StatusBits.RESERVED) - set_rejected(self.tx_hash) + set_rejected(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertTrue(is_error_status(otx.status)) self.assertEqual(otx.status & StatusBits.NODE_ERROR, StatusBits.NODE_ERROR) def test_final_fail(self): - set_ready(self.tx_hash) - set_reserved(self.tx_hash) - set_sent(self.tx_hash) - set_final(self.tx_hash, block=1042, fail=True) + set_ready(self.chain_spec, self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) + set_final(self.chain_spec, self.tx_hash, block=1042, fail=True) otx = Otx.load(self.tx_hash, session=self.session) self.assertFalse(is_alive(otx.status)) self.assertTrue(is_error_status(otx.status)) @@ -118,47 +118,47 @@ class TestOtx(TestOtxBase): def test_final_protected(self): - set_ready(self.tx_hash) - set_reserved(self.tx_hash) - set_sent(self.tx_hash) - set_final(self.tx_hash, block=1042) + set_ready(self.chain_spec, self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) + set_final(self.chain_spec, self.tx_hash, block=1042) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status & StatusBits.FINAL, StatusBits.FINAL) with self.assertRaises(TxStateChangeError): - set_ready(self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) with self.assertRaises(TxStateChangeError): - set_fubar(self.tx_hash) + set_fubar(self.chain_spec, self.tx_hash) with self.assertRaises(TxStateChangeError): - set_rejected(self.tx_hash) + set_rejected(self.chain_spec, self.tx_hash) - set_cancel(self.tx_hash) + set_cancel(self.chain_spec, self.tx_hash) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.OBSOLETE, 0) - set_cancel(self.tx_hash, manual=True) + set_cancel(self.chain_spec, self.tx_hash, manual=True) self.session.refresh(otx) self.assertEqual(otx.status & StatusBits.OBSOLETE, 0) with self.assertRaises(TxStateChangeError): - set_reserved(self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) with self.assertRaises(TxStateChangeError): - set_waitforgas(self.tx_hash) + set_waitforgas(self.chain_spec, self.tx_hash) with self.assertRaises(TxStateChangeError): - set_manual(self.tx_hash) + set_manual(self.chain_spec, self.tx_hash) def test_manual_persist(self): - set_manual(self.tx_hash) - set_ready(self.tx_hash) - set_reserved(self.tx_hash) - set_sent(self.tx_hash) - set_final(self.tx_hash, block=1042) + set_manual(self.chain_spec, self.tx_hash) + set_ready(self.chain_spec, self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) + set_final(self.chain_spec, self.tx_hash, block=1042) otx = Otx.load(self.tx_hash, session=self.session) self.assertEqual(otx.status & StatusBits.MANUAL, StatusBits.MANUAL) diff --git a/tests/test_otx_status_log.py b/tests/test_otx_status_log.py @@ -19,10 +19,10 @@ class TestOtxState(TestOtxBase): def test_state_log(self): - set_ready(self.tx_hash) - set_reserved(self.tx_hash) - set_sent(self.tx_hash) - set_final(self.tx_hash, block=1042) + set_ready(self.chain_spec, self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) + set_final(self.chain_spec, self.tx_hash, block=1042) state_log = get_state_log(self.chain_spec, self.tx_hash) self.assertEqual(state_log[0][1], StatusEnum.READYSEND) diff --git a/tests/test_query.py b/tests/test_query.py @@ -93,7 +93,7 @@ class TestTxQuery(TestTxBase): def test_paused_tx_cache(self): - set_waitforgas(self.tx_hash) + set_waitforgas(self.chain_spec, self.tx_hash) tx_hash = add_0x(os.urandom(32).hex()) signed_tx = add_0x(os.urandom(128).hex()) @@ -150,7 +150,7 @@ class TestTxQuery(TestTxBase): txs = get_paused_tx_cache(self.chain_spec, status=StatusBits.GAS_ISSUES, session=self.session) self.assertEqual(len(txs.keys()), 1) - set_waitforgas(tx_hash) + set_waitforgas(self.chain_spec, tx_hash) self.session.commit() txs = get_paused_tx_cache(self.chain_spec, status=StatusBits.GAS_ISSUES, session=self.session) diff --git a/tests/test_tx_cache.py b/tests/test_tx_cache.py @@ -16,10 +16,10 @@ class TestTxCache(TestTxBase): with self.assertRaises(NotLocalTxError): TxCache.set_final(self.tx_hash, 1024, 13, session=self.session) - set_ready(self.tx_hash) - set_reserved(self.tx_hash) - set_sent(self.tx_hash) - set_final(self.tx_hash, block=1024) + set_ready(self.chain_spec, self.tx_hash) + set_reserved(self.chain_spec, self.tx_hash) + set_sent(self.chain_spec, self.tx_hash) + set_final(self.chain_spec, self.tx_hash, block=1024) with self.assertRaises(NotLocalTxError): TxCache.set_final(self.tx_hash, 1023, 13, session=self.session)