Fixes some test cases in tendermint/test_lib.py

This commit is contained in:
Sangat Das 2022-06-09 01:41:42 -07:00
parent 36d9b41d0e
commit 4ca2c53cb7
2 changed files with 10 additions and 4 deletions

View File

@ -552,7 +552,7 @@ def tarantool_client(db_context): # TODO Here add TarantoolConnectionClass
# #
@pytest.fixture @pytest.fixture
def utxo_collection(tarantool_client): def utxo_collection(tarantool_client, _setup_database):
return tarantool_client.get_space("utxos") return tarantool_client.get_space("utxos")
@ -568,10 +568,12 @@ def dummy_unspent_outputs():
@pytest.fixture @pytest.fixture
def utxoset(dummy_unspent_outputs, utxo_collection): def utxoset(dummy_unspent_outputs, utxo_collection):
from json import dumps from json import dumps
num_rows_before_operation = utxo_collection.select().rowcount
for utxo in dummy_unspent_outputs: for utxo in dummy_unspent_outputs:
res = utxo_collection.insert((utxo["transaction_id"], utxo["output_index"], dumps(utxo))) res = utxo_collection.insert((utxo["transaction_id"], utxo["output_index"], dumps(utxo)))
assert res assert res
assert len(utxo_collection.select()) == 3 num_rows_after_operation = utxo_collection.select().rowcount
assert num_rows_after_operation == num_rows_before_operation + 3
return dummy_unspent_outputs, utxo_collection return dummy_unspent_outputs, utxo_collection

View File

@ -288,9 +288,11 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
@pytest.mark.bdb @pytest.mark.bdb
def test_delete_zero_unspent_outputs(b, utxoset): def test_delete_zero_unspent_outputs(b, utxoset):
unspent_outputs, utxo_collection = utxoset unspent_outputs, utxo_collection = utxoset
num_rows_before_operation = utxo_collection.select().rowcount
delete_res = b.delete_unspent_outputs() delete_res = b.delete_unspent_outputs()
num_rows_after_operation = utxo_collection.select().rowcount
# assert delete_res is None # assert delete_res is None
assert utxo_collection.select().rowcount == 3 assert num_rows_before_operation == num_rows_after_operation
# assert utxo_collection.count_documents( # assert utxo_collection.count_documents(
# {'$or': [ # {'$or': [
# {'transaction_id': 'a', 'output_index': 0}, # {'transaction_id': 'a', 'output_index': 0},
@ -350,9 +352,11 @@ def test_delete_many_unspent_outputs(b, utxoset):
@pytest.mark.bdb @pytest.mark.bdb
def test_store_zero_unspent_output(b, utxo_collection): def test_store_zero_unspent_output(b, utxo_collection):
num_rows_before_operation = utxo_collection.select().rowcount
res = b.store_unspent_outputs() res = b.store_unspent_outputs()
num_rows_after_operation = utxo_collection.select().rowcount
assert res is None assert res is None
assert utxo_collection.select().rowcount == 0 assert num_rows_before_operation == num_rows_after_operation
@pytest.mark.bdb @pytest.mark.bdb