From f1f757b24764573d0420fb8750f2a3dd28787bd9 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 21 Oct 2024 17:13:02 +0200 Subject: [PATCH] fix(tests): handle CLI issue 942 in various tests - Added handling for CLI issue 942 in `TestRegisterAddr` and `TestDelegateAddr` classes. - Updated `script_dreps_lg` to use workaround for CLI issue 942. - Introduced `CLI_WITH_ISSUE_942` constant to manage version-specific behavior. - Ensured tests finish appropriately when encountering `ValueNotConservedUTxO` error. --- cardano_node_tests/tests/issues.py | 6 ++++++ .../tests/test_addr_registration.py | 7 ++++++- cardano_node_tests/tests/test_delegation.py | 8 +++++++- .../tests/tests_conway/test_constitution.py | 2 +- .../tests/tests_plutus/test_delegation.py | 15 +++++++++------ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/cardano_node_tests/tests/issues.py b/cardano_node_tests/tests/issues.py index dcb90c04e..ac15cc6a9 100644 --- a/cardano_node_tests/tests/issues.py +++ b/cardano_node_tests/tests/issues.py @@ -86,6 +86,12 @@ fixed_in="9.5.0.0", # Fixed in some release after 9.4.1.0 message="Negative pparam proposal values overflow to positive.", ) +cli_942 = blockers.GH( + issue=942, + repo="IntersectMBO/cardano-cli", + fixed_in="10.0.0.1", # Fixed in some release after 10.0.0.0 + message="build command doesn't balance key deposit.", +) consensus_973 = blockers.GH( issue=973, diff --git a/cardano_node_tests/tests/test_addr_registration.py b/cardano_node_tests/tests/test_addr_registration.py index 88972deb6..9a2b0ecb9 100644 --- a/cardano_node_tests/tests/test_addr_registration.py +++ b/cardano_node_tests/tests/test_addr_registration.py @@ -161,7 +161,12 @@ def _build_dereg() -> clusterlib.TxRawOutput: signing_key_files=tx_files_dereg.signing_key_files, tx_name=f"{temp_template}_dereg", ) - cluster.g_transaction.submit_tx(tx_file=tx_signed, txins=tx_raw_output_dereg.txins) + try: + cluster.g_transaction.submit_tx(tx_file=tx_signed, txins=tx_raw_output_dereg.txins) + except clusterlib.CLIError as exc: + if "ValueNotConservedUTxO" in str(exc): + issues.cli_942.finish_test() + raise else: tx_raw_output_dereg = cluster.g_transaction.send_tx( src_address=user_payment.address, diff --git a/cardano_node_tests/tests/test_delegation.py b/cardano_node_tests/tests/test_delegation.py index 5049676d3..53a41b323 100644 --- a/cardano_node_tests/tests/test_delegation.py +++ b/cardano_node_tests/tests/test_delegation.py @@ -11,6 +11,7 @@ from cardano_node_tests.cluster_management import resources_management from cardano_node_tests.tests import common from cardano_node_tests.tests import delegation +from cardano_node_tests.tests import issues from cardano_node_tests.utils import clusterlib_utils from cardano_node_tests.utils import dbsync_utils from cardano_node_tests.utils import helpers @@ -819,7 +820,12 @@ def _build_deleg_dereg() -> clusterlib.TxRawOutput: signing_key_files=tx_files.signing_key_files, tx_name=f"{temp_template}_deleg_dereg", ) - cluster.g_transaction.submit_tx(tx_file=tx_signed, txins=tx_raw_output_deleg.txins) + try: + cluster.g_transaction.submit_tx(tx_file=tx_signed, txins=tx_raw_output_deleg.txins) + except clusterlib.CLIError as exc: + if "ValueNotConservedUTxO" in str(exc): + issues.cli_942.finish_test() + raise else: tx_raw_output_deleg = cluster.g_transaction.send_tx( src_address=user_payment.address, diff --git a/cardano_node_tests/tests/tests_conway/test_constitution.py b/cardano_node_tests/tests/tests_conway/test_constitution.py index 87ce7d366..2498207e3 100644 --- a/cardano_node_tests/tests/tests_conway/test_constitution.py +++ b/cardano_node_tests/tests/tests_conway/test_constitution.py @@ -238,7 +238,7 @@ def _dereg_stake() -> None: cluster_obj=cluster, name_template=f"{temp_template}_dereg", src_address=pool_users[0].payment.address, - use_build_cmd=True, + use_build_cmd=False, # Workaround for CLI issue 942 tx_files=tx_files, withdrawals=withdrawals, deposit=-sum(s.delegation_deposit for __, s in pool_users_info), diff --git a/cardano_node_tests/tests/tests_plutus/test_delegation.py b/cardano_node_tests/tests/tests_plutus/test_delegation.py index dcdd87da7..c8d34be8c 100644 --- a/cardano_node_tests/tests/tests_plutus/test_delegation.py +++ b/cardano_node_tests/tests/tests_plutus/test_delegation.py @@ -13,6 +13,7 @@ import allure import pytest from cardano_clusterlib import clusterlib +from packaging import version from cardano_node_tests.cluster_management import cluster_management from cardano_node_tests.cluster_management import resources_management @@ -29,6 +30,8 @@ LOGGER = logging.getLogger(__name__) +CLI_WITH_ISSUE_942 = version.parse("10.0.0.0") + pytestmark = [ common.SKIPIF_PLUTUS_UNUSABLE, pytest.mark.plutus, @@ -630,7 +633,7 @@ def test_register_deregister( pool_user=pool_user, redeemer_file=plutus_common.REDEEMER_42, reference_script_utxos=reference_script_utxos, - use_build_cmd=use_build_cmd, + use_build_cmd=use_build_cmd and VERSIONS.cli != CLI_WITH_ISSUE_942, ) if reward_error: @@ -839,12 +842,12 @@ def test_delegate_deregister( # noqa: C901 pool_user=pool_user, redeemer_file=plutus_common.REDEEMER_42, reference_script_utxos=reference_script_utxos, - use_build_cmd=use_build_cmd, + use_build_cmd=use_build_cmd and VERSIONS.cli != CLI_WITH_ISSUE_942, ) except clusterlib.CLIError as exc: - if "(MissingRedeemers" not in str(exc): - raise - issues.cli_299.finish_test() + if "(MissingRedeemers" in str(exc): + issues.cli_299.finish_test() + raise if reward_error: raise AssertionError(reward_error) @@ -1069,7 +1072,7 @@ def test_register_delegate_deregister( pool_user=pool_user, redeemer_file=plutus_common.REDEEMER_42, reference_script_utxos=reference_script_utxos, - use_build_cmd=use_build_cmd, + use_build_cmd=use_build_cmd and VERSIONS.cli != CLI_WITH_ISSUE_942, ) if reward_error: