planetmint/tests/test_txlist.py
Jürgen Eckel 0b0c954d34
331 refactor a certain module gets a specific driver type flask sync driver abci server async driver first we stick to the current tarantool driver (#337)
* created ABCI_RPC class to seperate RPC interaction from the other ABCI interactions
* renamed validation.py to validator.py
* simplified planetmint/__init__.py
* moved methods used by testing to tests/utils.py
* making planetmint/__init__.py lean
* moved ProcessGroup object to tests as it is only used there
* reintegrated disabled tests


Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-02-27 16:48:31 +01:00

48 lines
1.5 KiB
Python

# Copyright © 2020 Interplanetary Database Association e.V.,
# Planetmint and IPDB software contributors.
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0
"""Test getting a list of transactions from the backend.
This test module defines it's own fixture which is used by all the tests.
"""
import pytest
@pytest.fixture
def txlist(b, user_pk, user2_pk, user_sk, user2_sk):
from transactions.types.assets.create import Create
from transactions.types.assets.transfer import Transfer
# Create two CREATE transactions
create1 = Create.generate([user_pk], [([user2_pk], 6)]).sign([user_sk])
create2 = Create.generate([user2_pk], [([user2_pk], 5), ([user_pk], 5)]).sign([user2_sk])
# Create a TRANSFER transactions
transfer1 = Transfer.generate(create1.to_inputs(), [([user_pk], 8)], [create1.id]).sign([user2_sk])
b.models.store_bulk_transactions([create1, create2, transfer1])
return type(
"",
(),
{
"create1": create1,
"transfer1": transfer1,
},
)
@pytest.mark.bdb
def test_get_txlist_by_asset(b, txlist):
res = b.models.get_transactions_filtered([txlist.create1.id])
assert sorted(set(tx.id for tx in res)) == sorted(set([txlist.transfer1.id, txlist.create1.id]))
@pytest.mark.bdb
def test_get_txlist_by_operation(b, txlist):
res = b.models.get_transactions_filtered([txlist.create1.id], operation="CREATE")
assert set(tx.id for tx in res) == {txlist.create1.id}