Skip to content

Commit

Permalink
Merge pull request #1656 from saratomaz/fix_test_tx_mempool_info
Browse files Browse the repository at this point in the history
fix test_tx_mempool_info
  • Loading branch information
mkoura committed Feb 10, 2023
2 parents c7f4259 + 9e5479c commit e8a1711
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions cardano_node_tests/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,15 @@ def test_pool_params(self, cluster: clusterlib.ClusterLib, pool_ids: List[str]):
@allure.link(helpers.get_vcs_link())
@pytest.mark.testnets
@pytest.mark.smoke
@pytest.mark.parametrize(
"with_out_file",
(True, False),
ids=("with_out_file", "without_out_file"),
)
def test_tx_mempool_info(
self,
cluster: clusterlib.ClusterLib,
with_out_file: bool,
):
"""Test 'query tx-mempool info'.
Expand All @@ -586,7 +592,15 @@ def test_tx_mempool_info(
common.get_test_id(cluster)

for __ in range(5):
tx_mempool = cluster.g_query.get_mempool_info()
if with_out_file:
out_file = "/dev/stdout"
cli_out = cluster.cli(
["query", "tx-mempool", "info", "--out-file", out_file, *cluster.magic_args]
)
tx_mempool = json.loads(cli_out.stdout.rstrip().decode("utf-8"))
else:
tx_mempool = cluster.g_query.get_mempool_info()

last_ledger_slot = cluster.g_query.get_slot_no()

if last_ledger_slot + 1 == tx_mempool["slot"]:
Expand All @@ -596,18 +610,7 @@ def test_tx_mempool_info(
f"Expected slot number '{last_ledger_slot + 1}', got '{tx_mempool['slot']}'"
)

out_file = "/dev/stdout"
cli_out = cluster.cli(
["query", "tx-mempool", "info", "--out-file", out_file, *cluster.magic_args]
)
tx_mempool_file = json.loads(cli_out.stdout.rstrip().decode("utf-8"))

assert {"capacityInBytes", "numberOfTxs", "sizeInBytes", "slot"}.issubset(
tx_mempool
) and tx_mempool == tx_mempool_file, (
"The output to file doesn't match the expected output:\n"
f"{tx_mempool_file}\nvs\n{tx_mempool}"
)
assert {"capacityInBytes", "numberOfTxs", "sizeInBytes", "slot"}.issubset(tx_mempool)

@allure.link(helpers.get_vcs_link())
@pytest.mark.testnets
Expand Down

0 comments on commit e8a1711

Please sign in to comment.