Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions cardano_node_tests/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from cardano_node_tests.utils import configuration
from cardano_node_tests.utils import helpers
from cardano_node_tests.utils import pytest_utils
from cardano_node_tests.utils import types as ttypes
from cardano_node_tests.utils.versions import VERSIONS

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -621,21 +620,3 @@ def allow_unstable_error_messages() -> tp.Iterator[None]:
yield
except AssertionError:
LOGGER.exception("AssertionError suppressed")


def check_reference_script_policyid(
name_template: str,
cluster_obj: clusterlib.ClusterLib,
script_file: ttypes.FileType,
script_data: dict,
) -> None:
"""Check that the policy ID of a reference script file matches the original script policy ID."""
policyid_file = cluster_obj.g_transaction.get_policyid(script_file=script_file)
policyid_data = clusterlib_utils.get_script_data_policyid(
cluster_obj=cluster_obj,
script_name=name_template,
script_data=script_data,
)
assert policyid_file == policyid_data, (
f"Reference script hash mismatch: file '{policyid_file}' vs data '{policyid_data}'"
)
2 changes: 1 addition & 1 deletion cardano_node_tests/tests/test_native_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,7 @@ def test_script_reference_utxo(
assert reference_utxo.reference_script
has_issue_1332 = False
try:
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=script,
Expand Down
4 changes: 2 additions & 2 deletions cardano_node_tests/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ def test_script_reference_utxo(
assert reference_utxo.reference_script
has_issue_1332 = False
try:
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=multisig_script,
Expand Down Expand Up @@ -2640,7 +2640,7 @@ def test_spend_reference_script(
assert reference_utxo.reference_script
has_issue_1332 = False
try:
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=multisig_script,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def test_spend_reference_script(
)
assert reference_utxo.amount == amount, "Incorrect amount transferred"
assert reference_utxo.reference_script, "Reference script is missing"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=script_file,
Expand Down Expand Up @@ -703,7 +703,7 @@ def test_spend_regular_utxo_and_reference_script(
)
reference_script = clusterlib.filter_utxos(utxos=out_utxos_step1, utxo_ix=utxo_ix_offset)
assert reference_script[0].reference_script, "No reference script UTxO"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=plutus_op.script_file,
Expand Down Expand Up @@ -1235,7 +1235,7 @@ def test_lock_byron_reference_script(
)
assert reference_utxo.address == byron_addr.address, "Incorrect address for reference UTxO"
assert reference_utxo.reference_script, "Reference script is missing"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=plutus_op.script_file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def test_spend_reference_script(
)
assert reference_utxo.amount == amount, "Incorrect amount transferred"
assert reference_utxo.reference_script, "Reference script is missing"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=script_file,
Expand Down Expand Up @@ -621,7 +621,7 @@ def test_spend_regular_utxo_and_reference_script(
txid = cluster.g_transaction.get_txid(tx_body_file=tx_output_step1.out_file)
reference_script = cluster.g_query.get_utxo(txin=f"{txid}#0")
assert reference_script[0].reference_script, "No reference script UTxO"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=plutus_op.script_file,
Expand Down Expand Up @@ -682,7 +682,7 @@ def test_reference_script_byron_address(

assert reference_utxo.address == byron_addr.address, "Incorrect address for reference UTxO"
assert reference_utxo.reference_script, "Reference script is missing"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=script_file,
Expand Down Expand Up @@ -1200,7 +1200,7 @@ def test_lock_byron_reference_script(
)
assert reference_utxo.address == byron_addr.address, "Incorrect address for reference UTxO"
assert reference_utxo.reference_script, "Reference script is missing"
common.check_reference_script_policyid(
clusterlib_utils.check_reference_script_policyid(
name_template=f"{temp_template}_check",
cluster_obj=cluster,
script_file=plutus_op.script_file,
Expand Down
18 changes: 18 additions & 0 deletions cardano_node_tests/utils/clusterlib_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,3 +1633,21 @@ def get_script_data_policyid(
with open(script_file, "w", encoding="utf-8") as outfile:
json.dump(script_data, outfile)
return cluster_obj.g_transaction.get_policyid(script_file=script_file)


def check_reference_script_policyid(
name_template: str,
cluster_obj: clusterlib.ClusterLib,
script_file: cl_types.FileType,
script_data: dict,
) -> None:
"""Check that the policy ID of a reference script file matches the original script policy ID."""
policyid_file = cluster_obj.g_transaction.get_policyid(script_file=script_file)
policyid_data = get_script_data_policyid(
cluster_obj=cluster_obj,
script_name=name_template,
script_data=script_data,
)
if policyid_file != policyid_data:
msg = f"Reference script hash mismatch: file '{policyid_file}' vs data '{policyid_data}'"
raise AssertionError(msg)
Loading