From bb92b417e22e9e7b2983a8226bdcbdaea8fa5a03 Mon Sep 17 00:00:00 2001 From: nolash Date: Wed, 14 Jul 2021 23:45:23 +0200 Subject: [PATCH] Fix missing session passing for nonce reserve teste --- apps/cic-eth/cic_eth/pytest/fixtures_database.py | 2 +- apps/cic-eth/cic_eth/queue/query.py | 1 + apps/cic-eth/config/test/database.ini | 2 +- apps/cic-eth/tests/unit/db/test_nonce_db.py | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/cic-eth/cic_eth/pytest/fixtures_database.py b/apps/cic-eth/cic_eth/pytest/fixtures_database.py index d7fa81d8..539c6bf7 100644 --- a/apps/cic-eth/cic_eth/pytest/fixtures_database.py +++ b/apps/cic-eth/cic_eth/pytest/fixtures_database.py @@ -27,7 +27,7 @@ def database_engine( SessionBase.poolable = False dsn = dsn_from_config(load_config) #SessionBase.connect(dsn, True) - SessionBase.connect(dsn, debug=load_config.get('DATABASE_DEBUG') != None) + SessionBase.connect(dsn, debug=load_config.true('DATABASE_DEBUG')) return dsn diff --git a/apps/cic-eth/cic_eth/queue/query.py b/apps/cic-eth/cic_eth/queue/query.py index 9ce3a17f..c29bb430 100644 --- a/apps/cic-eth/cic_eth/queue/query.py +++ b/apps/cic-eth/cic_eth/queue/query.py @@ -100,6 +100,7 @@ def get_upcoming_tx(chain_spec, status=StatusEnum.READYSEND, not_status=None, re q_outer = q_outer.join(Lock, isouter=True) q_outer = q_outer.filter(or_(Lock.flags==None, Lock.flags.op('&')(LockEnum.SEND.value)==0)) + if not is_alive(status): SessionBase.release_session(session) raise ValueError('not a valid non-final tx value: {}'.format(status)) diff --git a/apps/cic-eth/config/test/database.ini b/apps/cic-eth/config/test/database.ini index 8c355ef3..34070210 100644 --- a/apps/cic-eth/config/test/database.ini +++ b/apps/cic-eth/config/test/database.ini @@ -6,4 +6,4 @@ HOST=localhost PORT=5432 ENGINE=sqlite DRIVER=pysqlite -DEBUG= +DEBUG=0 diff --git a/apps/cic-eth/tests/unit/db/test_nonce_db.py b/apps/cic-eth/tests/unit/db/test_nonce_db.py index 2b2dee6e..400cee16 100644 --- a/apps/cic-eth/tests/unit/db/test_nonce_db.py +++ b/apps/cic-eth/tests/unit/db/test_nonce_db.py @@ -1,6 +1,7 @@ -# third-party imports +# extended imports import pytest import uuid +import unittest # local imports from cic_eth.db.models.nonce import ( @@ -55,7 +56,7 @@ def test_nonce_reserve( o = q.first() assert o.nonce == 43 - nonce = NonceReservation.release(eth_empty_accounts[0], str(uu)) + nonce = NonceReservation.release(eth_empty_accounts[0], str(uu), session=init_database) init_database.commit() assert nonce == (str(uu), 42)