@@ -112,6 +112,24 @@ def _check_collateral_inputs(
112
112
return collateral_strings == set (expected_collateral )
113
113
114
114
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
+
115
133
def check_tx_view ( # noqa: C901
116
134
cluster_obj : clusterlib .ClusterLib , tx_raw_output : clusterlib .TxRawOutput
117
135
) -> dict :
@@ -243,4 +261,11 @@ def check_tx_view( # noqa: C901
243
261
):
244
262
raise AssertionError ("collateral inputs are not the expected" )
245
263
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
+
246
271
return tx_loaded
0 commit comments