From 555ff8871ad82ac0d6abb866ced4407c3bb8ff0a Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Tue, 10 Nov 2026 16:50:05 +0100 Subject: [PATCH] fix: handle unsupported script-invalid builds Add a specialized wrapper for Dijkstra builds that reject the --script-invalid option, routing only that error to node issue 6748 and re-raising unrelated CLI errors. Wrap both raw collateral transaction builds so the error is handled before signing or submission. Keep submission handling unchanged. Validation: make lint passed. E2E tests were not run. --- cardano_node_tests/tests/plutus_common.py | 17 ++++++++ .../test_spend_collateral_raw.py | 42 ++++++++++--------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/cardano_node_tests/tests/plutus_common.py b/cardano_node_tests/tests/plutus_common.py index 0ceff9e98..09d8c44e0 100644 --- a/cardano_node_tests/tests/plutus_common.py +++ b/cardano_node_tests/tests/plutus_common.py @@ -365,6 +365,23 @@ class PlutusScriptData: TIMERANGE_SLOTS_OFFSET_TESTNET = 3_000 +def run_with_script_invalid_arg_check[T](func: tp.Callable[[], T]) -> T: + """Run a build, handling only Dijkstra's unsupported script-invalid option. + + Return the callable's result on success. Fail or xfail for node issue 6748 + when the CLI rejects the option in Dijkstra. Re-raise any unrelated CLI error. + """ + try: + return func() + except clusterlib.CLIError as exc: + if ( + VERSIONS.cluster_era >= VERSIONS.DIJKSTRA_FIRST + and "Invalid option `--script-invalid'" in str(exc) + ): + issues.node_6748.finish_test() + raise + + def run_with_invalid_script_check[T](func: tp.Callable[[], T]) -> T: """Run a callable, handling known phase-2-invalid transaction errors. diff --git a/cardano_node_tests/tests/tests_plutus_v2/test_spend_collateral_raw.py b/cardano_node_tests/tests/tests_plutus_v2/test_spend_collateral_raw.py index 628c3fdbd..790383c90 100644 --- a/cardano_node_tests/tests/tests_plutus_v2/test_spend_collateral_raw.py +++ b/cardano_node_tests/tests/tests_plutus_v2/test_spend_collateral_raw.py @@ -139,15 +139,17 @@ def test_with_total_return_collateral( ), ] - tx_output_redeem = cluster.g_transaction.build_raw_tx_bare( - out_file=f"{temp_template}_step2_tx.body", - txouts=txouts_redeem, - tx_files=tx_files_redeem, - fee=redeem_cost.fee + spend_raw.FEE_REDEEM_TXSIZE, - script_txins=plutus_txins, - script_valid=False, - return_collateral_txouts=txouts_return_collateral if use_return_collateral else (), - total_collateral_amount=redeem_cost.collateral if use_total_collateral else None, + tx_output_redeem = plutus_common.run_with_script_invalid_arg_check( + func=lambda: cluster.g_transaction.build_raw_tx_bare( + out_file=f"{temp_template}_step2_tx.body", + txouts=txouts_redeem, + tx_files=tx_files_redeem, + fee=redeem_cost.fee + spend_raw.FEE_REDEEM_TXSIZE, + script_txins=plutus_txins, + script_valid=False, + return_collateral_txouts=txouts_return_collateral if use_return_collateral else (), + total_collateral_amount=redeem_cost.collateral if use_total_collateral else None, + ) ) tx_signed_redeem = cluster.g_transaction.sign_tx( tx_body_file=tx_output_redeem.out_file, @@ -296,16 +298,18 @@ def test_collateral_with_tokens( ), ] - tx_output_redeem = cluster.g_transaction.build_raw_tx_bare( - out_file=f"{temp_template}_step2_tx.body", - txouts=txouts_redeem, - tx_files=tx_files_redeem, - fee=redeem_cost.fee + spend_raw.FEE_REDEEM_TXSIZE, - script_txins=plutus_txins, - script_valid=False, - return_collateral_txouts=txouts_return_collateral, - total_collateral_amount=redeem_cost.collateral, - join_txouts=False, + tx_output_redeem = plutus_common.run_with_script_invalid_arg_check( + func=lambda: cluster.g_transaction.build_raw_tx_bare( + out_file=f"{temp_template}_step2_tx.body", + txouts=txouts_redeem, + tx_files=tx_files_redeem, + fee=redeem_cost.fee + spend_raw.FEE_REDEEM_TXSIZE, + script_txins=plutus_txins, + script_valid=False, + return_collateral_txouts=txouts_return_collateral, + total_collateral_amount=redeem_cost.collateral, + join_txouts=False, + ) ) tx_signed_redeem = cluster.g_transaction.sign_tx( tx_body_file=tx_output_redeem.out_file,