Skip to content

Commit

Permalink
[fix] #201: Add tests for transaction queries
Browse files Browse the repository at this point in the history
Signed-off-by: Sam H. Smith <[email protected]>
  • Loading branch information
SamHSmith committed Jun 5, 2024
1 parent c51e7e7 commit a679236
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl Client {
Ok(items)
}

fn query_all_transaction_by_hash(
fn query_transaction_by_hash(
&self,
tx_hash: [u8; Hash::LENGTH],
) -> PyResult<PyTransactionQueryOutput> {
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,13 @@ def GIVEN_registered_account_with_minted_assets(
5,
asset)]))
return GIVEN_registered_account


@pytest.fixture()
def GIVEN_hash_of_registered_transaction(GIVEN_new_domain_id):
"""Fixture to provide a registered transaction in Iroha"""
with allure.step(f'GIVEN registered domain name "{GIVEN_new_domain_id}"'):
tx_hash_string = client.submit_executable_only_success(
[iroha.Instruction
.register_domain(GIVEN_new_domain_id)])
return tx_hash_string
8 changes: 8 additions & 0 deletions tests/query/transactions/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import allure # type: ignore
import pytest

@pytest.fixture(scope="function", autouse=True)
def asset_test_setup():
allure.dynamic.feature("Transactions")
allure.dynamic.story("Account queries transactions")
allure.dynamic.label("permission", "no_permission_required")
31 changes: 31 additions & 0 deletions tests/query/transactions/test_query_transactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import allure
import iroha

from tests import client,account_id
from tests.helpers import generate_public_key


@allure.label("sdk_test_id", "query_all_transactions")
def test_query_all_transactions(GIVEN_hash_of_registered_transaction):
with allure.step('WHEN client queries all transactions'):
all_txs = client.query_all_transactions()
with allure.step('THEN there should be some transactions present'):
assert len(all_txs) > 0, "No transactions found in the system"


@allure.label("sdk_test_id", "query_all_transactions_by_account")
def test_query_all_transactions_by_account(
GIVEN_hash_of_registered_transaction):
with allure.step('WHEN client queries all transactions by their own account'):
all_txs = client.query_all_transactions_by_account(account_id)
with allure.step('THEN there should be some transactions present'):
assert len(all_txs) > 0, "No transactions found in the system"

@allure.label("sdk_test_id", "test_query_transaction_by_hash")
def test_query_transaction_by_hash(
GIVEN_hash_of_registered_transaction):
with allure.step(
f'WHEN client queries for transaction by hash {GIVEN_hash_of_registered_transaction}"'):
tx = client.query_transaction_by_hash(bytes.fromhex(GIVEN_hash_of_registered_transaction))
with allure.step('THEN there should be a transaction present'):
assert tx is not None, "No transactions found in the system"

0 comments on commit a679236

Please sign in to comment.