Skip to content

Commit

Permalink
Fix tests after removal of unnecessary validation of Data
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoura committed Mar 17, 2023
1 parent 07f7961 commit 15607a6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
Expand Up @@ -521,7 +521,12 @@ def _int_out_of_range(
)

err_str = str(excinfo.value)
assert "Value out of range within the script data" in err_str, err_str
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

@allure.link(helpers.get_vcs_link())
@hypothesis.given(
Expand Down
33 changes: 25 additions & 8 deletions cardano_node_tests/tests/tests_plutus/test_spend_negative_raw.py
Expand Up @@ -728,7 +728,7 @@ def _int_out_of_range(
dst_addr: clusterlib.AddressRecord,
cost_per_unit: plutus_common.ExecutionCost,
plutus_version: str,
):
) -> str:
"""Try to spend a locked UTxO with redeemer int value that is not in allowed range."""
redeemer_content = {}
if redeemer_value % 2 == 0:
Expand Down Expand Up @@ -765,16 +765,19 @@ def _int_out_of_range(
)
]

with pytest.raises(clusterlib.CLIError) as excinfo:
err_str = ""
try:
cluster_obj.g_transaction.build_raw_tx_bare(
out_file=f"{temp_template}_step2_tx.body",
txouts=txouts,
tx_files=tx_files,
fee=fee_redeem + spend_raw.FEE_REDEEM_TXSIZE,
script_txins=plutus_txins,
)
err_str = str(excinfo.value)
assert "Value out of range within the script data" in err_str, err_str
except clusterlib.CLIError as exc:
err_str = str(exc)

return err_str

@allure.link(helpers.get_vcs_link())
@hypothesis.given(
Expand Down Expand Up @@ -880,7 +883,7 @@ def test_wrong_value_bellow_range(
):
"""Try to spend a locked UTxO with a redeemer int value < minimum allowed value.
Expect failure.
Expect failure on node version < 1.36.0.
"""
temp_template = f"{common.get_test_id(cluster)}_{plutus_version}_{common.unique_time_str()}"

Expand All @@ -889,7 +892,7 @@ def test_wrong_value_bellow_range(
)

script_utxos, collateral_utxos, payment_addrs = fund_script_guessing_game
self._int_out_of_range(
err_str = self._int_out_of_range(
cluster_obj=cluster,
temp_template=temp_template,
script_utxos=script_utxos,
Expand All @@ -900,6 +903,13 @@ def test_wrong_value_bellow_range(
plutus_version=plutus_version,
)

assert (
# See node commit 2efdd2c173bee8f2463937cebb20614adf6180f0
not err_str
# On node version < 1.36.0
or "Value out of range within the script data" in err_str
), err_str

@allure.link(helpers.get_vcs_link())
@hypothesis.given(redeemer_value=st.integers(min_value=common.MAX_UINT64 + 1))
@hypothesis.example(redeemer_value=common.MAX_UINT64 + 1)
Expand All @@ -916,7 +926,7 @@ def test_wrong_value_above_range(
):
"""Try to spend a locked UTxO with a redeemer int value > maximum allowed value.
Expect failure.
Expect failure on node version < 1.36.0.
"""
temp_template = f"{common.get_test_id(cluster)}_{plutus_version}_{common.unique_time_str()}"

Expand All @@ -925,7 +935,7 @@ def test_wrong_value_above_range(
)

script_utxos, collateral_utxos, payment_addrs = fund_script_guessing_game
self._int_out_of_range(
err_str = self._int_out_of_range(
cluster_obj=cluster,
temp_template=temp_template,
script_utxos=script_utxos,
Expand All @@ -936,6 +946,13 @@ def test_wrong_value_above_range(
plutus_version=plutus_version,
)

assert (
# See node commit 2efdd2c173bee8f2463937cebb20614adf6180f0
not err_str
# On node version < 1.36.0
or "Value out of range within the script data" in err_str
), err_str

@allure.link(helpers.get_vcs_link())
@hypothesis.given(redeemer_value=st.binary(max_size=64))
@common.hypothesis_settings(max_examples=200)
Expand Down

0 comments on commit 15607a6

Please sign in to comment.