Skip to content

Commit e55beed

Browse files
authored
Merge pull request #1199 from saratomaz/update_tx_view_check_reference_inputs
Update tx view to check reference inputs
2 parents c792465 + 0eb70e8 commit e55beed

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cardano_node_tests/utils/tx_view.py

+25
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ def _check_collateral_inputs(
112112
return collateral_strings == set(expected_collateral)
113113

114114

115+
def _check_reference_inputs(
116+
tx_raw_output: clusterlib.TxRawOutput, expected_reference_inputs: List[str]
117+
) -> bool:
118+
"""Check reference inputs of tx_view."""
119+
reference_scripts = [
120+
s.reference_txin for s in tx_raw_output.script_txins if getattr(s, "reference_txin", None)
121+
]
122+
123+
all_reference_inputs: List[Any] = [
124+
*(tx_raw_output.readonly_reference_txins or []),
125+
*(reference_scripts or []),
126+
]
127+
128+
reference_strings = {f"{r.utxo_hash}#{r.utxo_ix}" for r in all_reference_inputs}
129+
130+
return reference_strings == set(expected_reference_inputs)
131+
132+
115133
def check_tx_view( # noqa: C901
116134
cluster_obj: clusterlib.ClusterLib, tx_raw_output: clusterlib.TxRawOutput
117135
) -> dict:
@@ -243,4 +261,11 @@ def check_tx_view( # noqa: C901
243261
):
244262
raise AssertionError("collateral inputs are not the expected")
245263

264+
# check reference inputs, this is only available on Babbage+ TX
265+
if loaded_tx_version >= VERSIONS.BABBAGE and not _check_reference_inputs(
266+
tx_raw_output=tx_raw_output,
267+
expected_reference_inputs=tx_loaded.get("reference inputs") or [],
268+
):
269+
raise AssertionError("reference inputs are not the expected")
270+
246271
return tx_loaded

0 commit comments

Comments
 (0)