From 8954656a9ec4ca2ccdbe986ca2e895bfa7023c1f Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Tue, 13 Jan 2026 12:14:28 +0100 Subject: [PATCH 1/2] feat(ci): add option to allow unstable error messages Removes the unused 'topology' input from regression workflows and scripts. Introduces a new 'allow_unstable_error_msgs' boolean input to control whether unstable error messages are allowed in tests. Updates environment variable handling and Python configuration to support this option. --- .github/regression.sh | 11 ++++------- .github/workflows/regression-dbsync.yaml | 14 +++++--------- .github/workflows/regression.yaml | 14 +++++--------- .github/workflows/regression_reusable.yaml | 15 +++++---------- cardano_node_tests/utils/configuration.py | 3 +++ 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/.github/regression.sh b/.github/regression.sh index 2e7405de1..4394e7c25 100755 --- a/.github/regression.sh +++ b/.github/regression.sh @@ -34,13 +34,6 @@ mkdir -p "$WORKDIR" export TMPDIR="$WORKDIR/tmp" mkdir -p "$TMPDIR" -if [ "${CI_TOPOLOGY:-}" = "legacy" ]; then - export ENABLE_LEGACY=1 -elif [ "${CI_TOPOLOGY:-}" = "mixed" ]; then - export MIXED_P2P=1 - export NUM_POOLS="${NUM_POOLS:-4}" -fi - export ARTIFACTS_DIR="${ARTIFACTS_DIR:-".artifacts"}" rm -rf "${ARTIFACTS_DIR:?}" @@ -93,6 +86,10 @@ else export TESTNET_VARIANT="${TESTNET_VARIANT:-"${CLUSTER_ERA}_fast"}" fi +if [ "${ALLOW_UNSTABLE_ERROR_MESSAGES:-"false"}" == "false" ]; then + unset ALLOW_UNSTABLE_ERROR_MESSAGES +fi + export CARDANO_NODE_SOCKET_PATH_CI="$WORKDIR/state-cluster0/bft1.socket" # assume we run tests on testnet when `BOOTSTRAP_DIR` is set diff --git a/.github/workflows/regression-dbsync.yaml b/.github/workflows/regression-dbsync.yaml index 0c9eeeaf9..4982ae249 100644 --- a/.github/workflows/regression-dbsync.yaml +++ b/.github/workflows/regression-dbsync.yaml @@ -36,14 +36,6 @@ on: - dbsync and plutus - dbsync and not long default: dbsync - topology: - type: choice - description: "Network topology" - options: - - p2p - - legacy - - mixed - default: p2p utxo_backend: type: choice description: "UTxO backend" @@ -53,6 +45,10 @@ on: - disk - disklmdb default: "" + allow_unstable_error_msgs: + type: boolean + default: false + description: "Allow unstable error messages" byron_cluster: type: boolean default: false @@ -77,8 +73,8 @@ jobs: dbsync_rev: ${{ inputs.dbsync_rev }} cluster_era: ${{ inputs.cluster_era }} markexpr: ${{ inputs.markexpr }} - topology: ${{ inputs.topology }} utxo_backend: ${{ inputs.utxo_backend }} + allow_unstable_error_msgs: ${{ inputs.allow_unstable_error_msgs }} byron_cluster: ${{ inputs.byron_cluster }} testrun_name: ${{ inputs.testrun_name }} skip_passed: ${{ inputs.skip_passed }} diff --git a/.github/workflows/regression.yaml b/.github/workflows/regression.yaml index 7b4e5292a..5195a2b71 100644 --- a/.github/workflows/regression.yaml +++ b/.github/workflows/regression.yaml @@ -28,14 +28,6 @@ on: - not long - conway only default: all - topology: - type: choice - description: "Network topology" - options: - - p2p - - legacy - - mixed - default: p2p utxo_backend: type: choice description: "UTxO backend" @@ -45,6 +37,10 @@ on: - disk - disklmdb default: "" + allow_unstable_error_msgs: + type: boolean + default: false + description: "Allow unstable error messages" byron_cluster: type: boolean default: false @@ -68,8 +64,8 @@ jobs: cli_rev: ${{ inputs.cli_rev }} cluster_era: ${{ inputs.cluster_era }} markexpr: ${{ inputs.markexpr }} - topology: ${{ inputs.topology }} utxo_backend: ${{ inputs.utxo_backend }} + allow_unstable_error_msgs: ${{ inputs.allow_unstable_error_msgs }} byron_cluster: ${{ inputs.byron_cluster }} testrun_name: ${{ inputs.testrun_name }} skip_passed: ${{ inputs.skip_passed }} diff --git a/.github/workflows/regression_reusable.yaml b/.github/workflows/regression_reusable.yaml index 9e56cb862..aa5e2b518 100644 --- a/.github/workflows/regression_reusable.yaml +++ b/.github/workflows/regression_reusable.yaml @@ -23,22 +23,18 @@ on: required: false type: string default: "" - tx_era: - required: false - type: string - default: "" markexpr: required: false type: string default: "" - topology: - required: false - type: string - default: "" utxo_backend: required: false type: string default: "" + allow_unstable_error_msgs: + required: false + type: boolean + default: false byron_cluster: required: false type: boolean @@ -92,10 +88,9 @@ jobs: echo "CARDANO_CLI_REV=${{ inputs.cli_rev }}" >> .github_ci_env echo "DBSYNC_REV=${{ inputs.dbsync_rev }}" >> .github_ci_env echo "CLUSTER_ERA=${{ inputs.cluster_era }}" >> .github_ci_env - echo "TX_ERA=${{ inputs.tx_era }}" >> .github_ci_env echo "MARKEXPR=${{ inputs.markexpr }}" >> .github_ci_env - echo "CI_TOPOLOGY=${{ inputs.topology }}" >> .github_ci_env echo "UTXO_BACKEND=${{ inputs.utxo_backend }}" >> .github_ci_env + echo "ALLOW_UNSTABLE_ERROR_MESSAGES=${{ inputs.allow_unstable_error_msgs }}" >> .github_ci_env echo "CI_BYRON_CLUSTER=${{ inputs.byron_cluster }}" >> .github_ci_env echo "CI_TESTRUN_NAME=${{ inputs.testrun_name }}" >> .github_ci_env echo "CI_SKIP_PASSED=${{ inputs.skip_passed }}" >> .github_ci_env diff --git a/cardano_node_tests/utils/configuration.py b/cardano_node_tests/utils/configuration.py index d05df7602..3cfbdd922 100644 --- a/cardano_node_tests/utils/configuration.py +++ b/cardano_node_tests/utils/configuration.py @@ -80,6 +80,9 @@ DONT_OVERWRITE_OUTFILES = bool(os.environ.get("DONT_OVERWRITE_OUTFILES")) +# Allow unstable error messages in tests +ALLOW_UNSTABLE_ERROR_MESSAGES = bool(os.environ.get("ALLOW_UNSTABLE_ERROR_MESSAGES")) + # Cluster instances are kept running after tests finish KEEP_CLUSTERS_RUNNING = bool(os.environ.get("KEEP_CLUSTERS_RUNNING")) From 587e64067e4fc72ed78da48bf680aea6ff885c4f Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Tue, 13 Jan 2026 12:15:32 +0100 Subject: [PATCH 2/2] refactor(tests): centralize unstable error handling Introduce `allow_unstable_error_messages` context manager in `common.py` to handle assertion errors for unstable error messages across different node/CLI versions. Refactor all test files to use this context manager, replacing direct assertions on error messages. This allows for temporarily ignoring specific error message checks when testing new features. --- cardano_node_tests/tests/common.py | 17 ++ .../tests/test_addr_registration.py | 25 ++- cardano_node_tests/tests/test_blocks.py | 7 +- cardano_node_tests/tests/test_cli.py | 92 ++++---- cardano_node_tests/tests/test_delegation.py | 69 +++--- cardano_node_tests/tests/test_kes.py | 5 +- cardano_node_tests/tests/test_mir_certs.py | 5 +- cardano_node_tests/tests/test_mnemonic.py | 23 +- .../tests/test_native_tokens.py | 121 ++++++---- cardano_node_tests/tests/test_pools.py | 111 ++++++---- cardano_node_tests/tests/test_scripts.py | 90 ++++---- cardano_node_tests/tests/test_tx_basic.py | 5 +- cardano_node_tests/tests/test_tx_fees.py | 8 +- cardano_node_tests/tests/test_tx_metadata.py | 54 +++-- cardano_node_tests/tests/test_tx_negative.py | 208 +++++++++++------- .../tests/test_tx_unbalanced.py | 76 ++++--- .../tests/tests_conway/test_committee.py | 60 ++--- .../tests/tests_conway/test_constitution.py | 20 +- .../tests/tests_conway/test_conway.py | 20 +- .../tests/tests_conway/test_drep.py | 17 +- .../tests/tests_conway/test_hardfork.py | 10 +- .../tests/tests_conway/test_no_confidence.py | 15 +- .../tests/tests_conway/test_pparam_update.py | 33 +-- .../tests_conway/test_treasury_withdrawals.py | 38 ++-- .../tests/tests_plutus/spend_raw.py | 3 +- .../tests_plutus/test_mint_negative_build.py | 56 ++--- .../tests_plutus/test_mint_negative_raw.py | 43 ++-- .../tests_plutus/test_spend_compat_build.py | 5 +- .../tests_plutus/test_spend_compat_raw.py | 12 +- .../tests_plutus/test_spend_datum_build.py | 33 +-- .../tests_plutus/test_spend_datum_raw.py | 34 +-- .../tests_plutus/test_spend_negative_build.py | 204 ++++++++--------- .../tests_plutus/test_spend_negative_raw.py | 69 +++--- .../tests/tests_plutus/test_spend_raw.py | 8 +- .../tests/tests_plutus_v2/mint_raw.py | 8 +- .../tests/tests_plutus_v2/test_mint_build.py | 17 +- .../test_mint_negative_build.py | 5 +- .../tests_plutus_v2/test_mint_negative_raw.py | 10 +- .../tests/tests_plutus_v2/test_mint_raw.py | 8 +- .../test_mint_secp256k1_build.py | 12 +- .../test_mint_secp256k1_raw.py | 13 +- .../test_spend_compat_build.py | 5 +- .../tests_plutus_v2/test_spend_compat_raw.py | 5 +- .../tests_plutus_v2/test_spend_datum_build.py | 21 +- .../tests_plutus_v2/test_spend_datum_raw.py | 21 +- .../test_spend_ref_inputs_build.py | 29 +-- .../test_spend_ref_inputs_raw.py | 17 +- .../test_spend_ref_scripts_build.py | 43 ++-- .../test_spend_ref_scripts_raw.py | 40 ++-- .../test_spend_secp256k1_build.py | 8 +- 50 files changed, 1064 insertions(+), 794 deletions(-) diff --git a/cardano_node_tests/tests/common.py b/cardano_node_tests/tests/common.py index e11c2c1d8..71b698437 100644 --- a/cardano_node_tests/tests/common.py +++ b/cardano_node_tests/tests/common.py @@ -1,3 +1,4 @@ +import contextlib import logging import string import time @@ -603,3 +604,19 @@ def is_fee_in_interval(fee: float, expected_fee: float, frac: float = 0.1) -> bo if cluster_nodes.get_cluster_type().type == cluster_nodes.ClusterType.TESTNET: return True return helpers.is_in_interval(fee, expected_fee, frac=frac) + + +@contextlib.contextmanager +def allow_unstable_error_messages() -> tp.Iterator[None]: + """Catch AssertionError and either log it or raise it. + + Used in tests where error messages can vary between node/CLI versions. + """ + if not configuration.ALLOW_UNSTABLE_ERROR_MESSAGES: + yield + return + + try: + yield + except AssertionError: + LOGGER.exception("AssertionError suppressed") diff --git a/cardano_node_tests/tests/test_addr_registration.py b/cardano_node_tests/tests/test_addr_registration.py index 7a48bf7ca..da4e863e1 100644 --- a/cardano_node_tests/tests/test_addr_registration.py +++ b/cardano_node_tests/tests/test_addr_registration.py @@ -536,8 +536,9 @@ def test_registration_cert_with_wrong_key( deposit_amt=common.get_conway_address_deposit(cluster_obj=cluster), stake_vkey_file=pool_users[0].payment.vkey_file, ) - err_msg = str(excinfo.value) - assert "Expected: StakeVerificationKeyShelley" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Expected: StakeVerificationKeyShelley" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -574,8 +575,9 @@ def test_register_addr_with_wrong_key( cluster.g_transaction.send_tx( src_address=user_payment.address, tx_name=temp_template, tx_files=tx_files ) - err_msg = str(excinfo.value) - assert "MissingVKeyWitnessesUTXOW" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD_NO_EST @@ -638,8 +640,9 @@ def _build_dereg() -> clusterlib.TxRawOutput: witness_count_add=len(tx_files.signing_key_files), ) - err_msg = str(excinfo.value) - assert "StakeKeyNotRegisteredDELEG" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakeKeyNotRegisteredDELEG" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD_NO_EST @@ -768,8 +771,9 @@ def _submit_tx( tx_files=tx_files_script, signing_key_files=signing_key_files, ) - err_msg = str(excinfo.value) - assert "MissingScriptWitnessesUTXOW" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingScriptWitnessesUTXOW" in exc_value, exc_value # Scenario2: One skey is missing when witnesing the Tx elif issue == "missing_skey": @@ -783,8 +787,9 @@ def _submit_tx( complex_certs=[reg_cert_script], signing_key_files=signing_key_files[:-1], ) - err_msg = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value else: err = f"Invalid issue: {issue}" diff --git a/cardano_node_tests/tests/test_blocks.py b/cardano_node_tests/tests/test_blocks.py index aa800363d..7be0e2670 100644 --- a/cardano_node_tests/tests/test_blocks.py +++ b/cardano_node_tests/tests/test_blocks.py @@ -233,12 +233,13 @@ def test_unstable_stake_distribution( cold_vkey_file=pool_rec["cold_key_pair"].vkey_file, for_next=True, ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) - if "PastHorizon" in err_str: + if "PastHorizon" in exc_value: issues.node_4002.finish_test() - assert "current stake distribution is currently unstable" in err_str, err_str + with common.allow_unstable_error_messages(): + assert "current stake distribution is currently unstable" in exc_value, exc_value @pytest.mark.skipif( diff --git a/cardano_node_tests/tests/test_cli.py b/cardano_node_tests/tests/test_cli.py index 19c444f24..3798d5842 100644 --- a/cardano_node_tests/tests/test_cli.py +++ b/cardano_node_tests/tests/test_cli.py @@ -404,10 +404,9 @@ def test_address_info_with_invalid_address(self, cluster: clusterlib.ClusterLib, with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_address.get_address_info(address=address) - - err_str = str(excinfo.value) - - assert "Invalid address" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid address" in exc_value, exc_value class TestAddressBuild: @@ -535,10 +534,9 @@ def test_invalid_payment_info( payment_vkey_file=vkey_file, payment_script_file=script_file, ) - - err_str = str(excinfo.value) - - assert "Invalid key" in err_str or "Syntax error in script" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid key" in exc_value or "Syntax error in script" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize( @@ -597,14 +595,13 @@ def test_invalid_stake_info( stake_script_file=script_file, stake_address=key if option == "address" else None, ) - - err_str = str(excinfo.value) - - assert ( - "Invalid key" in err_str - or "Syntax error in script" in err_str - or "invalid address" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Invalid key" in exc_value + or "Syntax error in script" in exc_value + or "invalid address" in exc_value + ), exc_value class TestAddressKeyHash: @@ -665,10 +662,9 @@ def test_invalid_verification_key(self, cluster: clusterlib.ClusterLib, option: payment_vkey=vkey if option == "vkey" else None, payment_vkey_file=vkey_file, ) - - err_str = str(excinfo.value) - - assert "Invalid key" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid key" in exc_value, exc_value class TestKey: @@ -737,12 +733,12 @@ def test_non_extended_key_error(self, cluster: clusterlib.ClusterLib): cluster.g_key.gen_non_extended_verification_key( key_name=temp_template, extended_verification_key_file=payment_keys.skey_file ) - - err_str = str(excinfo.value) - assert ( - "Error: Invalid key." in err_str - or "TextEnvelope type error: Expected one of:" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Error: Invalid key." in exc_value + or "TextEnvelope type error: Expected one of:" in exc_value + ), exc_value class TestQueryUTxO: @@ -873,16 +869,15 @@ def test_tx_in_invalid_data( *cluster.magic_args, ] ) - - err_str = str(excinfo.value) - - if invalid_param == "tx_hash": - assert ( - "expecting hexadecimal digit" in err_str - or "expecting transaction id (hexadecimal)" in err_str - ), err_str - else: - assert "expecting digit" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + if invalid_param == "tx_hash": + assert ( + "expecting hexadecimal digit" in exc_value + or "expecting transaction id (hexadecimal)" in exc_value + ), exc_value + else: + assert "expecting digit" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(filter_str=st.text(alphabet=common.ADDR_ALPHABET, min_size=1)) @@ -905,9 +900,9 @@ def test_address_invalid_data(self, cluster: clusterlib.ClusterLib, filter_str: *cluster.magic_args, ] ) - - err_str = str(excinfo.value) - assert "invalid address" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "invalid address" in exc_value, exc_value class TestStakeAddressKeyHash: @@ -968,10 +963,9 @@ def test_invalid_verification_key(self, cluster: clusterlib.ClusterLib, option: stake_vkey=vkey if option == "vkey" else None, stake_vkey_file=vkey_file, ) - - err_str = str(excinfo.value) - - assert "Invalid key" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid key" in exc_value, exc_value class TestAdvancedQueries: @@ -1427,9 +1421,9 @@ def test_slot_number_invalid_format( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_query.query_cli(["slot-number", timestamp_str]) - err_str = str(excinfo.value) - - assert "parseTimeOrError" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "parseTimeOrError" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("time_val", ("above", "bellow")) @@ -1451,6 +1445,6 @@ def test_slot_number_out_of_range( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_query.get_slot_number(timestamp=timestamp) - err_str = str(excinfo.value) - - assert "PastHorizon" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "PastHorizon" in exc_value, exc_value diff --git a/cardano_node_tests/tests/test_delegation.py b/cardano_node_tests/tests/test_delegation.py index f4cc27aed..1823ef446 100644 --- a/cardano_node_tests/tests/test_delegation.py +++ b/cardano_node_tests/tests/test_delegation.py @@ -493,11 +493,12 @@ def test_deregister_delegated( tx_name=f"{temp_template}_dereg_fail", tx_files=tx_files_deregister, ) - err_msg = str(excinfo.value) - assert ( - "StakeKeyNonZeroAccountBalanceDELEG" in err_msg - or "StakeKeyHasNonZeroRewardAccountBalanceDELEG" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "StakeKeyNonZeroAccountBalanceDELEG" in exc_value + or "StakeKeyHasNonZeroRewardAccountBalanceDELEG" in exc_value + ), exc_value src_payment_balance = cluster.g_query.get_address_balance(src_address) reward_balance = cluster.g_query.get_stake_addr_info( @@ -664,11 +665,12 @@ def test_delegate_multisig( tx_files=tx_files_deregister, complex_certs=[dereg_cert_script], ) - err_msg = str(excinfo.value) - assert ( - "StakeKeyNonZeroAccountBalanceDELEG" in err_msg - or "StakeKeyHasNonZeroRewardAccountBalanceDELEG" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "StakeKeyNonZeroAccountBalanceDELEG" in exc_value + or "StakeKeyHasNonZeroRewardAccountBalanceDELEG" in exc_value + ), exc_value src_payment_balance = cluster.g_query.get_address_balance(src_address) reward_balance = cluster.g_query.get_stake_addr_info( @@ -1020,11 +1022,12 @@ def test_delegation_cert_with_wrong_key( stake_pool_id=pool_id, always_abstain=True, ) - err_msg = str(excinfo.value) - assert ( - "Expected: StakeVerificationKeyShelley" in err_msg - or "MissingVKeyWitnessesUTXOW" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Expected: StakeVerificationKeyShelley" in exc_value + or "MissingVKeyWitnessesUTXOW" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1073,8 +1076,9 @@ def test_delegate_addr_with_wrong_key( tx_name=f"{temp_template}_deleg", tx_files=tx_files, ) - err_msg = str(excinfo.value) - assert "MissingVKeyWitnessesUTXOW" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD_NO_EST @@ -1121,10 +1125,12 @@ def test_delegate_unknown_addr( witness_override=len(tx_files.signing_key_files), ) - err_msg = str(excinfo.value) - assert ( - "StakeDelegationImpossibleDELEG" in err_msg or "StakeKeyNotRegisteredDELEG" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "StakeDelegationImpossibleDELEG" in exc_value + or "StakeKeyNotRegisteredDELEG" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD_NO_EST @@ -1190,10 +1196,12 @@ def test_delegate_deregistered_addr( witness_override=len(tx_files.signing_key_files), ) - err_msg = str(excinfo.value) - assert ( - "StakeDelegationImpossibleDELEG" in err_msg or "StakeKeyNotRegisteredDELEG" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "StakeDelegationImpossibleDELEG" in exc_value + or "StakeKeyNotRegisteredDELEG" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1244,8 +1252,9 @@ def test_delegatee_not_registered( tx_name=f"{temp_template}_deleg", tx_files=tx_files, ) - err_msg = str(excinfo.value) - assert ( - "DelegateeNotRegisteredDELEG" in err_msg # Before cardano-node 10.0.0 - or "DelegateeStakePoolNotRegisteredDELEG" in err_msg - ), err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "DelegateeNotRegisteredDELEG" in exc_value # Before cardano-node 10.0.0 + or "DelegateeStakePoolNotRegisteredDELEG" in exc_value + ), exc_value diff --git a/cardano_node_tests/tests/test_kes.py b/cardano_node_tests/tests/test_kes.py index 63b8e835e..c9bb76c34 100644 --- a/cardano_node_tests/tests/test_kes.py +++ b/cardano_node_tests/tests/test_kes.py @@ -805,7 +805,10 @@ def test_no_kes_period_arg( str(out_file), ] ) - assert "Missing: --kes-period NATURAL" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Missing: --kes-period NATURAL" in exc_value, exc_value + assert not out_file.exists(), "New operational certificate was generated" @allure.link(helpers.get_vcs_link()) diff --git a/cardano_node_tests/tests/test_mir_certs.py b/cardano_node_tests/tests/test_mir_certs.py index 28827786a..6baea94f0 100644 --- a/cardano_node_tests/tests/test_mir_certs.py +++ b/cardano_node_tests/tests/test_mir_certs.py @@ -1071,5 +1071,6 @@ def test_exceed_pay_stake_addr_from( tx_name=temp_template, tx_files=tx_files, ) - err_str = str(excinfo.value) - assert "InsufficientForInstantaneousRewardsDELEG" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InsufficientForInstantaneousRewardsDELEG" in exc_value, exc_value diff --git a/cardano_node_tests/tests/test_mnemonic.py b/cardano_node_tests/tests/test_mnemonic.py index ce9974f65..8364e345c 100644 --- a/cardano_node_tests/tests/test_mnemonic.py +++ b/cardano_node_tests/tests/test_mnemonic.py @@ -439,8 +439,9 @@ def test_gen_invalid_size( common.get_test_id(cluster) with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_key.gen_mnemonic(size=size) # type: ignore - err_value = str(excinfo.value) - assert "Invalid mnemonic size" in err_value + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid mnemonic size" in exc_value, exc_value @common.hypothesis_settings(max_examples=500) @hypothesis.given(bad_case=invalid_mnemonic_files) @@ -461,11 +462,12 @@ def test_rejects_noncompliant_mnemonics( mnemonic_file=target, account_number=0, ) - err_value = str(excinfo.value) - assert ( - "Error reading mnemonic file" in err_value - or "Error converting the mnemonic into a key" in err_value - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Error reading mnemonic file" in exc_value + or "Error converting the mnemonic into a key" in exc_value + ) @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("key_type", KEY_TYPES, ids=KEY_TYPE_IDS) @@ -507,5 +509,8 @@ def test_reject_invalid_account_or_key_number( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_key.derive_from_mnemonic(**kwargs) - err_value = str(excinfo.value) - assert "unexpected" in err_value or "Error converting the mnemonic into a key" in err_value + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "unexpected" in exc_value or "Error converting the mnemonic into a key" in exc_value + ), exc_value diff --git a/cardano_node_tests/tests/test_native_tokens.py b/cardano_node_tests/tests/test_native_tokens.py index 659da850f..977d8ba4a 100644 --- a/cardano_node_tests/tests/test_native_tokens.py +++ b/cardano_node_tests/tests/test_native_tokens.py @@ -795,14 +795,16 @@ def _mint_tokens() -> clusterlib.TxRawOutput: with pytest.raises((clusterlib.CLIError, submit_api.SubmitApiError)) as excinfo: _mint_tokens() - err_msg = str(excinfo.value) - assert ( - # On cardano-node 10.0.0+ - re.search(rf"MaxTxSizeUTxO .* {max_tx_size}", err_msg) - # On older cardano-node releases - or "OutputTooBigUTxO" in err_msg # For `build-raw` command - or "balance of the transaction is negative" in err_msg # For `build` command - ), "Unexpected error message" + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # On cardano-node 10.0.0+ + re.search(rf"MaxTxSizeUTxO .* {max_tx_size}", exc_value) + # On older cardano-node releases + or "OutputTooBigUTxO" in exc_value # For `build-raw` command + or "balance of the transaction is negative" + in exc_value # For `build` command + ), exc_value finally: logging.disable(logging.NOTSET) # Wait for the log files to be written @@ -949,14 +951,16 @@ def _mint_tokens() -> clusterlib.TxRawOutput: with pytest.raises((clusterlib.CLIError, submit_api.SubmitApiError)) as excinfo: _mint_tokens() - err_msg = str(excinfo.value) - assert ( - # On cardano-node 10.0.0+ - re.search(rf"MaxTxSizeUTxO .* {max_tx_size}", err_msg) - # On older cardano-node releases - or "OutputTooBigUTxO" in err_msg # For `build-raw` command - or "balance of the transaction is negative" in err_msg # For `build` command - ), "Unexpected error message" + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # On cardano-node 10.0.0+ + re.search(rf"MaxTxSizeUTxO .* {max_tx_size}", exc_value) + # On older cardano-node releases + or "OutputTooBigUTxO" in exc_value # For `build-raw` command + or "balance of the transaction is negative" + in exc_value # For `build` command + ), "Unexpected error message" finally: logging.disable(logging.NOTSET) # Wait for the log files to be written @@ -1436,7 +1440,9 @@ def test_policy_before_past( invalid_before=1, invalid_hereafter=before_slot, ) - assert "OutsideValidityIntervalUTxO" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in exc_value, exc_value # Token minting - invalid range, slot is already in the past with pytest.raises(clusterlib.CLIError) as excinfo: @@ -1447,7 +1453,9 @@ def test_policy_before_past( invalid_before=1, invalid_hereafter=before_slot + 1, ) - assert "ScriptWitnessNotValidatingUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value mint_utxos = cluster.g_query.get_utxo(address=token_mint_addr.address) for t in tokens_to_mint: @@ -1510,7 +1518,9 @@ def test_policy_before_future( invalid_before=1, invalid_hereafter=before_slot + 1, ) - assert "ScriptWitnessNotValidatingUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value mint_utxos = cluster.g_query.get_utxo(address=token_mint_addr.address) for t in tokens_to_mint: @@ -1573,7 +1583,9 @@ def test_policy_after_future( invalid_before=after_slot, invalid_hereafter=after_slot + 100, ) - assert "OutsideValidityIntervalUTxO" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in exc_value, exc_value # Token minting - invalid range, slot is in the future with pytest.raises(clusterlib.CLIError) as excinfo: @@ -1584,7 +1596,9 @@ def test_policy_after_future( invalid_before=1, invalid_hereafter=after_slot, ) - assert "ScriptWitnessNotValidatingUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value mint_utxos = cluster.g_query.get_utxo(address=token_mint_addr.address) for t in tokens_to_mint: @@ -1647,7 +1661,9 @@ def test_policy_after_past( invalid_before=1, invalid_hereafter=after_slot, ) - assert "ScriptWitnessNotValidatingUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value mint_utxos = cluster.g_query.get_utxo(address=token_mint_addr.address) for t in tokens_to_mint: @@ -2097,9 +2113,12 @@ def test_transfer_no_ada( fee_buffer=2_000_000, tx_files=tx_files, ) - assert expected_error in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert expected_error in exc_value, exc_value elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW: expected_error = "OutputTooSmallUTxO" + err_str = "" try: cluster.g_transaction.send_tx( @@ -2109,8 +2128,11 @@ def test_transfer_no_ada( tx_files=tx_files, ) except clusterlib.CLIError as err: - if expected_error not in str(err): - raise + err_str = str(err) + + if err_str: + with common.allow_unstable_error_messages(): + assert expected_error in err_str, err_str elif build_method == clusterlib_utils.BuildMethods.BUILD_EST: expected_error = "Minimum required UTxO:" @@ -2121,7 +2143,9 @@ def test_transfer_no_ada( txouts=txouts, tx_files=tx_files, ) - assert expected_error in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert expected_error in exc_value, exc_value else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) @@ -2179,14 +2203,15 @@ def test_transfer_invalid_token_amount( finally: logging.disable(logging.NOTSET) - exc_val = str(excinfo.value) - assert ( - "The transaction does not balance in its use of assets" - in exc_val # In node 10.4.0+ - or "Non-Ada assets are unbalanced" in exc_val - or "Illegal Value in TxOut" in exc_val # In node 9.2.0+ - or re.search(r"Negative quantity \(-[0-9]*\) in transaction output", exc_val) - ), exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "The transaction does not balance in its use of assets" + in exc_value # In node 10.4.0+ + or "Non-Ada assets are unbalanced" in exc_value + or "Illegal Value in TxOut" in exc_value # In node 9.2.0+ + or re.search(r"Negative quantity \(-[0-9]*\) in transaction output", exc_value) + ), exc_value elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW: with pytest.raises(clusterlib.CLIError) as excinfo: try: @@ -2201,8 +2226,9 @@ def test_transfer_invalid_token_amount( finally: logging.disable(logging.NOTSET) - exc_val = str(excinfo.value) - assert "ValueNotConservedUTxO" in exc_val, exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ValueNotConservedUTxO" in exc_value, exc_value elif build_method == clusterlib_utils.BuildMethods.BUILD_EST: with pytest.raises(clusterlib.CLIError) as excinfo: @@ -2217,11 +2243,11 @@ def test_transfer_invalid_token_amount( finally: logging.disable(logging.NOTSET) - exc_val = str(excinfo.value) + exc_value = str(excinfo.value) # TODO: refine once CLI issue #1199 is fixed # At this point we don't know the exact error string from build-estimate. # Fail explicitly so we can capture and refine later. - pytest.fail(f"Unexpected error for build-estimate (CLI issue #1199): {exc_val}") + pytest.fail(f"Unexpected error for build-estimate (CLI issue #1199): {exc_value}") else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) @@ -2329,12 +2355,13 @@ def test_long_name( new_tokens=[token_mint], temp_template=f"{temp_template}_mint", ) - exc_val = str(excinfo.value) - assert ( - "the bytestring should be no longer than 32 bytes long" in exc_val - or "name exceeds 32 bytes" in exc_val - or "expecting hexadecimal digit" in exc_val - ), exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "the bytestring should be no longer than 32 bytes long" in exc_value + or "name exceeds 32 bytes" in exc_value + or "expecting hexadecimal digit" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(token_amount=st.integers(min_value=MAX_TOKEN_AMOUNT + 1)) @@ -2374,9 +2401,9 @@ def test_minting_amount_above_the_allowed( new_tokens=[token_mint], temp_template=f"{temp_template}_mint", ) - - exc_val = str(excinfo.value) - assert "the number exceeds the max bound" in exc_val, exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "the number exceeds the max bound" in exc_value, exc_value @common.SKIPIF_WRONG_ERA diff --git a/cardano_node_tests/tests/test_pools.py b/cardano_node_tests/tests/test_pools.py index bc80573ba..0e07ab25c 100644 --- a/cardano_node_tests/tests/test_pools.py +++ b/cardano_node_tests/tests/test_pools.py @@ -1921,11 +1921,14 @@ def test_stake_pool_low_cost( ) # Check that it failed in an expected way - err = str(excinfo.value) - if pool_cost < 0: - assert "--pool-cost: Failed reading" in err or "expecting digit" in err - else: - assert "StakePoolCostTooLowPOOL" in err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + if pool_cost < 0: + assert ( + "--pool-cost: Failed reading" in exc_value or "expecting digit" in exc_value + ), exc_value + else: + assert "StakePoolCostTooLowPOOL" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.dbsync @@ -2058,7 +2061,9 @@ def test_pool_registration_cert_wrong_vrf( cold_vkey_file=node_cold.vkey_file, owner_stake_vkey_files=[pool_users[0].stake.vkey_file], ) - assert "Expected: VrfVerificationKey_PraosVRF" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Expected: VrfVerificationKey_PraosVRF" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2085,8 +2090,9 @@ def test_pool_registration_cert_wrong_cold( cold_vkey_file=node_cold.skey_file, # skey instead of vkey owner_stake_vkey_files=[pool_users[0].stake.vkey_file], ) - err_msg = str(excinfo.value) - assert ": StakePoolVerificationKey" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ": StakePoolVerificationKey" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2113,7 +2119,9 @@ def test_pool_registration_cert_wrong_stake( cold_vkey_file=node_cold.vkey_file, owner_stake_vkey_files=[pool_users[0].stake.skey_file], # skey instead of vkey ) - assert "Expected: StakeVerificationKeyShelley" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Expected: StakeVerificationKeyShelley" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2154,7 +2162,9 @@ def test_pool_registration_missing_cold_skey( tx_name="missing_cold_key", tx_files=tx_files, ) - assert "MissingVKeyWitnessesUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2193,7 +2203,9 @@ def test_pool_registration_missing_payment_skey( cluster.g_transaction.send_tx( src_address=pool_users[0].payment.address, tx_name="missing_skey", tx_files=tx_files ) - assert "MissingVKeyWitnessesUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD_NO_EST @@ -2234,9 +2246,9 @@ def test_pool_deregistration_not_registered( fee_buffer=2_000_000, build_method=build_method, ) - - err_msg = str(excinfo.value) - assert "StakePoolNotRegisteredOnKeyPOOL" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakePoolNotRegisteredOnKeyPOOL" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2262,7 +2274,9 @@ def test_stake_pool_metadata_no_name( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - assert 'key "name" not found' in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'key "name" not found' in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2288,7 +2302,9 @@ def test_stake_pool_metadata_no_description( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - assert 'key "description" not found' in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'key "description" not found' in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2314,7 +2330,9 @@ def test_stake_pool_metadata_no_ticker( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - assert 'key "ticker" not found' in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'key "ticker" not found' in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -2340,7 +2358,9 @@ def test_stake_pool_metadata_no_homepage( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - assert 'key "homepage" not found' in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'key "homepage" not found' in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(pool_name=st.text(min_size=51)) @@ -2370,11 +2390,12 @@ def test_stake_pool_metadata_long_name( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - err_value = str(excinfo.value) - assert ( - "Stake pool metadata must consist of at most 512 bytes" in err_value - or '"name" must have at most 50 characters' in err_value - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Stake pool metadata must consist of at most 512 bytes" in exc_value + or '"name" must have at most 50 characters' in exc_value + ) @allure.link(helpers.get_vcs_link()) @hypothesis.given(pool_description=st.text(min_size=256, max_size=1000)) @@ -2404,11 +2425,12 @@ def test_stake_pool_metadata_long_description( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - err_value = str(excinfo.value) - assert ( - "Stake pool metadata must consist of at most 512 bytes" in err_value - or '"description" must have at most 255 characters' in err_value - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Stake pool metadata must consist of at most 512 bytes" in exc_value + or '"description" must have at most 255 characters' in exc_value + ) @allure.link(helpers.get_vcs_link()) @hypothesis.given(pool_ticker=st.text()) @@ -2440,11 +2462,12 @@ def test_stake_pool_metadata_long_ticker( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - err_value = str(excinfo.value) - assert ( - "Stake pool metadata must consist of at most 512 bytes" in err_value - or '"ticker" must have at least 3 and at most 5 characters' in err_value - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Stake pool metadata must consist of at most 512 bytes" in exc_value + or '"ticker" must have at least 3 and at most 5 characters' in exc_value + ) @allure.link(helpers.get_vcs_link()) @hypothesis.given(pool_homepage=st.text(min_size=425, max_size=1000)) @@ -2474,7 +2497,9 @@ def test_stake_pool_metadata_long_homepage( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_stake_pool.gen_pool_metadata_hash(pool_metadata_file) - assert "Stake pool metadata must consist of at most 512 bytes" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Stake pool metadata must consist of at most 512 bytes" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given( @@ -2520,14 +2545,16 @@ def test_stake_pool_long_metadata_url( cold_vkey_file=node_cold.vkey_file, owner_stake_vkey_files=[p.stake.vkey_file for p in pool_users], ) - err_str = str(excinfo.value) - assert ( - "option --metadata-url: The provided string must have at most 128 characters" in err_str - or "invalid url" in err_str - # In cardano-node <= 10.6.0 - or "option --metadata-url: The provided string must have at most 64 characters" - in err_str - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "option --metadata-url: The provided string must have at most 128 characters" + in exc_value + or "invalid url" in exc_value + # In cardano-node <= 10.6.0 + or "option --metadata-url: The provided string must have at most 64 characters" + in exc_value + ) @pytest.mark.skipif( diff --git a/cardano_node_tests/tests/test_scripts.py b/cardano_node_tests/tests/test_scripts.py index 442efd149..28c748ac0 100644 --- a/cardano_node_tests/tests/test_scripts.py +++ b/cardano_node_tests/tests/test_scripts.py @@ -905,8 +905,9 @@ def test_multisig_all_missing_skey( multisig_script=multisig_script, script_utxos=script_utxos, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -962,8 +963,9 @@ def test_multisig_any_unlisted_skey( multisig_script=multisig_script, script_utxos=script_utxos, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -1027,8 +1029,9 @@ def test_multisig_atleast_low_num_of_skeys( multisig_script=multisig_script, script_utxos=script_utxos, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -1421,8 +1424,9 @@ def test_tx_missing_validity( invalid_hereafter=None, # missing required validity interval for "before" build_method=build_method, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD @@ -1481,19 +1485,20 @@ def test_tx_negative_validity( invalid_hereafter=-1, build_method=build_method, ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) # In node versions >= 1.36.0 we are checking error from # `cardano-cli transaction build/build-raw` - if "SLOT must not be less than" in err_str: + if "SLOT must not be less than" in exc_value: return # In node versions < 1.36.0 we were checking error from `cardano-cli transaction submit` - assert "OutsideValidityIntervalUTxO" in err_str, err_str + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in exc_value, exc_value slot_no = 0 _slot_search = re.search( - r"ValidityInterval {invalidBefore = SJust \(SlotNo ([0-9]*)", err_str + r"ValidityInterval {invalidBefore = SJust \(SlotNo ([0-9]*)", exc_value ) if _slot_search is not None: slot_no = int(_slot_search.group(1)) @@ -1554,8 +1559,9 @@ def test_before_past( invalid_hereafter=before_slot - slot_no, build_method=build_method, ) - err_str = str(excinfo.value) - assert "OutsideValidityIntervalUTxO" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in exc_value, exc_value # Send funds from script address - invalid range, slot is already in the past with pytest.raises(clusterlib.CLIError) as excinfo: @@ -1572,8 +1578,9 @@ def test_before_past( invalid_hereafter=before_slot + slot_no, build_method=build_method, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -1629,8 +1636,9 @@ def test_before_future( invalid_hereafter=before_slot + slot_no, build_method=build_method, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -1688,8 +1696,9 @@ def test_after_future( invalid_hereafter=after_slot + slot_no + 100, build_method=build_method, ) - err_str = str(excinfo.value) - assert "OutsideValidityIntervalUTxO" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in exc_value, exc_value # Send funds from script address - invalid range, slot is in the future with pytest.raises(clusterlib.CLIError) as excinfo: @@ -1706,8 +1715,9 @@ def test_after_future( invalid_hereafter=after_slot, build_method=build_method, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -1766,8 +1776,9 @@ def test_after_past( invalid_hereafter=after_slot - slot_no, build_method=build_method, ) - err_str = str(excinfo.value) - assert "ScriptWitnessNotValidatingUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ScriptWitnessNotValidatingUTXOW" in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -2007,8 +2018,9 @@ def test_tx_script_invalid( else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) - err_str = str(excinfo.value) - assert 'Error in $: key "type" not found' in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'Error in $: key "type" not found' in exc_value, exc_value class TestIncrementalSigning: @@ -3024,8 +3036,8 @@ def test_invalid( # noqa: C901 submit_method=submit_method, build_method=build_method, ) - err_str = str(excinfo.value) - assert expected_err in err_str, err_str + exc_value = str(excinfo.value) + assert expected_err in exc_value, exc_value dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output) @@ -3112,11 +3124,12 @@ def test_script_v2( invalid_hereafter=150, submit_method=submit_method, ) - err_str = str(excinfo.value) - assert ( - "SimpleScriptV2 is not supported" in err_str - or "Transaction validity lower bound not supported in Shelley" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "SimpleScriptV2 is not supported" in exc_value + or "Transaction validity lower bound not supported in Shelley" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( @@ -3159,8 +3172,9 @@ def test_auxiliary_scripts( submit_method=submit_method, tx_files=tx_files, ) - err_str = str(excinfo.value) - assert ( - "Transaction auxiliary scripts are not supported" in err_str - or "Auxiliary scripts cannot be used" in err_str # node <= 1.35.6 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Transaction auxiliary scripts are not supported" in exc_value + or "Auxiliary scripts cannot be used" in exc_value # node <= 1.35.6 + ), exc_value diff --git a/cardano_node_tests/tests/test_tx_basic.py b/cardano_node_tests/tests/test_tx_basic.py index 9bea5b836..edbe50d51 100644 --- a/cardano_node_tests/tests/test_tx_basic.py +++ b/cardano_node_tests/tests/test_tx_basic.py @@ -1747,8 +1747,9 @@ def test_incremental_signing( tx_file=tx_signed, txins=tx_output.txins, ) - err_str = str(excinfo.value) - assert "MissingVKeyWitnessesUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value # Incrementally sign the already signed Tx with the required skey tx_signed = cluster.g_transaction.sign_tx( diff --git a/cardano_node_tests/tests/test_tx_fees.py b/cardano_node_tests/tests/test_tx_fees.py index 287e14212..7aa4e08dd 100644 --- a/cardano_node_tests/tests/test_tx_fees.py +++ b/cardano_node_tests/tests/test_tx_fees.py @@ -89,7 +89,9 @@ def test_negative_fee( tx_files=tx_files, fee=fee, ) - assert "option --fee:" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "option --fee:" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("fee_change", (0, 1.1, 1.5, 2)) @@ -133,7 +135,9 @@ def test_smaller_fee( tx_files=tx_files, fee=int(fee), ) - assert "FeeTooSmallUTxO" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "FeeTooSmallUTxO" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("fee_add", (0, 1_000, 100_000, 1_000_000)) diff --git a/cardano_node_tests/tests/test_tx_metadata.py b/cardano_node_tests/tests/test_tx_metadata.py index 7c7aaf59d..deadbf92f 100644 --- a/cardano_node_tests/tests/test_tx_metadata.py +++ b/cardano_node_tests/tests/test_tx_metadata.py @@ -69,8 +69,9 @@ def test_tx_wrong_json_metadata_format( tx_name="wrong_json_format", tx_files=tx_files, ) - str_err = str(excinfo.value) - assert "The JSON metadata top level must be a map" in str_err, str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "The JSON metadata top level must be a map" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -99,8 +100,9 @@ def test_build_tx_wrong_json_metadata_format( tx_files=tx_files, fee_buffer=1_000_000, ) - str_err = str(excinfo.value) - assert "The JSON metadata top level must be a map" in str_err, str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "The JSON metadata top level must be a map" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -126,12 +128,13 @@ def test_tx_invalid_json_metadata( tx_name="invalid_metadata", tx_files=tx_files, ) - str_err = str(excinfo.value) - assert ( - "expecting record key literal" in str_err # cardano-cli >= 10.11.1.1 - or "Failed reading: satisfy" in str_err # cardano-node < 8.7.0 - or "JSON parse error:" in str_err - ), str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "expecting record key literal" in exc_value # cardano-cli >= 10.11.1.1 + or "Failed reading: satisfy" in exc_value # cardano-node < 8.7.0 + or "JSON parse error:" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -161,12 +164,13 @@ def test_build_tx_invalid_json_metadata( tx_files=tx_files, fee_buffer=1_000_000, ) - str_err = str(excinfo.value) - assert ( - "expecting record key literal" in str_err # cardano-cli >= 10.11.1.1 - or "Failed reading: satisfy" in str_err # cardano-node < 8.7.0 - or "JSON parse error:" in str_err - ), str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "expecting record key literal" in exc_value # cardano-cli >= 10.11.1.1 + or "Failed reading: satisfy" in exc_value # cardano-node < 8.7.0 + or "JSON parse error:" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -189,10 +193,11 @@ def test_tx_too_long_metadata_json( tx_name="too_long_metadata", tx_files=tx_files, ) - str_err = str(excinfo.value) - assert "Text string metadata value must consist of at most 64 UTF8 bytes" in str_err, ( - str_err - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Text string metadata value must consist of at most 64 UTF8 bytes" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -220,10 +225,11 @@ def test_build_tx_too_long_metadata_json( tx_files=tx_files, fee_buffer=1_000_000, ) - str_err = str(excinfo.value) - assert "Text string metadata value must consist of at most 64 UTF8 bytes" in str_err, ( - str_err - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Text string metadata value must consist of at most 64 UTF8 bytes" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke diff --git a/cardano_node_tests/tests/test_tx_negative.py b/cardano_node_tests/tests/test_tx_negative.py index 354d69b07..d2e19cc40 100644 --- a/cardano_node_tests/tests/test_tx_negative.py +++ b/cardano_node_tests/tests/test_tx_negative.py @@ -118,9 +118,10 @@ def _send_funds_to_invalid_address( else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) - exc_val = str(excinfo.value) - # TODO: better match - assert "invalid address" in exc_val or "An error occurred" in exc_val, exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + # TODO: better match + assert "invalid address" in exc_value or "An error occurred" in exc_value, exc_value def _send_funds_from_invalid_address( self, @@ -163,7 +164,9 @@ def _send_funds_from_invalid_address( else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) - assert "invalid address" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "invalid address" in exc_value, exc_value def _send_funds_invalid_change_address( self, @@ -186,7 +189,9 @@ def _send_funds_invalid_change_address( tx_files=tx_files, fee_buffer=1_000_000, ) - assert "invalid address" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "invalid address" in exc_value, exc_value def _send_funds_with_invalid_utxo( self, @@ -249,7 +254,7 @@ def _submit_wrong_validity( tx_files = clusterlib.TxFiles(signing_key_files=[pool_users[0].payment.skey_file]) txouts = [clusterlib.TxOut(address=dst_address, amount=2_000_000)] - exc_val = "" + exc_str = "" slot_no = tx_output = None try: @@ -287,10 +292,10 @@ def _submit_wrong_validity( msg = f"Unsupported build method: {build_method}" raise ValueError(msg) except clusterlib.CLIError as exc: - exc_val = str(exc) - if "SLOT must not" not in exc_val: + exc_str = str(exc) + if "SLOT must not" not in exc_str: raise - return slot_no, exc_val, tx_output + return slot_no, exc_str, tx_output # Prior to node 1.36.0, it was possible to build a transaction with invalid interval, # but it was not possible to submit it. @@ -304,17 +309,19 @@ def _submit_wrong_validity( # It should NOT be possible to submit a transaction with negative ttl with pytest.raises(clusterlib.CLIError) as excinfo: cluster_obj.g_transaction.submit_tx_bare(out_file_signed) - exc_val = str(excinfo.value) - - assert "ExpiredUTxO" in exc_val or "OutsideValidityIntervalUTxO" in exc_val, exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ExpiredUTxO" in exc_value or "OutsideValidityIntervalUTxO" in exc_value, ( + exc_value + ) - slot_no_search = re.search(r"ValidityInterval .*SJust \(SlotNo ([0-9]*)", exc_val) + slot_no_search = re.search(r"ValidityInterval .*SJust \(SlotNo ([0-9]*)", exc_value) if slot_no_search is None: err = "Cannot find SlotNo in CLI error output" raise RuntimeError(err) slot_no = int(slot_no_search.group(1)) - return slot_no, exc_val, tx_output + return slot_no, exc_value, tx_output def _get_validity_range( self, cluster_obj: clusterlib.ClusterLib, tx_body_file: pl.Path @@ -491,7 +498,9 @@ def test_before_too_high( build_method=build_method, ) - assert "(OutsideValidityIntervalUTxO" in err_str, err_str + assert err_str, "Expected error but none was raised" + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in err_str, err_str @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( @@ -621,7 +630,10 @@ def test_pbt_before_too_high( build_method=build_method, ) - assert "(OutsideValidityIntervalUTxO" in err_str, err_str + assert err_str, "Expected error but none was raised" + with common.allow_unstable_error_messages(): + assert "OutsideValidityIntervalUTxO" in err_str, err_str + assert slot_no == before_value, f"SlotNo: {slot_no}, `before_value`: {before_value}" @allure.link(helpers.get_vcs_link()) @@ -680,11 +692,12 @@ def test_duplicated_tx( # It should NOT be possible to submit a transaction twice with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx_bare(out_file_signed) - exc_str = str(excinfo.value) - assert ( - "All inputs are spent" in exc_str # In cardano-node >= 10.6.0 - or "(ValueNotConservedUTxO" in exc_str - ), exc_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "All inputs are spent" in exc_value # In cardano-node >= 10.6.0 + or "(ValueNotConservedUTxO" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -754,7 +767,9 @@ def test_wrong_network_magic( str(out_file_signed), ] ) - assert "HandshakeError" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "HandshakeError" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -782,7 +797,9 @@ def test_wrong_signing_key( txouts=txouts, tx_files=tx_files, ) - assert "MissingVKeyWitnessesUTXOW" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingVKeyWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -810,11 +827,12 @@ def test_wrong_tx_era( txouts=txouts, tx_files=tx_files, ) - err_str = str(excinfo.value) - assert ( - "The era of the node and the tx do not match" in err_str - or "HardForkEncoderDisabledEra" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "The era of the node and the tx do not match" in exc_value + or "HardForkEncoderDisabledEra" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_BUILD_METHOD @@ -1134,26 +1152,30 @@ def test_nonexistent_utxo_ix( utxo = cluster.g_query.get_utxo(address=pool_users[0].payment.address)[0] utxo_copy = dataclasses.replace(utxo, utxo_ix=5) - err = self._send_funds_with_invalid_utxo( + err_str = self._send_funds_with_invalid_utxo( cluster_obj=cluster, pool_users=pool_users, utxo=utxo_copy, temp_template=temp_template, build_method=build_method, ) + assert err_str, "Expected error but none was raised" + if build_method in ( clusterlib_utils.BuildMethods.BUILD, clusterlib_utils.BuildMethods.BUILD_EST, ): - assert ( - "The UTxO is empty" in err - or "The following tx input(s) were not present in the UTxO" in err - ), err + with common.allow_unstable_error_messages(): + assert ( + "The UTxO is empty" in err_str + or "The following tx input(s) were not present in the UTxO" in err_str + ), err_str elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW: - assert ( - "All inputs are spent" in err # In cardano-node >= 10.6.0 - or "BadInputsUTxO" in err - ), err + with common.allow_unstable_error_messages(): + assert ( + "All inputs are spent" in err_str # In cardano-node >= 10.6.0 + or "BadInputsUTxO" in err_str + ), err_str else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) @@ -1177,26 +1199,30 @@ def test_nonexistent_utxo_hash( utxo = cluster.g_query.get_utxo(address=pool_users[0].payment.address)[0] new_hash = f"{utxo.utxo_hash[:-4]}fd42" utxo_copy = dataclasses.replace(utxo, utxo_hash=new_hash) - err = self._send_funds_with_invalid_utxo( + err_str = self._send_funds_with_invalid_utxo( cluster_obj=cluster, pool_users=pool_users, utxo=utxo_copy, temp_template=temp_template, build_method=build_method, ) + assert err_str, "Expected error but none was raised" + if build_method in ( clusterlib_utils.BuildMethods.BUILD, clusterlib_utils.BuildMethods.BUILD_EST, ): - assert ( - "The UTxO is empty" in err - or "The following tx input(s) were not present in the UTxO" in err - ), err + with common.allow_unstable_error_messages(): + assert ( + "The UTxO is empty" in err_str + or "The following tx input(s) were not present in the UTxO" in err_str + ), err_str elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW: - assert ( - "All inputs are spent" in err # In cardano-node >= 10.6.0 - or "BadInputsUTxO" in err - ), err + with common.allow_unstable_error_messages(): + assert ( + "All inputs are spent" in err_str # In cardano-node >= 10.6.0 + or "BadInputsUTxO" in err_str + ), err_str else: msg = f"Unsupported build method: {build_method}" raise ValueError(msg) @@ -1222,19 +1248,22 @@ def test_invalid_length_utxo_hash( utxo = cluster.g_query.get_utxo(address=pool_users[0].payment.address)[0] utxo_copy = dataclasses.replace(utxo, utxo_hash=utxo_hash) - err = self._send_funds_with_invalid_utxo( + err_str = self._send_funds_with_invalid_utxo( cluster_obj=cluster, pool_users=pool_users, utxo=utxo_copy, temp_template=temp_template, build_method=build_method, ) - assert ( - "Failed to deserialise" in err # With node 10.5.0+ - or "Incorrect transaction id format" in err - or "Failed reading" in err - or "expecting transaction id (hexadecimal)" in err - ) + + assert err_str, "Expected error but none was raised" + with common.allow_unstable_error_messages(): + assert ( + "Failed to deserialise" in err_str # With node 10.5.0+ + or "Incorrect transaction id format" in err_str + or "Failed reading" in err_str + or "expecting transaction id (hexadecimal)" in err_str + ), err_str @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -1258,19 +1287,22 @@ def test_build_invalid_length_utxo_hash( utxo = cluster.g_query.get_utxo(address=pool_users[0].payment.address)[0] utxo_copy = dataclasses.replace(utxo, utxo_hash=utxo_hash) - err = self._send_funds_with_invalid_utxo( + err_str = self._send_funds_with_invalid_utxo( cluster_obj=cluster, pool_users=pool_users, utxo=utxo_copy, temp_template=temp_template, build_method=clusterlib_utils.BuildMethods.BUILD, ) - assert ( - "Failed to deserialise" in err # With node 10.5.0+ - or "Incorrect transaction id format" in err - or "Failed reading" in err - or "expecting transaction id (hexadecimal)" in err - ) + + assert err_str, "Expected error but none was raised" + with common.allow_unstable_error_messages(): + assert ( + "Failed to deserialise" in err_str # With node 10.5.0+ + or "Incorrect transaction id format" in err_str + or "Failed reading" in err_str + or "expecting transaction id (hexadecimal)" in err_str + ), err_str @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1318,14 +1350,17 @@ def test_missing_fee( else: issues.cli_796.finish_test() + assert err_str, "Expected error but none was raised" + if "Transaction _ fee not supported in" in err_str: issues.node_4591.finish_test() - assert ( - "fee must be specified" in err_str - or "Implicit transaction fee not supported" in err_str - or "Missing: --fee LOVELACE" in err_str # node >= 8.12.0 - ), err_str + with common.allow_unstable_error_messages(): + assert ( + "fee must be specified" in err_str + or "Implicit transaction fee not supported" in err_str + or "Missing: --fee LOVELACE" in err_str # node >= 8.12.0 + ), err_str @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( @@ -1368,15 +1403,15 @@ def test_missing_ttl( *helpers.prepend_flag("--tx-out", txouts), ] ) - err_str = str(excinfo.value) - - if "Transaction validity upper bound not supported" in err_str: + exc_value = str(excinfo.value) + if "Transaction validity upper bound not supported" in exc_value: issues.node_4591.finish_test() - assert ( - "TTL must be specified" in err_str - or "Transaction validity upper bound must be specified" in err_str - ), err_str + with common.allow_unstable_error_messages(): + assert ( + "TTL must be specified" in exc_value + or "Transaction validity upper bound must be specified" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1416,8 +1451,9 @@ def test_missing_tx_in( *helpers.prepend_flag("--tx-out", txouts), ] ) - err_str = str(excinfo.value) - assert re.search(r"Missing: *\(--tx-in TX[_-]IN", err_str), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Missing: *\(--tx-in TX[_-]IN", exc_value), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( @@ -1454,11 +1490,12 @@ def test_lower_bound_not_supported( fee=1_000, invalid_before=10, # the unsupported argument ) - err_str = str(excinfo.value) - assert ( - "validity lower bound not supported" in err_str - or "validity lower bound cannot be used" in err_str # node <= 1.35.6 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "validity lower bound not supported" in exc_value + or "validity lower bound cannot be used" in exc_value # node <= 1.35.6 + ), exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -1502,8 +1539,9 @@ def test_build_missing_tx_in( *helpers.prepend_flag("--tx-out", txouts), ] ) - err_str = str(excinfo.value) - assert re.search(r"Missing: *\(--tx-in TX[_-]IN", err_str), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Missing: *\(--tx-in TX[_-]IN", exc_value), exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -1546,7 +1584,9 @@ def test_build_missing_change_address( *helpers.prepend_flag("--tx-out", txouts), ] ) - assert re.search(r"Missing:.* --change-address ADDRESS", str(excinfo.value)) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Missing:.* --change-address ADDRESS", exc_value), exc_value @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -1593,4 +1633,6 @@ def test_build_multiple_change_addresses( ), ] ) - assert re.search(r"Invalid option.*--change-address", str(excinfo.value)) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Invalid option.*--change-address", exc_value), exc_value diff --git a/cardano_node_tests/tests/test_tx_unbalanced.py b/cardano_node_tests/tests/test_tx_unbalanced.py index a9a01acf4..09b245d51 100644 --- a/cardano_node_tests/tests/test_tx_unbalanced.py +++ b/cardano_node_tests/tests/test_tx_unbalanced.py @@ -34,8 +34,7 @@ def _build_transfer_amount_bellow_minimum( src_address = payment_addrs[0].address dst_address = payment_addrs[1].address - err_str = "" - try: + with pytest.raises(clusterlib.CLIError) as excinfo: cluster.cli( [ "transaction", @@ -51,17 +50,16 @@ def _build_transfer_amount_bellow_minimum( *cluster.magic_args, ] ) - except clusterlib.CLIError as err: - err_str = str(err) - - if amount < 0: - assert ( - "Value must be positive in UTxO" in err_str # In cli 10.1.1.0+ - or "Illegal Value in TxOut" in err_str # In node 9.2.0+ - or "Negative quantity" in err_str - ), err_str - else: - assert "Minimum UTxO threshold not met for tx output" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + if amount < 0: + assert ( + "Value must be positive in UTxO" in exc_value # In cli 10.1.1.0+ + or "Illegal Value in TxOut" in exc_value # In node 9.2.0+ + or "Negative quantity" in exc_value + ), exc_value + else: + assert "Minimum UTxO threshold not met for tx output" in exc_value, exc_value @pytest.fixture def payment_addrs( @@ -140,16 +138,17 @@ def test_negative_change( fee=fee, ttl=ttl, ) - exc_val = str(excinfo.value) - assert ( - "option --tx-out: Failed reading" in exc_val - or "TxOutAdaOnly" in exc_val - or "AdaAssetId,-1" in exc_val - or "Negative quantity" in exc_val # cardano-node >= 8.7.0 - or "Illegal Value in TxOut" in exc_val # cardano-node >= 9.2.0 - ) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "option --tx-out: Failed reading" in exc_value + or "TxOutAdaOnly" in exc_value + or "AdaAssetId,-1" in exc_value + or "Negative quantity" in exc_value # cardano-node >= 8.7.0 + or "Illegal Value in TxOut" in exc_value # cardano-node >= 9.2.0 + ) - if "CallStack" in exc_val: + if "CallStack" in exc_value: issues.cli_904.finish_test() @allure.link(helpers.get_vcs_link()) @@ -191,11 +190,12 @@ def test_build_transfer_unavailable_funds( txouts=txouts, tx_files=tx_files, ) - exc_val = str(excinfo.value) - assert ( - "The net balance of the transaction is negative" in exc_val - or "Illegal Value in TxOut" in exc_val # In node 9.2.0+ - ), exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "The net balance of the transaction is negative" in exc_value + or "Illegal Value in TxOut" in exc_value # In node 9.2.0+ + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(change_amount=st.integers(min_value=2_000_000, max_value=MAX_LOVELACE_AMOUNT)) @@ -254,9 +254,12 @@ def test_wrong_balance( # It should NOT be possible to submit an unbalanced transaction with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx_bare(out_file_signed) - exc_val = str(excinfo.value) - # TODO: see https://github.com/IntersectMBO/cardano-node/issues/2555 - assert "ValueNotConservedUTxO" in exc_val or "DeserialiseFailure" in exc_val, exc_val + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + # TODO: see https://github.com/IntersectMBO/cardano-node/issues/2555 + assert "ValueNotConservedUTxO" in exc_value or "DeserialiseFailure" in exc_value, ( + exc_value + ) @allure.link(helpers.get_vcs_link()) @hypothesis.given(change_amount=st.integers(min_value=MAX_LOVELACE_AMOUNT + 1)) @@ -286,6 +289,7 @@ def test_out_of_bounds_amount( clusterlib.TxOut(address=payment_addrs[0].address, amount=change_amount), ] + err_str = "" try: cluster.g_transaction.build_raw_tx_bare( out_file=out_file_tx, @@ -296,8 +300,11 @@ def test_out_of_bounds_amount( ttl=ttl, ) except clusterlib.CLIError as exc: - exc_val = str(exc) - assert "out of bounds" in exc_val or "exceeds the max bound" in exc_val, exc_val + err_str = str(exc) + + if err_str: + with common.allow_unstable_error_messages(): + assert "out of bounds" in err_str or "exceeds the max bound" in err_str, err_str @allure.link(helpers.get_vcs_link()) @common.SKIPIF_BUILD_UNUSABLE @@ -427,8 +434,9 @@ def test_transfer_amount_bellow_minimum( # Submit the signed transaction cluster.g_transaction.submit_tx(tx_file=out_file_signed, txins=[pbt_highest_utxo]) - exc_val = str(excinfo_build.value) - assert "OutputTooSmallUTxO" in exc_val, exc_val + exc_value = str(excinfo_build.value) + with common.allow_unstable_error_messages(): + assert "OutputTooSmallUTxO" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(amount=st.integers(min_value=-MAX_LOVELACE_AMOUNT, max_value=-1)) diff --git a/cardano_node_tests/tests/tests_conway/test_committee.py b/cardano_node_tests/tests/tests_conway/test_committee.py index e6845376e..cddfebdb6 100644 --- a/cardano_node_tests/tests/tests_conway/test_committee.py +++ b/cardano_node_tests/tests/tests_conway/test_committee.py @@ -151,8 +151,9 @@ def test_register_hot_key_no_cc_member( build_method=build_method, tx_files=tx_files_auth, ) - err_str = str(excinfo.value) - assert "ConwayCommitteeIsUnknown" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ConwayCommitteeIsUnknown" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -277,11 +278,12 @@ def _submit_vote(scenario: str, build_method: str, submit_method: str) -> None: build_method=build_method, submit_method=smethod, ) - err_str = str(excinfo.value) - assert ( - "UnelectedCommitteeVoters" in err_str # In protocol version >= 11 - or "VotersDoNotExist" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "UnelectedCommitteeVoters" in exc_value # In protocol version >= 11 + or "VotersDoNotExist" in exc_value + ), exc_value # Update committee action is not supported in bootstrap period if conway_common.is_in_bootstrap(cluster_obj=cluster): @@ -404,12 +406,13 @@ def _auth_hot_keys() -> None: build_method=build_method, submit_method=smethod, ) - err_str = str(excinfo.value) - assert re.search( - "ConwayMempoolFailure .*Unelected committee members are not allowed " - "to cast votes:", - err_str, - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search( + "ConwayMempoolFailure .*Unelected committee members are not " + "allowed to cast votes:", + exc_value, + ), exc_value subtest_errors.pop() if not subtest_errors: @@ -496,8 +499,9 @@ def test_update_committee_action( tx_files=tx_files, deposit=deposit_amt, ) - err_str = str(excinfo.value) - assert "(DisallowedProposalDuringBootstrap" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedProposalDuringBootstrap" in exc_value, exc_value reqc.cip026_01.success() return @@ -1066,8 +1070,9 @@ def _check_resign_dbsync(res_member: clusterlib.CCMember) -> None: approve_drep=True, approve_spo=True, ) - err_str = str(excinfo.value) - assert "CommitteeVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "CommitteeVoter" in exc_value, exc_value # Vote & disapprove the removal action conway_common.cast_vote( @@ -1199,8 +1204,9 @@ def _check_resign_dbsync(res_member: clusterlib.CCMember) -> None: approve_drep=False, approve_spo=False, ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value # Check ratification of removal action. The removal action should be ratified at the same # time as the add action is enacted, because ratification of new actions was delayed by @@ -1224,8 +1230,9 @@ def _check_resign_dbsync(res_member: clusterlib.CCMember) -> None: approve_drep=False, approve_spo=False, ) - err_str = str(excinfo.value) - assert "(VotingOnExpiredGovAction" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "VotingOnExpiredGovAction" in exc_value, exc_value next_rat_rem_state = enact_add_gov_state["nextRatifyState"] _check_cc_member2_removed(gov_state=next_rat_rem_state["nextEnactState"]) @@ -1282,8 +1289,9 @@ def _check_resign_dbsync(res_member: clusterlib.CCMember) -> None: approve_drep=True, approve_spo=True, ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value # Resign CC member _resign_member(res_member=cc_members[2]) @@ -1689,9 +1697,9 @@ def test_update_committee_threshold_out_of_range( prev_action_ix=prev_action_rec.ix, deposit_return_stake_vkey_file=pool_user.stake.vkey_file, ) - - err_str = str(excinfo.value) - assert "Please enter a value in the range [0,1]" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Please enter a value in the range [0,1]" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif(not configuration.HAS_CC, reason="Runs only on setup with CC") diff --git a/cardano_node_tests/tests/tests_conway/test_constitution.py b/cardano_node_tests/tests/tests_conway/test_constitution.py index 241719183..26b1ace12 100644 --- a/cardano_node_tests/tests/tests_conway/test_constitution.py +++ b/cardano_node_tests/tests/tests_conway/test_constitution.py @@ -385,8 +385,9 @@ def test_change_constitution( constitution_hash=constitution_hash, pool_user=pool_user_lg, ) - err_str = str(excinfo.value) - assert "(DisallowedProposalDuringBootstrap" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedProposalDuringBootstrap" in exc_value, exc_value reqc.cip026_02.success() return @@ -427,8 +428,9 @@ def test_change_constitution( approve_spo=False, build_method=clusterlib_utils.BuildMethods.BUILD_RAW, # cardano-cli issue #650 ) - err_str = str(excinfo.value) - assert "StakePoolVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakePoolVoter" in exc_value, exc_value # Vote & disapprove the action conway_common.cast_vote( @@ -551,8 +553,9 @@ def _check_cli_query(): dst_addr_record=pool_user_lg.payment, tx_name=temp_template, ) - err_str = str(excinfo.value) - assert "(ConwayWdrlNotDelegatedToDRep" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ConwayWdrlNotDelegatedToDRep" in exc_value, exc_value reqc.cip027.success() # Try to vote on enacted action @@ -568,8 +571,9 @@ def _check_cli_query(): approve_drep=False, build_method=clusterlib_utils.BuildMethods.BUILD_RAW, # cardano-cli issue #650 ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value # Check action view reqc.cli020.start(url=helpers.get_vcs_link()) diff --git a/cardano_node_tests/tests/tests_conway/test_conway.py b/cardano_node_tests/tests/tests_conway/test_conway.py index 94e7dca34..57bf5b223 100644 --- a/cardano_node_tests/tests/tests_conway/test_conway.py +++ b/cardano_node_tests/tests/tests_conway/test_conway.py @@ -63,8 +63,9 @@ def test_genesis_cert_not_available(self, cluster: clusterlib.ClusterLib): ], add_default_args=False, ) - err_str = str(excinfo.value) - assert "Invalid argument" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid argument" in exc_value, exc_value reqc.cip071.success() @@ -107,17 +108,20 @@ def _run_test_action_unreg_deposit_addr( build_method=build_method, tx_files=tx_files_action, ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) if build_method in ( clusterlib_utils.BuildMethods.BUILD, clusterlib_utils.BuildMethods.BUILD_EST, ): - assert ( - "Stake credential specified in the proposal is not registered on-chain" in err_str - or "ProposalReturnAccountDoesNotExist" in err_str # In node <= 10.1.4 - ), err_str + with common.allow_unstable_error_messages(): + assert ( + "Stake credential specified in the proposal is not registered on-chain" + in exc_value + or "ProposalReturnAccountDoesNotExist" in exc_value # In node <= 10.1.4 + ), exc_value elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW: - assert "ProposalReturnAccountDoesNotExist" in err_str, err_str + with common.allow_unstable_error_messages(): + assert "ProposalReturnAccountDoesNotExist" in exc_value, exc_value else: msg = f"Unexpected build method: {build_method}" raise ValueError(msg) diff --git a/cardano_node_tests/tests/tests_conway/test_drep.py b/cardano_node_tests/tests/tests_conway/test_drep.py index 1e78c118f..3115e37c1 100644 --- a/cardano_node_tests/tests/tests_conway/test_drep.py +++ b/cardano_node_tests/tests/tests_conway/test_drep.py @@ -901,8 +901,9 @@ def test_no_delegation_without_stake_registration( deposit=deposit_address_amt, ) - err_msg = str(excinfo.value) - assert "StakeKeyNotRegisteredDELEG" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakeKeyNotRegisteredDELEG" in exc_value, exc_value reqc.cip088.success() @allure.link(helpers.get_vcs_link()) @@ -952,9 +953,9 @@ def test_drep_no_retirement_before_register( tx_files=tx_files_ret, deposit=deposit_drep_amt, ) - - err_msg = str(excinfo.value) - assert "ConwayDRepNotRegistered" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ConwayDRepNotRegistered" in exc_value, exc_value reqc.cip089.success() @allure.link(helpers.get_vcs_link()) @@ -1035,9 +1036,9 @@ def test_drep_no_multiple_registration( tx_files=tx_files_reg, deposit=reg_drep.deposit, ) - - err_msg = str(excinfo.value) - assert "ConwayDRepAlreadyRegistered" in err_msg, err_msg + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ConwayDRepAlreadyRegistered" in exc_value, exc_value reqc.cip090.success() diff --git a/cardano_node_tests/tests/tests_conway/test_hardfork.py b/cardano_node_tests/tests/tests_conway/test_hardfork.py index 8fd9f67e5..7535aedeb 100644 --- a/cardano_node_tests/tests/tests_conway/test_hardfork.py +++ b/cardano_node_tests/tests/tests_conway/test_hardfork.py @@ -162,8 +162,9 @@ def test_hardfork( approve_drep=False, approve_spo=False, ) - err_str = str(excinfo.value) - assert "(DisallowedVotesDuringBootstrap ((DRepVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedVotesDuringBootstrap ((DRepVoter" in exc_value, exc_value reqc.cip026_04.success() # Vote & disapprove the action @@ -270,8 +271,9 @@ def test_hardfork( approve_drep=False, approve_spo=False, ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value # Check action view governance_utils.check_action_view(cluster_obj=cluster, action_data=hardfork_action) diff --git a/cardano_node_tests/tests/tests_conway/test_no_confidence.py b/cardano_node_tests/tests/tests_conway/test_no_confidence.py index 4d1396156..11285a9b9 100644 --- a/cardano_node_tests/tests/tests_conway/test_no_confidence.py +++ b/cardano_node_tests/tests/tests_conway/test_no_confidence.py @@ -220,8 +220,9 @@ def test_no_confidence_action( approve_drep=True, approve_spo=True, ) - err_str = str(excinfo.value) - assert "CommitteeVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "CommitteeVoter" in exc_value, exc_value # Check ratification rat_epoch = cluster.wait_for_epoch(epoch_no=init_epoch + 1, padding_seconds=5) @@ -295,8 +296,9 @@ def test_no_confidence_action( approve_drep=False, approve_spo=False, ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value reqc.cip041.start(url=helpers.get_vcs_link()) governance_setup.reinstate_committee( @@ -392,8 +394,9 @@ def test_committee_min_size( approve_cc=True, approve_drep=True, ) - err_str = str(excinfo.value) - assert "(VotersDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "VotersDoNotExist" in exc_value, exc_value # Make sure we have enough time to submit the votes in one epoch clusterlib_utils.wait_for_epoch_interval( diff --git a/cardano_node_tests/tests/tests_conway/test_pparam_update.py b/cardano_node_tests/tests/tests_conway/test_pparam_update.py index aaa35a308..69dd790d3 100644 --- a/cardano_node_tests/tests/tests_conway/test_pparam_update.py +++ b/cardano_node_tests/tests/tests_conway/test_pparam_update.py @@ -758,8 +758,9 @@ def _check_proposed_pparams( if net_nodrep_prop_rec.proposal_names.isdisjoint(SECURITY_PPARAMS) else True, ) - err_str = str(excinfo.value) - assert "(DisallowedVotesDuringBootstrap" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedVotesDuringBootstrap" in exc_value, exc_value else: conway_common.cast_vote( cluster_obj=cluster, @@ -892,8 +893,9 @@ def _check_proposed_pparams( approve_drep=None if is_in_bootstrap else False, approve_spo=True, ) - err_str = str(excinfo.value) - assert "StakePoolVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakePoolVoter" in exc_value, exc_value _url = helpers.get_vcs_link() reqc.cip065.start(url=_url) @@ -1325,8 +1327,9 @@ def _check_state(state: dict): approve_cc=False, approve_drep=None if is_in_bootstrap else False, ) - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value # Check that deposit is returned for the enacted pparam proposal right after enactment. # Check that deposit is returned also for pparam proposals that are no longer valid @@ -1503,8 +1506,9 @@ def test_legacy_proposal_submit( ], ), ) - err_str = str(excinfo.value) - assert 'TextEnvelopeType "UpdateProposalShelley"' in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert 'TextEnvelopeType "UpdateProposalShelley"' in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1548,8 +1552,9 @@ def test_legacy_proposal_build( ], add_default_args=False, ) - err_str = str(excinfo.value) - assert "Invalid argument `create-update-proposal'" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Invalid argument `create-update-proposal'" in exc_value, exc_value class TestNegativeCostModels: @@ -1564,10 +1569,7 @@ def test_incompatible_cost_models( """Test incompatible Plutus cost models.""" cluster, __ = cluster_use_governance temp_template = common.get_test_id(cluster) - exp_error = "" - cm_file = "cost_models_dict.json" - exp_error = "blake2b-cpu-arguments-intercept" update_proposal = [ clusterlib_utils.UpdateProposal( @@ -1593,5 +1595,6 @@ def test_incompatible_cost_models( proposals=update_proposal, prev_action_rec=prev_action_rec, ) - err_str = str(excinfo.value) - assert exp_error in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "blake2b-cpu-arguments-intercept" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py b/cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py index 0f5592f1f..4f396a6e5 100644 --- a/cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py +++ b/cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py @@ -191,8 +191,9 @@ def test_enact_treasury_withdrawals( tx_files=tx_files_action, deposit=actions_deposit_combined + stake_deposit_amt, ) - err_str = str(excinfo.value) - assert "(DisallowedProposalDuringBootstrap" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedProposalDuringBootstrap" in exc_value, exc_value reqc.cip026_03.success() return @@ -205,10 +206,12 @@ def test_enact_treasury_withdrawals( build_method=clusterlib_utils.BuildMethods.BUILD, tx_files=tx_files_action, ) - err_str = str(excinfo.value) - assert ( - "Stake credential specified in the proposal is not registered on-chain" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "Stake credential specified in the proposal is not registered on-chain" + in exc_value + ), exc_value # Make sure we have enough time to submit the proposals in one epoch clusterlib_utils.wait_for_epoch_interval( @@ -349,8 +352,9 @@ def _cast_vote( # Check that SPOs cannot vote on treasury withdrawal action with pytest.raises(clusterlib.CLIError) as excinfo: _cast_vote(approve=False, vote_id="with_spos", add_spo_votes=True) - err_str = str(excinfo.value) - assert "StakePoolVoter" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "StakePoolVoter" in exc_value, exc_value # Vote & disapprove the action _cast_vote(approve=False, vote_id="no") @@ -397,8 +401,9 @@ def _cast_vote( # Try to vote on enacted action with pytest.raises(clusterlib.CLIError) as excinfo: _cast_vote(approve=False, vote_id="enacted") - err_str = str(excinfo.value) - assert "(GovActionsDoNotExist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "GovActionsDoNotExist" in exc_value, exc_value reqc.cip079.start(url=helpers.get_vcs_link()) treasury_finish = clusterlib_utils.get_chain_account_state( @@ -512,8 +517,9 @@ def test_expire_treasury_withdrawals( tx_files=tx_files_action, deposit=actions_deposit_combined + stake_deposit_amt, ) - err_str = str(excinfo.value) - assert "(DisallowedProposalDuringBootstrap" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "DisallowedProposalDuringBootstrap" in exc_value, exc_value return # Make sure we have enough time to submit the proposals in one epoch @@ -812,7 +818,8 @@ def test_mir_certificates( tx_files=tx_files, ) err_build = str(excinfo.value) - assert "TextEnvelope type error:" in err_build, err_build + with common.allow_unstable_error_messages(): + assert "TextEnvelope type error:" in err_build, err_build # The Tx can be build as Babbage Tx using `build-raw`, but cannot be submitted. # TODO: convert to use `compatible babbage transaction signed-transaction` @@ -836,6 +843,9 @@ def test_mir_certificates( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=out_file_signed, txins=tx_output.txins) err_submit = str(excinfo.value) - assert "Error: The era of the node and the tx do not match." in err_submit, err_submit + with common.allow_unstable_error_messages(): + assert "Error: The era of the node and the tx do not match." in err_submit, ( + err_submit + ) reqc.cip070.success() diff --git a/cardano_node_tests/tests/tests_plutus/spend_raw.py b/cardano_node_tests/tests/tests_plutus/spend_raw.py index 97bfb5041..596c7b9de 100644 --- a/cardano_node_tests/tests/tests_plutus/spend_raw.py +++ b/cardano_node_tests/tests/tests_plutus/spend_raw.py @@ -327,7 +327,6 @@ def _spend_locked_txin( # noqa: C901 if expect_failure: with pytest.raises(clusterlib.CLIError) as excinfo: cluster_obj.g_transaction.submit_tx_bare(tx_file=tx_signed) - err = str(excinfo.value) assert cluster_obj.g_query.get_address_balance(dst_addr.address) == dst_init_balance, ( f"Collateral was spent from `{dst_addr.address}`" ) @@ -337,7 +336,7 @@ def _spend_locked_txin( # noqa: C901 f"Inputs were unexpectedly spent for `{u.address}`" ) - return err, tx_raw_output + return str(excinfo.value), tx_raw_output cluster_obj.g_transaction.submit_tx( tx_file=tx_signed, txins=[t.txins[0] for t in tx_raw_output.script_txins if t.txins] diff --git a/cardano_node_tests/tests/tests_plutus/test_mint_negative_build.py b/cardano_node_tests/tests/tests_plutus/test_mint_negative_build.py index bf39fbd9a..3cb8d1738 100644 --- a/cardano_node_tests/tests/tests_plutus/test_mint_negative_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_mint_negative_build.py @@ -179,11 +179,12 @@ def test_witness_redeemer_missing_signer( tx_file=tx_signed_step2, txins=mint_utxos, ) - str_err = str(excinfo.value) - assert ( - "MissingRequiredSigners" in str_err # on node version < 8.8.0 - or "MissingVKeyWitnessesUTXOW" in str_err - ), str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "MissingRequiredSigners" in exc_value # on node version < 8.8.0 + or "MissingVKeyWitnessesUTXOW" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -268,14 +269,14 @@ def test_redeemer_with_simple_minting_script( txouts=txouts, mint=plutus_mint_data, ) - - err_str = str(excinfo.value) - assert ( - 'Error in $: key "description" not found' in err_str # In cli 10.1.1.0+ - or "expected a script in the Plutus script language, but it is actually " - "using SimpleScriptLanguage" - in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + 'Error in $: key "description" not found' in exc_value # In cli 10.1.1.0+ + or "expected a script in the Plutus script language, but it is actually " + "using SimpleScriptLanguage" + in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given( @@ -349,15 +350,17 @@ def test_asset_name_too_long( cluster.g_transaction.calculate_min_req_utxo(txouts=mint_txouts) min_req_utxo_error = str(excinfo.value) - assert ( - "the bytestring should be no longer than 32 bytes long" in min_token_error - or "AssetName deserisalisation failed" in min_token_error - ), min_token_error + with common.allow_unstable_error_messages(): + assert ( + "the bytestring should be no longer than 32 bytes long" in min_token_error + or "AssetName deserisalisation failed" in min_token_error + ), min_token_error - assert ( - "the bytestring should be no longer than 32 bytes long" in min_req_utxo_error - or "AssetName deserisalisation failed" in min_req_utxo_error - ), min_req_utxo_error + with common.allow_unstable_error_messages(): + assert ( + "the bytestring should be no longer than 32 bytes long" in min_req_utxo_error + or "AssetName deserisalisation failed" in min_req_utxo_error + ), min_req_utxo_error @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize( @@ -457,8 +460,9 @@ def test_time_range_missing_tx_validity( mint=plutus_mint_data, invalid_hereafter=None, # Required validity interval is missing here ) - err_str = str(excinfo.value) - assert ( - "following scripts have execution failures" in err_str # In cli 10.1.1.0+ - or "Plutus script evaluation failed" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "following scripts have execution failures" in exc_value # In cli 10.1.1.0+ + or "Plutus script evaluation failed" in exc_value + ), exc_value diff --git a/cardano_node_tests/tests/tests_plutus/test_mint_negative_raw.py b/cardano_node_tests/tests/tests_plutus/test_mint_negative_raw.py index 1c5cbe046..d5e6ac614 100644 --- a/cardano_node_tests/tests/tests_plutus/test_mint_negative_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_mint_negative_raw.py @@ -182,11 +182,12 @@ def test_witness_redeemer_missing_signer( ) with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - str_err = str(excinfo.value) - assert ( - "MissingRequiredSigners" in str_err # on node version < 8.8.0 - or "MissingVKeyWitnessesUTXOW" in str_err - ), str_err + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "MissingRequiredSigners" in exc_value # on node version < 8.8.0 + or "MissingVKeyWitnessesUTXOW" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -280,10 +281,12 @@ def test_low_budget( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert ( - "The budget was overspent" in err_str or "due to overspending the budget" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "The budget was overspent" in exc_value + or "due to overspending the budget" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -378,7 +381,9 @@ def test_low_fee( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - assert "FeeTooSmallUTxO" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "FeeTooSmallUTxO" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(data=st.data()) @@ -495,8 +500,9 @@ def test_execution_units_above_limit( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert "ExUnitsTooBigUTxO" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ExUnitsTooBigUTxO" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize( @@ -602,8 +608,9 @@ def test_time_range_missing_tx_validity( ) with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert "(PlutusFailure" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "PlutusFailure" in exc_value, exc_value class TestNegativeCollateral: @@ -707,7 +714,9 @@ def test_minting_with_invalid_collaterals( # It should NOT be possible to mint with an invalid collateral with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - assert "NoCollateralInputs" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "NoCollateralInputs" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -810,4 +819,6 @@ def test_minting_with_insufficient_collateral( # It should NOT be possible to mint with a collateral with insufficient funds with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - assert "InsufficientCollateral" in str(excinfo.value) + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InsufficientCollateral" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_compat_build.py b/cardano_node_tests/tests/tests_plutus/test_spend_compat_build.py index 2873060a1..e86c9cb85 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_compat_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_compat_build.py @@ -92,5 +92,6 @@ def test_plutusv2_old_tx_era( submit_tx=False, ) - err_str = str(excinfo.value) - assert "PlutusScriptV2 is not supported" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "PlutusScriptV2 is not supported" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_compat_raw.py b/cardano_node_tests/tests/tests_plutus/test_spend_compat_raw.py index 8852d6460..d071cd61f 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_compat_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_compat_raw.py @@ -90,9 +90,9 @@ def test_plutusv2_old_tx_era( plutus_op=plutus_op, amount=amount, ) - - err_str = str(excinfo.value) - assert "PlutusScriptV2 is not supported" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "PlutusScriptV2 is not supported" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( @@ -144,6 +144,6 @@ def test_plutusv1_old_tx_era( plutus_op=plutus_op, amount=amount, ) - - err_str = str(excinfo.value) - assert "PlutusScriptV1 is not supported" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "PlutusScriptV1 is not supported" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_datum_build.py b/cardano_node_tests/tests/tests_plutus/test_spend_datum_build.py index 770825dfe..eccb6d86d 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_datum_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_datum_build.py @@ -274,13 +274,16 @@ def test_no_datum_txout( issues.cli_800.finish_test() if not in_conway_plus: + assert err_str, "Expected error was not raised" if address_type == "script_address": - assert "txin does not have a script datum" in err_str, err_str + with common.allow_unstable_error_messages(): + assert "txin does not have a script datum" in err_str, err_str else: - assert ( - "not a Plutus script witnessed tx input" in err_str - or "points to a script hash that is not known" in err_str - ), err_str + with common.allow_unstable_error_messages(): + assert ( + "not a Plutus script witnessed tx input" in err_str + or "points to a script hash that is not known" in err_str + ), err_str # Check expected fees expected_fee_fund = 199_087 @@ -325,9 +328,9 @@ def test_lock_tx_invalid_datum( plutus_op=plutus_op, amount=100_000, ) - - err_str = str(excinfo.value) - assert "JSON object expected. Unexpected value" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "JSON object expected. Unexpected value" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -388,9 +391,11 @@ def test_unlock_tx_wrong_datum( return issues.cli_800.finish_test() - assert ( - "The Plutus script witness has the wrong datum (according to the UTxO)." in err_str - ), err_str + assert err_str, "Expected error was not raised" + with common.allow_unstable_error_messages(): + assert ( + "The Plutus script witness has the wrong datum (according to the UTxO)." in err_str + ), err_str @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -478,9 +483,9 @@ def test_unlock_non_script_utxo( amount=amount_redeem, submit_tx=False, ) - - err_str = str(excinfo.value) - assert "points to a script hash that is not known" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "points to a script hash that is not known" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(datum_value=st.binary(min_size=65)) diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_datum_raw.py b/cardano_node_tests/tests/tests_plutus/test_spend_datum_raw.py index 80a8e9505..5206ba526 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_datum_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_datum_raw.py @@ -198,11 +198,12 @@ def test_no_datum_txout( amount=amount, ) - err_str = str(excinfo.value) - assert ( - "NonOutputSupplimentaryDatums" in err_str - or "NotAllowedSupplementalDatums" in err_str # on node version >= 8.6.0 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "NonOutputSupplimentaryDatums" in exc_value + or "NotAllowedSupplementalDatums" in exc_value # on node version >= 8.6.0 + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(datum_value=st.text()) @@ -247,9 +248,9 @@ def test_lock_tx_invalid_datum( plutus_op=plutus_op, amount=amount, ) - - err_str = str(excinfo.value) - assert "JSON object expected. Unexpected value" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "JSON object expected. Unexpected value" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -307,11 +308,12 @@ def test_unlock_tx_wrong_datum( amount=amount, ) - err_str = str(excinfo.value) - assert ( - "NonOutputSupplimentaryDatums" in err_str - or "NotAllowedSupplementalDatums" in err_str # on node version >= 8.6.0 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "NonOutputSupplimentaryDatums" in exc_value + or "NotAllowedSupplementalDatums" in exc_value # on node version >= 8.6.0 + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -400,9 +402,9 @@ def test_unlock_non_script_utxo( amount=amount_redeem, tx_files=tx_files_redeem, ) - - err_str = str(excinfo.value) - assert "ExtraneousScriptWitnessesUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ExtraneousScriptWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(datum_value=st.binary(min_size=65)) diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_negative_build.py b/cardano_node_tests/tests/tests_plutus/test_spend_negative_build.py index a56799789..cffc84e81 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_negative_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_negative_build.py @@ -102,8 +102,9 @@ def test_wrong_script( plutus_op=plutus_op2, amount=-1, ) - err_str = str(excinfo.value) - assert "points to a Plutus script that does not exist" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "points to a Plutus script that does not exist" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -156,8 +157,9 @@ def test_no_script( plutus_op=plutus_op2, amount=-1, ) - err_str = str(excinfo.value) - assert "(MissingScriptWitnessesUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "(MissingScriptWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -229,7 +231,9 @@ def test_collateral_w_tokens( if VERSIONS.cli >= version.parse("10.0.0.0"): assert not exc_str, exc_str else: - assert "CollateralContainsNonADA" in exc_str, exc_str + assert exc_str, "Expected error was not raised" + with common.allow_unstable_error_messages(): + assert "CollateralContainsNonADA" in exc_str, exc_str # Check expected fees expected_fee_fund = 173597 @@ -287,15 +291,15 @@ def test_same_collateral_txin( amount=-1, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - "expected to be key witnessed but are actually script witnessed: " - f'["{script_utxos[0].utxo_hash}#{script_utxos[0].utxo_ix}"]' - in err_str - # In 1.35.3 and older - or "Expected key witnessed collateral" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "expected to be key witnessed but are actually script witnessed: " + f'["{script_utxos[0].utxo_hash}#{script_utxos[0].utxo_ix}"]' + in exc_value + # In 1.35.3 and older + or "Expected key witnessed collateral" in exc_value + ), exc_value # Check expected fees expected_fee_fund = 168_845 @@ -376,12 +380,12 @@ def test_invalid_guessing_game( amount=-1, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - "following scripts have execution failures" in err_str # In cli 10.1.1.0+ - or "Plutus script evaluation failed" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "following scripts have execution failures" in exc_value # In cli 10.1.1.0+ + or "Plutus script evaluation failed" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -537,12 +541,12 @@ def test_two_scripts_spending_one_fail( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - - err_str = str(excinfo.value) - assert ( - "following scripts have execution failures" in err_str # In cli 10.1.1.0+ - or "Plutus script evaluation failed" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "following scripts have execution failures" in exc_value # In cli 10.1.1.0+ + or "Plutus script evaluation failed" in exc_value + ), exc_value class TestNegativeRedeemer: @@ -651,14 +655,14 @@ def _int_out_of_range( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - # On node version < 1.36.0 - "Value out of range within the script data" in err_str - # See node commit 2efdd2c173bee8f2463937cebb20614adf6180f0 - or "Incorrect datum" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # On node version < 1.36.0 + "Value out of range within the script data" in exc_value + # See node commit 2efdd2c173bee8f2463937cebb20614adf6180f0 + or "Incorrect datum" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given( @@ -721,12 +725,12 @@ def test_wrong_value_inside_range( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - "following scripts have execution failures" in err_str # In cli 10.1.1.0+ - or "Plutus script evaluation failed" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "following scripts have execution failures" in exc_value # In cli 10.1.1.0+ + or "Plutus script evaluation failed" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.integers(min_value=common.MAX_UINT64 + 1)) @@ -851,9 +855,9 @@ def test_wrong_type( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert "logs: Incorrect datum. Expected 42." in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "logs: Incorrect datum. Expected 42." in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.binary(min_size=65)) @@ -904,12 +908,12 @@ def test_too_big( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - "must consist of at most 64 bytes" in err_str # on node version < 1.36.0 - or "Incorrect datum" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "must consist of at most 64 bytes" in exc_value # on node version < 1.36.0 + or "Incorrect datum" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.binary(max_size=64)) @@ -961,11 +965,12 @@ def test_json_schema_typed_int_bytes_declared( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - 'The value in the field "int" does not have the type required by the schema.' in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + 'The value in the field "int" does not have the type required by the schema.' + in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.binary(max_size=64)) @@ -1017,11 +1022,12 @@ def test_json_schema_untyped_int_bytes_declared( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - 'The value in the field "int" does not have the type required by the schema.' in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + 'The value in the field "int" does not have the type required by the schema.' + in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.integers()) @@ -1073,12 +1079,12 @@ def test_json_schema_typed_bytes_int_declared( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - 'The value in the field "bytes" does not have the type required by the schema.' - in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + 'The value in the field "bytes" does not have the type required by the schema.' + in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.integers()) @@ -1130,12 +1136,12 @@ def test_json_schema_untyped_bytes_int_declared( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - 'The value in the field "bytes" does not have the type required by the schema.' - in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + 'The value in the field "bytes" does not have the type required by the schema.' + in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.text()) @@ -1186,9 +1192,9 @@ def test_invalid_json( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert "JSON object expected. Unexpected value" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "JSON object expected. Unexpected value" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given( @@ -1246,18 +1252,19 @@ def test_json_schema_typed_invalid_type( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - # On node version < 1.36.0 - 'Expected a single field named "int", "bytes", "string", "list" or "map".' in err_str - # See node commit ac662d8e46554c1ed02d485bfdd69e7ec04d8613 - or 'Expected a single field named "int", "bytes", "list" or "map".' in err_str - or ( - redeemer_type in self.KNOWN_FIELDS - and "JSON schema error within the script data" in err_str - ) - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # On node version < 1.36.0 + 'Expected a single field named "int", "bytes", "string", "list" or "map".' + in exc_value + # See node commit ac662d8e46554c1ed02d485bfdd69e7ec04d8613 + or 'Expected a single field named "int", "bytes", "list" or "map".' in exc_value + or ( + redeemer_type in self.KNOWN_FIELDS + and "JSON schema error within the script data" in exc_value + ) + ), exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given( @@ -1315,15 +1322,16 @@ def test_json_schema_untyped_invalid_type( amount=self.AMOUNT, submit_tx=False, ) - - err_str = str(excinfo.value) - assert ( - # On node version < 1.36.0 - 'Expected a single field named "int", "bytes", "string", "list" or "map".' in err_str - # See node commit ac662d8e46554c1ed02d485bfdd69e7ec04d8613 - or 'Expected a single field named "int", "bytes", "list" or "map".' in err_str - or ( - redeemer_type in self.KNOWN_FIELDS - and "JSON schema error within the script data" in err_str - ) - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # On node version < 1.36.0 + 'Expected a single field named "int", "bytes", "string", "list" or "map".' + in exc_value + # See node commit ac662d8e46554c1ed02d485bfdd69e7ec04d8613 + or 'Expected a single field named "int", "bytes", "list" or "map".' in exc_value + or ( + redeemer_type in self.KNOWN_FIELDS + and "JSON schema error within the script data" in exc_value + ) + ), exc_value diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_negative_raw.py b/cardano_node_tests/tests/tests_plutus/test_spend_negative_raw.py index a7941719e..607f460bb 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_negative_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_negative_raw.py @@ -162,7 +162,9 @@ def test_invalid_guessing_game( expect_failure=True, ) - assert "ValidationTagMismatch (IsValid True)" in err, err + assert err, "Expected failure did not happen" + with common.allow_unstable_error_messages(): + assert "ValidationTagMismatch (IsValid True)" in err, err @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -216,11 +218,12 @@ def test_wrong_script( plutus_op=plutus_op2, amount=amount, ) - err_str = str(excinfo.value) - assert ( - "(MissingScriptWitnessesUTXOW" in err_str - and " (ExtraneousScriptWitnessesUTXOW" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "(MissingScriptWitnessesUTXOW" in exc_value + and " (ExtraneousScriptWitnessesUTXOW" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS_VERSION @@ -272,8 +275,9 @@ def test_no_script( plutus_op=plutus_op2, amount=amount, ) - err_str = str(excinfo.value) - assert "(MissingScriptWitnessesUTXOW" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "MissingScriptWitnessesUTXOW" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -338,9 +342,9 @@ def test_collateral_w_tokens( plutus_op=plutus_op, amount=amount, ) - - err_str = str(excinfo.value) - assert "CollateralContainsNonADA" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "CollateralContainsNonADA" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -392,9 +396,11 @@ def test_same_collateral_txin( plutus_op=plutus_op, amount=amount, ) - err_str = str(excinfo.value) - assert "transaction submit" in err_str, err_str - assert "ScriptsNotPaidUTxO" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "transaction submit" in exc_value, exc_value + with common.allow_unstable_error_messages(): + assert "ScriptsNotPaidUTxO" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -451,9 +457,9 @@ def test_collateral_percent( plutus_op=plutus_op, amount=amount, ) - - err_str = str(excinfo.value) - assert "InsufficientCollateral" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InsufficientCollateral" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -606,16 +612,16 @@ def test_two_scripts_spending_one_fail( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx_bare(tx_file=tx_signed_redeem) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) script2_hash = helpers.decode_bech32(bech32=script_address2)[2:] if not ( - rf"ScriptHash \"{script2_hash}\") fails" in err_str # node < 8.10.0 - or f'The script hash is:ScriptHash \\"{script2_hash}\\"' in err_str + rf"ScriptHash \"{script2_hash}\") fails" in exc_value # node < 8.10.0 + or f'The script hash is:ScriptHash \\"{script2_hash}\\"' in exc_value ): # Try matching the error message with base64 encoded binary script instead script2_base64 = clusterlib_utils.get_plutus_b64(script_file=plutus_op2.script_file) - assert rf"script failed:\n\"{script2_base64}\"" in err_str, err_str + assert rf"script failed:\n\"{script2_base64}\"" in exc_value, exc_value issues.ledger_3731.finish_test() @allure.link(helpers.get_vcs_link()) @@ -685,8 +691,9 @@ def test_execution_units_above_limit( plutus_op=plutus_op, amount=amount, ) - err_str = str(excinfo.value) - assert "ExUnitsTooBigUTxO" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ExUnitsTooBigUTxO" in exc_value, exc_value class TestNegativeRedeemer: @@ -1004,9 +1011,9 @@ def test_wrong_value_inside_range( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx_bare(tx_file=tx_signed) - - err_str = str(excinfo.value) - assert "ValidationTagMismatch (IsValid True)" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ValidationTagMismatch (IsValid True)" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.integers(max_value=MIN_INT_VAL - 1)) @@ -1179,9 +1186,9 @@ def test_wrong_type( with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx_bare(tx_file=tx_signed) - - err_str = str(excinfo.value) - assert "ValidationTagMismatch (IsValid True)" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ValidationTagMismatch (IsValid True)" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(redeemer_value=st.binary(min_size=65)) @@ -1459,7 +1466,9 @@ def test_invalid_json( cost_per_unit=cost_per_unit, plutus_version=plutus_version, ) - assert "Invalid JSON format" in err, err + assert err, "Expected failure when using invalid JSON format for redeemer" + with common.allow_unstable_error_messages(): + assert "Invalid JSON format" in err, err @allure.link(helpers.get_vcs_link()) @hypothesis.given( diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_raw.py b/cardano_node_tests/tests/tests_plutus/test_spend_raw.py index b592b4a24..c39fc760e 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_raw.py @@ -681,7 +681,9 @@ def test_always_fails( amount=amount, expect_failure=True, ) - assert "PlutusFailure" in err, err + assert err, "The script spending was expected to fail." + with common.allow_unstable_error_messages(): + assert "PlutusFailure" in err, err @allure.link(helpers.get_vcs_link()) @common.PARAM_PLUTUS3_VERSION @@ -998,8 +1000,8 @@ def test_collaterals( plutus_op=plutus_op, amount=amount, ) - err_str = str(excinfo.value) - assert any(e in err_str for e in exp_errors), err_str + exc_value = str(excinfo.value) + assert any(e in exc_value for e in exp_errors), exc_value else: spend_raw._spend_locked_txin( temp_template=temp_template, diff --git a/cardano_node_tests/tests/tests_plutus_v2/mint_raw.py b/cardano_node_tests/tests/tests_plutus_v2/mint_raw.py index 232eb4781..f5f883c13 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/mint_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/mint_raw.py @@ -211,9 +211,13 @@ def _check_txout() -> None: cost_model_len = len(pv2_cost_model) if prot_ver < 10: - assert "(MalformedScriptWitnesses" in err, err + assert err, "Transaction succeeded but expected to fail" + with common.allow_unstable_error_messages(): + assert "MalformedScriptWitnesses" in err, err elif cost_model_len < 185 or pv2_cost_model[-1] == 9223372036854775807: - assert "overspending the budget" in err, err + assert err, "Transaction succeeded but expected to fail" + with common.allow_unstable_error_messages(): + assert "overspending the budget" in err, err elif not err: _check_txout() else: diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_build.py index 3aa1bcd69..e3b04eef7 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_build.py @@ -463,9 +463,9 @@ def test_reference_inputs_visibility( txouts=txouts_step2, mint=plutus_mint_data, ) - err_str = str(excinfo.value) - - assert "Reference inputs do not match redeemer" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Reference inputs do not match redeemer" in exc_value, exc_value return tx_output_step2 = cluster.g_transaction.build_tx( @@ -591,9 +591,9 @@ def test_reference_scripts_visibility( txouts=txouts_step2, mint=plutus_mint_data, ) - err_str = str(excinfo.value) - - assert "Unexpected reference script at each reference input" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Unexpected reference script at each reference input" in exc_value, exc_value return tx_output_step2 = cluster.g_transaction.build_tx( @@ -736,8 +736,9 @@ def test_inline_datum_visibility( mint=plutus_mint_data, readonly_reference_txins=reference_input, ) - err_str = str(excinfo.value) - assert "Unexpected inline datum at each reference input" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Unexpected inline datum at each reference input" in exc_value, exc_value return tx_output_step2 = cluster.g_transaction.build_tx( diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_build.py index 4ca3ce191..98c6485c1 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_build.py @@ -147,5 +147,6 @@ def test_minting_with_unbalanced_total_collateral( # It should NOT be possible to mint with an unbalanced total collateral with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert "IncorrectTotalCollateralField" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "IncorrectTotalCollateralField" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_raw.py index 5b97881b3..65a6eedbb 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_negative_raw.py @@ -149,8 +149,9 @@ def test_minting_with_limited_collateral( # It should NOT be possible to mint with a collateral with insufficient funds with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert "InsufficientCollateral" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InsufficientCollateral" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize( @@ -257,5 +258,6 @@ def test_minting_with_unbalanced_total_collateral( # It should NOT be possible to mint with an unbalanced total collateral with pytest.raises(clusterlib.CLIError) as excinfo: cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - err_str = str(excinfo.value) - assert "IncorrectTotalCollateralField" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "IncorrectTotalCollateralField" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_raw.py index 27fea3369..660322e42 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_raw.py @@ -342,13 +342,13 @@ def test_datum_hash_visibility( mint=plutus_mint_data, readonly_reference_txins=reference_input, ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) - if "Unexpected datum hash at each reference input" not in err_str: - if "The machine terminated because of an error" in err_str: + if "Unexpected datum hash at each reference input" not in exc_value: + if "The machine terminated because of an error" in exc_value: issues.node_4488.finish_test() - pytest.fail(f"Unexpected error message: {err_str}") + pytest.fail(f"Unexpected error message: {exc_value}") return diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_build.py index 09c14fcd1..8e0a27771 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_build.py @@ -244,26 +244,26 @@ def test_negative_secp_builtin_functions( redeemer_file=redeemer_file, ) - err_msg = str(excinfo.value) + exc_value = str(excinfo.value) # Before protocol version 8 the SECP256k1 is blocked. # After that the usage is limited by high cost model. is_forbidden = ( "Forbidden builtin function: (builtin " f"verify{algorithm.capitalize()}Secp256k1Signature)" - in err_msg + in exc_value or f"Builtin function Verify{algorithm.capitalize()}Secp256k1Signature " "is not available in language PlutusV2 at and protocol version 7.0" - in err_msg + in exc_value ) is_overspending = ( "The machine terminated part way through evaluation due to " - "overspending the budget." in err_msg + "overspending the budget." in exc_value ) if before_pv8: - assert is_forbidden or is_overspending, err_msg + assert is_forbidden or is_overspending, exc_value # From protocol version 8 the SECP256k1 functions are allowed and # when we provide wrong data meaningful error messages are expected. elif plutus_version == "v2": @@ -276,7 +276,7 @@ def test_negative_secp_builtin_functions( "no_pubkey": "Invalid verification key", "no_sig": "Invalid signature", } - assert expected_error_messages[test_vector] in err_msg, err_msg + assert expected_error_messages[test_vector] in exc_value, exc_value elif plutus_version == "v3": # PT5: PlutusTx.Prelude.check: input is 'False'. The untyped script we use for # PlutusV3 is different from the PlutusV2 script, and doesn't produce the same error diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_raw.py index 780eea2ba..deef42755 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_mint_secp256k1_raw.py @@ -222,16 +222,15 @@ def test_negative_secp_builtin_functions( script_file=script_file, redeemer_file=redeemer_file, ) - - err_msg = str(excinfo.value) + exc_value = str(excinfo.value) # Before protocol version 8 the SECP256k1 is blocked. # After that the usage is limited by high cost model. - is_forbidden = "MalformedScriptWitnesses" in err_msg + is_forbidden = "MalformedScriptWitnesses" in exc_value is_overspending = ( "The machine terminated part way through evaluation due to " - "overspending the budget." in err_msg + "overspending the budget." in exc_value ) # From protocol version 8 the SECP256k1 functions are allowed @@ -251,7 +250,7 @@ def test_negative_secp_builtin_functions( } if before_pv8: - assert is_forbidden or is_overspending, err_msg + assert is_forbidden or is_overspending, exc_value else: - assert re.search(expected_error_messages[test_vector], err_msg), err_msg - # Assert expected_error_messages[test_vector] in err_msg, err_msg + assert re.search(expected_error_messages[test_vector], exc_value), exc_value + # Assert expected_error_messages[test_vector] in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_build.py index d7266e12b..c30b3ca0b 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_build.py @@ -177,5 +177,6 @@ def test_ro_reference_old_tx_era( txouts=txouts, readonly_reference_txins=reference_input, ) - err_str = str(excinfo.value) - assert "Reference inputs cannot be used" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Reference inputs cannot be used" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_raw.py index 20396cf3e..fc00cc9b4 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_compat_raw.py @@ -196,5 +196,6 @@ def test_ro_reference_old_tx_era( readonly_reference_txins=reference_input, tx_files=tx_files, ) - err_str = str(excinfo.value) - assert "Reference inputs cannot be used" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Reference inputs cannot be used" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_build.py index 1292f0b04..21aefb490 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_build.py @@ -215,8 +215,9 @@ def test_lock_tx_invalid_datum( plutus_op=plutus_op, amount=1_000_000, ) - err_str = str(excinfo.value) - assert "JSON object expected. Unexpected value" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "JSON object expected. Unexpected value" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -295,8 +296,9 @@ def test_lock_tx_v1_script( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert "InlineDatumsNotSupported" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InlineDatumsNotSupported" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(datum_content=st.text(alphabet=string.ascii_letters, min_size=65)) @@ -432,8 +434,9 @@ def test_lock_tx_datum_as_witness( tx_file=tx_signed, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert ( - "NonOutputSupplimentaryDatums" in err_str - or "NotAllowedSupplementalDatums" in err_str # on node version >= 8.6.0 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "NonOutputSupplimentaryDatums" in exc_value + or "NotAllowedSupplementalDatums" in exc_value # on node version >= 8.6.0 + ), exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_raw.py index a1cba6188..ac2791dab 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_datum_raw.py @@ -125,8 +125,9 @@ def test_lock_tx_invalid_datum( redeem_cost=redeem_cost, use_inline_datum=True, ) - err_str = str(excinfo.value) - assert "JSON object expected. Unexpected value" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "JSON object expected. Unexpected value" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -212,8 +213,9 @@ def test_lock_tx_v1_script( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert "InlineDatumsNotSupported" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "InlineDatumsNotSupported" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @hypothesis.given(datum_content=st.text(alphabet=string.ascii_letters, min_size=65)) @@ -349,8 +351,9 @@ def test_lock_tx_datum_as_witness( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert ( - "NonOutputSupplimentaryDatums" in err_str - or "NotAllowedSupplementalDatums" in err_str # on node version >= 8.6.0 - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "NonOutputSupplimentaryDatums" in exc_value + or "NotAllowedSupplementalDatums" in exc_value # on node version >= 8.6.0 + ), exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_build.py index 9fd15c1be..6c479bf50 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_build.py @@ -540,17 +540,19 @@ def test_reference_spent_output( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert ( - # TODO: in 1.35.3 and older - cardano-node issue #4012 - f"following tx input(s) were not present in the UTxO: \n{reference_input[0].utxo_hash}" - in err_str - or re.search( - "TranslationLogicMissingInput .*unTxId = SafeHash " - f'"{reference_input[0].utxo_hash}"', - err_str, - ) - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + # TODO: in 1.35.3 and older - cardano-node issue #4012 + "following tx input(s) were not present in the UTxO:" + f" \n{reference_input[0].utxo_hash}" + in exc_value + or re.search( + "TranslationLogicMissingInput .*unTxId = SafeHash " + f'"{reference_input[0].utxo_hash}"', + exc_value, + ) + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -687,5 +689,6 @@ def test_reference_input_without_spend_anything( str(cluster.network_magic), ] ) - err_str = str(excinfo.value) - assert re.search(r"Missing: *\(--tx-in TX[_-]IN", err_str), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Missing: *\(--tx-in TX[_-]IN", exc_value), exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_raw.py index 7bd01064b..b1af8bf2c 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_inputs_raw.py @@ -413,11 +413,13 @@ def test_reference_spent_output( join_txouts=False, script_txins=plutus_txins, ) - err_str = str(excinfo.value) - assert re.search( - f'TranslationLogicMissingInput .*unTxId = SafeHash "{reference_input[0].utxo_hash}"', - err_str, - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search( + "TranslationLogicMissingInput " + f'.*unTxId = SafeHash "{reference_input[0].utxo_hash}"', + exc_value, + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -550,5 +552,6 @@ def test_reference_input_without_spend_anything( f"{temp_template}_tx.body", ] ) - err_str = str(excinfo.value) - assert re.search(r"Missing: *\(--tx-in TX[_-]IN", err_str), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert re.search(r"Missing: *\(--tx-in TX[_-]IN", exc_value), exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_build.py index 32bd132a9..a7dfd6a4a 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_build.py @@ -763,8 +763,9 @@ def test_not_a_script( amount=100_000, use_reference_script=True, ) - err_str = str(excinfo.value) - assert "Syntax error in script" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Syntax error in script" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -919,11 +920,12 @@ def test_two_scripts_one_fail( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert ( - "following scripts have execution failures" in err_str # In cli 10.1.1.0+ - or "Plutus script evaluation failed" in err_str - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "following scripts have execution failures" in exc_value # In cli 10.1.1.0+ + or "Plutus script evaluation failed" in exc_value + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1006,11 +1008,12 @@ def test_lock_tx_v1_reference_script( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert ( - "ReferenceInputsNotSupported" in err_str - or "InlineDatumsNotSupported" in err_str # in Conway - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "ReferenceInputsNotSupported" in exc_value + or "InlineDatumsNotSupported" in exc_value # in Conway + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1161,11 +1164,12 @@ def test_v1_attached_v2_reference( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert ( - "ReferenceInputsNotSupported" in err_str - or "InlineDatumsNotSupported" in err_str # in Conway - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "ReferenceInputsNotSupported" in exc_value + or "InlineDatumsNotSupported" in exc_value # in Conway + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1258,5 +1262,6 @@ def test_lock_byron_reference_script( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) - assert "ByronTxOutInContext" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ByronTxOutInContext" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_raw.py index d5abbd1d5..3dab0c028 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_ref_scripts_raw.py @@ -716,8 +716,9 @@ def test_not_a_script( amount=amount, redeem_cost=redeem_cost, ) - err_str = str(excinfo.value) - assert "Syntax error in script" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "Syntax error in script" in exc_value, exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -864,16 +865,16 @@ def test_two_scripts_one_fail( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) script2_hash = helpers.decode_bech32(bech32=script_address_2)[2:] if not ( - rf"ScriptHash \"{script2_hash}\") fails" in err_str # node < 8.10.0 - or f'The script hash is:ScriptHash \\"{script2_hash}\\"' in err_str + rf"ScriptHash \"{script2_hash}\") fails" in exc_value # node < 8.10.0 + or f'The script hash is:ScriptHash \\"{script2_hash}\\"' in exc_value ): # Try matching the error message with base64 encoded binary script instead script2_base64 = clusterlib_utils.get_plutus_b64(script_file=plutus_op2.script_file) - assert rf"script failed:\n\"{script2_base64}\"" in err_str, err_str + assert rf"script failed:\n\"{script2_base64}\"" in exc_value, exc_value issues.ledger_3731.finish_test() @allure.link(helpers.get_vcs_link()) @@ -964,11 +965,12 @@ def test_lock_tx_v1_reference_script( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert ( - "ReferenceInputsNotSupported" in err_str - or "InlineDatumsNotSupported" in err_str # in Conway - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "ReferenceInputsNotSupported" in exc_value + or "InlineDatumsNotSupported" in exc_value # in Conway + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1114,11 +1116,12 @@ def test_v1_attached_v2_reference( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert ( - "ReferenceInputsNotSupported" in err_str - or "InlineDatumsNotSupported" in err_str # in Conway - ), err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert ( + "ReferenceInputsNotSupported" in exc_value + or "InlineDatumsNotSupported" in exc_value # in Conway + ), exc_value @allure.link(helpers.get_vcs_link()) @pytest.mark.smoke @@ -1219,5 +1222,6 @@ def test_lock_byron_reference_script( tx_file=tx_signed_redeem, txins=[t.txins[0] for t in tx_output_redeem.script_txins if t.txins], ) - err_str = str(excinfo.value) - assert "ByronTxOutInContext" in err_str, err_str + exc_value = str(excinfo.value) + with common.allow_unstable_error_messages(): + assert "ByronTxOutInContext" in exc_value, exc_value diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_secp256k1_build.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_secp256k1_build.py index 222e862e8..42c7c4aeb 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_secp256k1_build.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_secp256k1_build.py @@ -319,10 +319,10 @@ def test_overspending_execution_budget( script_txins=plutus_txins, change_address=payment_addrs[0].address, ) - err_str = str(excinfo.value) + exc_value = str(excinfo.value) - if "Negative numbers indicate the overspent budget" not in err_str: + if "Negative numbers indicate the overspent budget" not in exc_value: plutus_common.xfail_on_secp_error( - cluster_obj=cluster, algorithm=algorithm, err_msg=err_str + cluster_obj=cluster, algorithm=algorithm, err_msg=exc_value ) - pytest.fail(f"Unexpected error message: {err_str}") + pytest.fail(f"Unexpected error message: {exc_value}")