From 2bb9896c9f3cfcd63675e1e6a09a38098e640299 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 9 Mar 2026 17:35:01 +0100 Subject: [PATCH] feat: remove context equivalence Plutus tests and related scripts The working version of `create-script-context` tool is not available for several years, and the https://github.com/IntersectMBO/plutus-apps repo where the tool comes from is archived. The tests relying on the tool have been disabled for a long time. - Remove all tests and code related to "context equivalence" for Plutus scripts, including: - Test cases for context equivalence in minting and spending (build and build-raw flows) - Associated Plutus scripts and test data files - Helper functions and constants for context equivalence - The `.github/source_plutus_apps.sh` script and related setup logic - The `create_script_context` utility function - Clean up imports and references to removed functionality This streamlines the codebase by removing long-disabled or broken tests and dependencies on the `create-script-context` tool. --- .github/regression.sh | 15 -- .github/source_plutus_apps.sh | 24 --- cardano_node_tests/tests/common.py | 5 - .../plutus/v1/context-equivalence-test.plutus | 5 - .../minting-context-equivalence-test.plutus | 5 - cardano_node_tests/tests/plutus_common.py | 40 ---- .../tests/tests_plutus/test_mint_build.py | 192 ------------------ .../tests/tests_plutus/test_mint_raw.py | 154 -------------- .../tests/tests_plutus/test_spend_build.py | 117 ----------- .../tests/tests_plutus/test_spend_raw.py | 110 ---------- cardano_node_tests/utils/clusterlib_utils.py | 35 ---- cardano_node_tests/utils/helpers.py | 2 +- 12 files changed, 1 insertion(+), 703 deletions(-) delete mode 100644 .github/source_plutus_apps.sh delete mode 100644 cardano_node_tests/tests/data/plutus/v1/context-equivalence-test.plutus delete mode 100644 cardano_node_tests/tests/data/plutus/v1/minting-context-equivalence-test.plutus diff --git a/.github/regression.sh b/.github/regression.sh index 263e04063..8f576f271 100755 --- a/.github/regression.sh +++ b/.github/regression.sh @@ -98,21 +98,6 @@ case "${DBSYNC_REV:-}" in ;; esac -# Setup plutus-apps (disabled by default). -# The "plutus-apps" repo is needed for the `create-script-context` tool, which is used by the -# Plutus tests that are testing script context. -# TODO: The `create-script-context` tool is broken for a very long time, hence disabled. -# See https://github.com/IntersectMBO/plutus-apps/issues/1107 -case "${PLUTUS_APPS_REV:="none"}" in - "none" ) - unset PLUTUS_APPS_REV - ;; - * ) - # shellcheck disable=SC1091 - . .github/source_plutus_apps.sh - ;; -esac - # setup cardano-cli (use the built-in version by default) case "${CARDANO_CLI_REV:-}" in "" ) diff --git a/.github/source_plutus_apps.sh b/.github/source_plutus_apps.sh deleted file mode 100644 index 27b44db3e..000000000 --- a/.github/source_plutus_apps.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -_origpwd="$PWD" -cd "$WORKDIR" || exit 1 - -if [ -z "${PLUTUS_APPS_REV:-""}" ]; then - echo "The value for PLUTUS_APPS_REV cannot be empty" >&2 - exit 1 -fi - -# Build `create-script-context` -nix build \ - --accept-flake-config \ - --no-write-lock-file \ - "github://github.com/IntersectMBO/plutus-apps?ref=${PLUTUS_APPS_REV}#create-script-context" \ - -o create-script-context-build || exit 1 -[ -e create-script-context-build/bin/create-script-context ] || exit 1 - -# Add `create-script-context` to PATH_PREPEND -PATH_PREPEND="${PATH_PREPEND:+"${PATH_PREPEND}:"}$(readlink -m create-script-context-build/bin)" -export PATH_PREPEND - -cd "$_origpwd" || exit 1 -unset _origpwd diff --git a/cardano_node_tests/tests/common.py b/cardano_node_tests/tests/common.py index 71b698437..2600c3c07 100644 --- a/cardano_node_tests/tests/common.py +++ b/cardano_node_tests/tests/common.py @@ -48,11 +48,6 @@ reason="`build-estimate` fails to balance tx with no txouts", ) -SKIPIF_MISMATCHED_ERAS = pytest.mark.skipif( - VERSIONS.transaction_era != VERSIONS.cluster_era, - reason="transaction era must be the same as node era", -) - SKIPIF_WRONG_ERA = pytest.mark.skipif( not ( VERSIONS.cluster_era >= VERSIONS.DEFAULT_CLUSTER_ERA diff --git a/cardano_node_tests/tests/data/plutus/v1/context-equivalence-test.plutus b/cardano_node_tests/tests/data/plutus/v1/context-equivalence-test.plutus deleted file mode 100644 index e1d25d935..000000000 --- a/cardano_node_tests/tests/data/plutus/v1/context-equivalence-test.plutus +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "PlutusScriptV1", - "description": "", - "cborHex": "590fc9590fc601000033232332232323232323232323232323232323232323232223223232323232323232322323253353330103333573466e1cd55cea8072400046eb4d5d09aab9e500f2326353357380480460440426666ae68cdc39aab9d500c480008ccccccccc88888888848ccccccccc00402802402001c01801401000c008cd4048050d5d0a80619a8090099aba1500b3335501675ca02a6ae854028cd4061d69aba150093335501675ca02a6ae854020cd4048cd5406dd710009aba1500733501201f35742a00c66a024eb8d5d0a80299a80b80e1aba135744a00a464c6a66ae7009008c088084cccd5cd19b8735573aa004900011991091980080180119191919191919191919191999ab9a3370e6aae754029200023333333333222222222212333333333300100b00a00900800700600500400300233501e01f35742a01466a03c0406ae854024ccd54089d728109aba150083335502275ca0426ae85401ccd40780acd5d0a80319a80f19aa8138163ad35742a00a66a048eb4d5d0a80219a80f3ae35742a00666a03c66aa04eeb88004d5d0a80118151aba135744a004464c6a66ae700c00bc0b80b44d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d55cf280089baa00135742a00460386ae84d5d1280111931a99ab9c024023022021102213263533573892010350543500022021135573ca00226ea80044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226aae7940044dd500089baa0011232230023758002640026aa02e446666aae7c004940608cd405cc010d5d080118019aba2002014232323333573466e1cd55cea80124000466442466002006004601c6ae854008c014d5d09aba2500223263533573802a02802602426aae7940044dd500091919191999ab9a3370e6aae75400d20002333222123330010040030023232323333573466e1cd55cea80124000466442466002006004602c6ae854008cd4030054d5d09aba2500223263533573803203002e02c26aae7940044dd50009aba150033335500775ca00c6ae854008cd4021d71aba135744a004464c6a66ae7005405004c0484d5d1280089aab9e500113754002266aa002eb9d6889119118011bab00132001355014223233335573e0044a02c466a02a66aa02e600c6aae754008c014d55cf280118021aba200301213574200224464646666ae68cdc3a800a40004642446004006600a6ae84d55cf280191999ab9a3370ea0049001109100091931a99ab9c01301201101000f135573aa00226ea8004488c8c8cccd5cd19b8735573aa00490001199109198008018011919191999ab9a3370e6aae754009200023322123300100300233500a00935742a00460166ae84d5d1280111931a99ab9c015014013012135573ca00226ea8004d5d0a8011919191999ab9a3370e6aae754009200023322123300100300233500a00935742a00460166ae84d5d1280111931a99ab9c015014013012135573ca00226ea8004d5d09aba2500223263533573802202001e01c26aae7940044dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6a66ae7004804404003c0380344d55cea80089baa0012323333573466e1d40052002212200223333573466e1d40092000212200123263533573801c01a01801601426aae74dd50008891119191999ab9a3370e6aae754009200023355012300635742a004600a6ae84d5d1280111931a99ab9c00f00e00d00c135573ca00226ea80048c8c8cccd5cd19b875001480188c848888c010014c01cd5d09aab9e500323333573466e1d400920042321222230020053009357426aae7940108cccd5cd19b875003480088c848888c004014c01cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931a99ab9c00f00e00d00c00b00a009135573aa00226ea80048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931a99ab9c00b00a009008135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98d4cd5ce00480400380309baa001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98d4cd5ce00900880800780700680600580500489aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6a66ae7002c02802402001c4d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263533573801000e00c00a00826aae7540044dd5000a4c2400292103505431001122002122122330010040031122123300100300211232300100122330033002002001323233223232332232323232323232323232323322323232323232323232323222232323500423223232222223222533533301b02935500f22222222220070081533532350012235002223500c2232350032232533350082153335004215335330360020011500310381037103715333500321037150011036153335003210371036150011533500615335001150031035153350011035150031350052235003225333500421533350032153353303600200113303700500310381037103715333500221037133035003001103615333500221037103613303500300135500f2222222222004153353335301912001223500222350032253353302e0040021333573466ebc00c0040c80c440c4d5403c888888888800801454cd4ccd4c064480040a0d5403c888888888800c00854cd4c030cd54c04c48004cd54c05848004050d5403c8888888888024d4060488cc0092002330024801000454cd54cd4c02540384c029403840ac54cd4c00ccd54c04c48004d5403c8888888888018d4060488cc00920020011533500121323333500223333500223302a002001202f202f202f233335002202f23302c002001202f202f233335002202f202f23302b002001202f233335002202f202f202f233029002001350112200116102b102b102b102b102b102b102b3200135502f225335001102a2213500222533533029002533500713501801a221002102f1300600332001355029225335001102422135002225335330170025335008135012014221002102913006003320013550282253350011023221350022253353301600253353302a007502c13501101322100210281300600332001355026225335001102122135002225335333015023002533533027335530101200100e007502a13500f01122100210261300600313355300512001355001222222222200a3500a1223300248008cc0092004001135001220023200135501f2211225335002150212215335003150232213350243355026004002335530081200100300123500122200212326353357380022400293190009aa80e110891299a8008a80f11099a80f980200119aa980309000802000a49035054380012335001501850193200135501922122253350021533500110182210192215335003101922153353300700400213335300912001007003001101b22350022235003225335330110040021350032223500322350062223500322325335335008233500425335333573466e3c0080040940905400c409080908cd4010809094cd4ccd5cd19b8f0020010250241500310241533533301202000a0051533500921533500521330210020011023153350042102310231022102215335006215335002213301f0020011022153350012102210221017222333553009120013500b500a2350012233355300c120013500e500d23500122333500123300a4800000488cc02c0080048cc0280052000001335530081200123500122335501c002333500123355300c1200123500122335502000235500e0010012233355500901500200123355300c1200123500122335502000235500d001001333555004010002001111222333553004120015016335530071200123500122335501b00235500900133355300412001223500222533533355300c12001323350102233350032200200200135001220011233001225335002101a1001017235001223300a0020050061003133501a004003501700133553007120012350012232335501c00330010053200135501c225335001135500a003221350022253353300c002008112223300200a0041300600300232001355015221122253350011002221330050023335530071200100500400111212223003004112122230010043200135501222112253350011501422133501530040023355300612001004001320013550112211222533500113500322001221333500522002300400233355300712001005004001112330012253350021001100c00b123350022233350032200200200135001220011221233001003002225335333573466e3cd400888008d4004880080240204ccd5cd19b873500222001350012200100900810082253333333500221533333335002213300500200122100a210091008100822100a22100a2215333333350032100a221533533007004002133008003001100b2100a1009100922100b22100b215333333350022100922100a21330050020011008100822100a22100a153333333500121008221009210081008100722100922100915333333350012100822100921008100710082210092210092215333333350032100a22100b2100a100910092215335333573466e3c01000803002c4cc02000c004402c88402c8854ccccccd400c8402888402c840284024402488402c8854cd4ccd5cd19b8f00400200c00b133009003001100b22335002233500223350022335002233007002001200a2335002200a23300700200122200a222335004200a2225335333573466e1c01800c03403054cd4ccd5cd19b8700500200d00c13300a004001100c100c22333573466e3c00800401801488ccd5cd19b870020010050042253350021001153350011003100412200212200132001355005222533500210012213300500133500700200332001355004222533500210012213300500133500600200311220021221223300100400311221233001003002112323001001223300330020020011" -} diff --git a/cardano_node_tests/tests/data/plutus/v1/minting-context-equivalence-test.plutus b/cardano_node_tests/tests/data/plutus/v1/minting-context-equivalence-test.plutus deleted file mode 100644 index 62ff59875..000000000 --- a/cardano_node_tests/tests/data/plutus/v1/minting-context-equivalence-test.plutus +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "PlutusScriptV1", - "description": "", - "cborHex": "590cef590cec01000032332232323232323322323232323233223232323232323232323232323232323232323232323232232323232323232323223232533532323235003222222223225335323335530361200135038503723500122333553039120013503b503a2350012233350012330464800000488cc11c0080048cc1180052000001335530351200123500122335503f00233350012335530391200123500122335504300235503b001001223335550360430020012335530391200123500122335504300235503a00100133355503103e00900135500b22222222220071533532350012235002223500c22323500322325333500821533350042153353304b00200115003104d104c104c1533350032104c15001104b1533350032104c104b15001153350061533500115003104a15335001104a150031350052235003225333500421533350032153353304b00200113304c005003104d104c104c1533350022104c13304a003001104b1533350022104c104b13304a00300135500b22222222220041533530023355301b1200135500b22222222220033322330024800800540e540e854cd400484c8cccd40088cccd400894ccccccd4008854ccccccd400884cc10800800488411c841184114411488411c88411c8854ccccccd400c8411c8854cd4cc1100100084cc11400c00441208411c41184118884120884120854ccccccd40088411888411c84cc1080080044114411488411c88411c54ccccccd400484114884118841144114411088411888411854ccccccd40048411488411884114411041148841188841188854ccccccd400c8411c8841208411c411841188854cd4ccd5cd19b8f00400204904813304500300110482210482215333333350032104722104821047104610462210482215335333573466e3c0100081241204cc11800c00441208110811081108cccd400881108cc104008004811081108cccd4008811081108cc10000800481108cccd400881108110811094cd4ccd5cd19b8f350022200235001220020450441333573466e1cd400888004d4004880041141104110d40348800458410041004100c8004d54100894cd40044100884d4008894cd4cc1040094cd401c4d408124010350543800221002104513006003135001220023333573466e1cd55cea801a400046644246600200600464646464646464646464646666ae68cdc39aab9d500a480008cccccccccc888888888848cccccccccc00402c02802402001c01801401000c008cd407807cd5d0a80519a80f0101aba150093335502275ca0426ae854020ccd54089d728109aba1500733501e02b35742a00c66a03c66aa04e058eb4d5d0a80299a8123ad35742a00866a03ceb8d5d0a80199a80f19aa813bae200135742a00460546ae84d5d1280111931a99ab9c03002f02e02d135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135573ca00226ea8004d5d0a801980e1aba135744a006464c6a66ae7009008c088084cccd5cd19b8735573aa018900011999999999111111110919999999980080500480400380300280200180119a8088099aba1500c33501101235742a016666aa02aeb94050d5d0a80519a80bbad35742a012666aa02aeb94050d5d0a80419a80899aa80d3ae200135742a00e66a02203c6ae854018cd4045d71aba1500533501601b357426ae8940148c98d4cd5ce011811010810081089a807a4810350543500135573ca00226ea80044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226aae7940044dd5000990009aa813910891299a8010a811910a99a8018a81291099a81319aa81400200119aa980409000801800891931a99ab9c0010130121232230023758002640026aa04c446666aae7c004940848cd4080c010d5d080118019aba2002014232323333573466e1cd55cea80124000466442466002006004601c6ae854008c014d5d09aba2500223263533573802a02802602426aae7940044dd500091919191999ab9a3370e6aae75400d20002333222123330010040030023232323333573466e1cd55cea80124000466442466002006004602c6ae854008cd4030054d5d09aba2500223263533573803203002e02c26aae7940044dd50009aba150033335500775ca00c6ae854008cd4021d71aba135744a004464c6a66ae7005405004c0484d5d1280089aab9e500113754002266aa002eb9d6889119118011bab00132001355023223233335573e0044a03e466a03c66aa040600c6aae754008c014d55cf280118021aba200301213574200224464646666ae68cdc3a800a40004642446004006600a6ae84d55cf280191999ab9a3370ea0049001109100091931a99ab9c01301201101000f135573aa00226ea8004488c8c8cccd5cd19b8735573aa00490001199109198008018011919191999ab9a3370e6aae754009200023322123300100300233500a00935742a00460166ae84d5d1280111931a99ab9c015014013012135573ca00226ea8004d5d0a8011919191999ab9a3370e6aae754009200023322123300100300233500a00935742a00460166ae84d5d1280111931a99ab9c015014013012135573ca00226ea8004d5d09aba2500223263533573802202001e01c26aae7940044dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6a66ae7004804404003c0380344d55cea80089baa0012323333573466e1d40052002201f23333573466e1d40092000201f23263533573801c01a01801601426aae74dd50008891119191999ab9a3370e6aae75400920002335501b300635742a004600a6ae84d5d1280111931a99ab9c00f00e00d00c135573ca00226ea80048c8c8cccd5cd19b875001480188c848888c010014c01cd5d09aab9e500323333573466e1d400920042321222230020053009357426aae7940108cccd5cd19b875003480088c848888c004014c01cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931a99ab9c00f00e00d00c00b00a009135573aa00226ea80048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931a99ab9c00b00a009008135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98d4cd5ce00480400380309baa001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98d4cd5ce00900880800780700680600580500489aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6a66ae7002c02802402001c4d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263533573801000e00c00a00826aae7540044dd5000a4c240029201035054310011122233355300412001500c335530071200123500122335501100235500900133355300412001223500222533533355300c12001323350102233350032200200200135001220011233001225335002101b1001018235001223300a00200500610031335010004003500d001335530071200123500122323355012003300100532001355018225335001135500a003221350022253353300c002008112223300200a0041300600300232001355011221122253350011002221330050023335530071200100500400111212223003004112122230010043200135500e22112253350011500a22133500b300400233553006120010040013200135500d2211222533500113500322001221333500522002300400233355300712001005004001112330012253350021001100d00c1233500222333500322002002001350012200112212330010030021122002122122330010040031122123300100300222335002233500223350022335002233007002001200a2335002200a23300700200122200a222335004200a2225335333573466e1c01800c03403054cd4ccd5cd19b8700500200d00c13300a004001100c100c22333573466e3c00800401801488ccd5cd19b87002001005004225335002100115335001100310041220021220011123230010012233003300200200101" -} diff --git a/cardano_node_tests/tests/plutus_common.py b/cardano_node_tests/tests/plutus_common.py index b94166371..85207920e 100644 --- a/cardano_node_tests/tests/plutus_common.py +++ b/cardano_node_tests/tests/plutus_common.py @@ -6,7 +6,6 @@ from cardano_clusterlib import clusterlib from packaging import version -from cardano_node_tests.tests import issues from cardano_node_tests.utils import cluster_nodes from cardano_node_tests.utils import clusterlib_utils from cardano_node_tests.utils import dbsync_utils @@ -27,7 +26,6 @@ ALWAYS_FAILS_PLUTUS_V1 = SCRIPTS_V1_DIR / "always-fails.plutus" GUESSING_GAME_PLUTUS_V1 = SCRIPTS_V1_DIR / "custom-guess-42-datum-42.plutus" GUESSING_GAME_UNTYPED_PLUTUS_V1 = SCRIPTS_V1_DIR / "guess-42-datum-42-txin.plutus" -CONTEXT_EQUIVALENCE_PLUTUS_V1 = SCRIPTS_V1_DIR / "context-equivalence-test.plutus" ALWAYS_SUCCEEDS_PLUTUS_V2 = SCRIPTS_V2_DIR / "always-succeeds-spending.plutus" ALWAYS_FAILS_PLUTUS_V2 = SCRIPTS_V2_DIR / "always-fails.plutus" @@ -42,7 +40,6 @@ MINTING_PLUTUS_V1 = SCRIPTS_V1_DIR / "anyone-can-mint.plutus" MINTING_TIME_RANGE_PLUTUS_V1 = SCRIPTS_V1_DIR / "time_range.plutus" -MINTING_CONTEXT_EQUIVALENCE_PLUTUS_V1 = SCRIPTS_V1_DIR / "minting-context-equivalence-test.plutus" MINTING_WITNESS_REDEEMER_PLUTUS_V1 = SCRIPTS_V1_DIR / "witness-redeemer.plutus" MINTING_TOKENNAME_PLUTUS_V1 = SCRIPTS_V1_DIR / "mint-tokenname.plutus" @@ -96,8 +93,6 @@ class ExecutionCost: ALWAYS_SUCCEEDS_COST = ExecutionCost(per_time=368_100, per_space=1_700, fixed_cost=125) GUESSING_GAME_COST = ExecutionCost(per_time=282_016_214, per_space=1_034_516, fixed_cost=80_025) GUESSING_GAME_UNTYPED_COST = ExecutionCost(per_time=4_985_806, per_space=11_368, fixed_cost=1_016) -# TODO: fix once context equivalence tests can run again -CONTEXT_EQUIVALENCE_COST = ExecutionCost(per_time=100_000_000, per_space=1_000_00, fixed_cost=947) ALWAYS_FAILS_V2_COST = ExecutionCost(per_time=230_100, per_space=1_100, fixed_cost=81) ALWAYS_SUCCEEDS_V2_COST = ExecutionCost(per_time=230_100, per_space=1_100, fixed_cost=81) @@ -122,10 +117,6 @@ class ExecutionCost: MINTING_TIME_RANGE_COST = ExecutionCost( per_time=277_239_670, per_space=1_044_064, fixed_cost=80_232 ) -# TODO: fix once context equivalence tests can run again -MINTING_CONTEXT_EQUIVALENCE_COST = ExecutionCost( - per_time=358_849_733, per_space=978_434, fixed_cost=82_329 -) MINTING_WITNESS_REDEEMER_COST = ExecutionCost( per_time=261_056_789, per_space=1_013_630, fixed_cost=75_278 ) @@ -895,34 +886,3 @@ def xfail_on_secp_error(cluster_obj: clusterlib.ClusterLib, algorithm: str, err_ if before_pv8 and (is_forbidden or is_overspending): pytest.xfail("The SECP256k1 builtin functions are not allowed before protocol version 8") - - -def create_script_context_w_blockers( - cluster_obj: clusterlib.ClusterLib, - plutus_version: int, - redeemer_file: pl.Path, - tx_file: pl.Path | None = None, -) -> None: - """Run the `create-script-context` command (available in plutus-apps). - - This variant of the `create_script_context` function catches known errors and fails the test - with a blocker issue. - """ - try: - clusterlib_utils.create_script_context( - cluster_obj=cluster_obj, - plutus_version=plutus_version, - redeemer_file=redeemer_file, - tx_file=tx_file, - ) - except RuntimeError as err: - str_err = str(err) - if "Unwitnessed Tx ConwayEra" in str_err: - pytest.xfail("create-script-context: unsupported 'Unwitnessed Tx ConwayEra'") - if "DeserialiseFailure" in str_err: - issues.plutus_apps_583.finish_test() - if "TextEnvelopeTypeError" in str_err: - issues.plutus_apps_1078.finish_test() - if "PlutusScriptV1 custom redeemer not wired up" in str_err: - issues.plutus_apps_1107.finish_test() - raise diff --git a/cardano_node_tests/tests/tests_plutus/test_mint_build.py b/cardano_node_tests/tests/tests_plutus/test_mint_build.py index ff786b155..859d61084 100644 --- a/cardano_node_tests/tests/tests_plutus/test_mint_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_mint_build.py @@ -1,10 +1,8 @@ """Tests for minting with Plutus using `transaction build`.""" -import dataclasses import datetime import logging import pathlib as pl -import shutil import allure import pytest @@ -769,196 +767,6 @@ def test_two_scripts_minting( dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output_step1) dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output_step2) - @allure.link(helpers.get_vcs_link()) - @pytest.mark.skipif( - not shutil.which("create-script-context"), - reason="cannot find `create-script-context` on the PATH", - ) - @common.SKIPIF_MISMATCHED_ERAS - @submit_utils.PARAM_SUBMIT_METHOD - @pytest.mark.smoke - @pytest.mark.testnets - @pytest.mark.dbsync - def test_minting_context_equivalence( - self, - cluster: clusterlib.ClusterLib, - payment_addrs: list[clusterlib.AddressRecord], - submit_method: str, - ): - """Test context equivalence while minting a token. - - Uses `cardano-cli transaction build` command for building the transactions. - - * Fund the token issuer and create a UTxO for collateral - * Check that the expected amount was transferred to token issuer's address - * Generate a dummy redeemer and a dummy Tx - * Derive the correct redeemer from the dummy Tx - * Mint the token using the derived redeemer - * Check that the token was minted and collateral UTxO was not spent - * Check expected Plutus cost - * (optional) Check transactions in db-sync - """ - temp_template = common.get_test_id(cluster) - payment_addr = payment_addrs[0] - issuer_addr = payment_addrs[1] - - lovelace_amount = 2_000_000 - token_amount = 5 - script_fund = 10_000_000 - - minting_cost = plutus_common.compute_cost( - execution_cost=plutus_common.MINTING_CONTEXT_EQUIVALENCE_COST, - protocol_params=cluster.g_query.get_protocol_params(), - ) - - issuer_init_balance = cluster.g_query.get_address_balance(issuer_addr.address) - - # Step 1: fund the token issuer - - mint_utxos, collateral_utxos, tx_output_step1 = mint_build._fund_issuer( - cluster_obj=cluster, - temp_template=temp_template, - payment_addr=payment_addr, - issuer_addr=issuer_addr, - minting_cost=minting_cost, - amount=script_fund, - submit_method=submit_method, - ) - - # Step 2: mint the "qacoin" - - invalid_hereafter = cluster.g_query.get_slot_no() + 200 - - policyid = cluster.g_transaction.get_policyid( - plutus_common.MINTING_CONTEXT_EQUIVALENCE_PLUTUS_V1 - ) - asset_name = f"qacoin{clusterlib.get_rand_str(4)}".encode().hex() - token = f"{policyid}.{asset_name}" - mint_txouts = [ - clusterlib.TxOut(address=issuer_addr.address, amount=token_amount, coin=token) - ] - - tx_files_step2 = clusterlib.TxFiles( - signing_key_files=[issuer_addr.skey_file, plutus_common.SIGNING_KEY_GOLDEN], - ) - txouts_step2 = [ - clusterlib.TxOut(address=issuer_addr.address, amount=lovelace_amount), - *mint_txouts, - ] - - # Generate a dummy redeemer in order to create a txbody from which - # we can generate a tx and then derive the correct redeemer - redeemer_file_dummy = pl.Path(f"{temp_template}_dummy_script_context.redeemer") - clusterlib_utils.create_script_context( - cluster_obj=cluster, plutus_version=1, redeemer_file=redeemer_file_dummy - ) - - plutus_mint_data_dummy = [ - clusterlib.Mint( - txouts=mint_txouts, - script_file=plutus_common.MINTING_CONTEXT_EQUIVALENCE_PLUTUS_V1, - collaterals=collateral_utxos, - redeemer_file=redeemer_file_dummy, - ) - ] - - tx_output_dummy = cluster.g_transaction.build_tx( - src_address=payment_addr.address, - tx_name=f"{temp_template}_dummy", - tx_files=tx_files_step2, - txins=mint_utxos, - txouts=txouts_step2, - mint=plutus_mint_data_dummy, - required_signers=[plutus_common.SIGNING_KEY_GOLDEN], - invalid_before=1, - invalid_hereafter=invalid_hereafter, - script_valid=False, - ) - assert tx_output_dummy - - # Generate the "real" redeemer - redeemer_file = pl.Path(f"{temp_template}_script_context.redeemer") - - plutus_common.create_script_context_w_blockers( - cluster_obj=cluster, - plutus_version=1, - redeemer_file=redeemer_file, - tx_file=tx_output_dummy.out_file, - ) - - plutus_mint_data = [ - dataclasses.replace(plutus_mint_data_dummy[0], redeemer_file=redeemer_file) - ] - - tx_output_step2 = cluster.g_transaction.build_tx( - src_address=payment_addr.address, - tx_name=f"{temp_template}_step2", - tx_files=tx_files_step2, - txins=mint_utxos, - txouts=txouts_step2, - mint=plutus_mint_data, - required_signers=[plutus_common.SIGNING_KEY_GOLDEN], - invalid_before=1, - invalid_hereafter=invalid_hereafter, - ) - - # Calculate cost of Plutus script - plutus_costs_step2 = cluster.g_transaction.calculate_plutus_script_cost( - src_address=payment_addr.address, - tx_name=f"{temp_template}_step2", - tx_files=tx_files_step2, - txins=mint_utxos, - txouts=txouts_step2, - mint=plutus_mint_data, - required_signers=[plutus_common.SIGNING_KEY_GOLDEN], - invalid_before=1, - invalid_hereafter=invalid_hereafter, - ) - - tx_signed_step2 = cluster.g_transaction.sign_tx( - tx_body_file=tx_output_step2.out_file, - signing_key_files=tx_files_step2.signing_key_files, - tx_name=f"{temp_template}_step2", - ) - - submit_utils.submit_tx( - submit_method=submit_method, - cluster_obj=cluster, - tx_file=tx_signed_step2, - txins=mint_utxos, - ) - - assert ( - cluster.g_query.get_address_balance(issuer_addr.address) - == issuer_init_balance + minting_cost.collateral + lovelace_amount - ), f"Incorrect balance for token issuer address `{issuer_addr.address}`" - - out_utxos = cluster.g_query.get_utxo(tx_raw_output=tx_output_step2) - token_utxo = clusterlib.filter_utxos( - utxos=out_utxos, address=issuer_addr.address, coin=token - ) - assert token_utxo and token_utxo[0].amount == token_amount, "The token was not minted" - - common.check_missing_utxos(cluster_obj=cluster, utxos=out_utxos) - - plutus_common.check_plutus_costs( - plutus_costs=plutus_costs_step2, - expected_costs=[plutus_common.MINTING_CONTEXT_EQUIVALENCE_COST], - ) - - # Check tx_view - tx_view.check_tx_view(cluster_obj=cluster, tx_raw_output=tx_output_step2) - - dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output_step1) - tx_db_record_step2 = dbsync_utils.check_tx( - cluster_obj=cluster, tx_raw_output=tx_output_step2 - ) - # Compare cost of Plutus script with data from db-sync - if tx_db_record_step2: - dbsync_utils.check_plutus_costs( - redeemer_records=tx_db_record_step2.redeemers, cost_records=plutus_costs_step2 - ) - @allure.link(helpers.get_vcs_link()) @submit_utils.PARAM_SUBMIT_METHOD @pytest.mark.parametrize( diff --git a/cardano_node_tests/tests/tests_plutus/test_mint_raw.py b/cardano_node_tests/tests/tests_plutus/test_mint_raw.py index 2fb349315..4a0f94237 100644 --- a/cardano_node_tests/tests/tests_plutus/test_mint_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_mint_raw.py @@ -1,10 +1,8 @@ """Tests for minting with Plutus using `transaction build-raw`.""" -import dataclasses import datetime import logging import pathlib as pl -import shutil import allure import pytest @@ -15,7 +13,6 @@ from cardano_node_tests.tests import common from cardano_node_tests.tests import plutus_common from cardano_node_tests.tests.tests_plutus import mint_raw -from cardano_node_tests.utils import clusterlib_utils from cardano_node_tests.utils import dbsync_utils from cardano_node_tests.utils import helpers from cardano_node_tests.utils import tx_view @@ -1034,157 +1031,6 @@ def test_minting_policy_executed_once2( dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_step1) dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_step2) - @allure.link(helpers.get_vcs_link()) - @pytest.mark.skipif( - not shutil.which("create-script-context"), - reason="cannot find `create-script-context` on the PATH", - ) - @common.SKIPIF_MISMATCHED_ERAS - @pytest.mark.smoke - @pytest.mark.testnets - @pytest.mark.dbsync - def test_minting_context_equivalence( - self, cluster: clusterlib.ClusterLib, payment_addrs: list[clusterlib.AddressRecord] - ): - """Test context equivalence while minting a token. - - * Fund the token issuer and create a UTxO for collateral - * Check that the expected amount was transferred to token issuer's address - * Generate a dummy redeemer and a dummy Tx - * Derive the correct redeemer from the dummy Tx - * Mint the token using the derived redeemer - * Check that the token was minted and collateral UTxO was not spent - * (optional) Check transactions in db-sync - """ - temp_template = common.get_test_id(cluster) - payment_addr = payment_addrs[0] - issuer_addr = payment_addrs[1] - - lovelace_amount = 2_000_000 - token_amount = 5 - - minting_cost = plutus_common.compute_cost( - execution_cost=plutus_common.MINTING_CONTEXT_EQUIVALENCE_COST, - protocol_params=cluster.g_query.get_protocol_params(), - ) - - # Step 1: fund the token issuer - - mint_utxos, collateral_utxos, tx_raw_output_step1 = mint_raw._fund_issuer( - cluster_obj=cluster, - temp_template=temp_template, - payment_addr=payment_addr, - issuer_addr=issuer_addr, - minting_cost=minting_cost, - amount=lovelace_amount, - ) - - issuer_fund_balance = cluster.g_query.get_address_balance(issuer_addr.address) - - # Step 2: mint the "qacoin" - - invalid_hereafter = cluster.g_query.get_slot_no() + 200 - - policyid = cluster.g_transaction.get_policyid( - plutus_common.MINTING_CONTEXT_EQUIVALENCE_PLUTUS_V1 - ) - asset_name = f"qacoin{clusterlib.get_rand_str(4)}".encode().hex() - token = f"{policyid}.{asset_name}" - mint_txouts = [ - clusterlib.TxOut(address=issuer_addr.address, amount=token_amount, coin=token) - ] - - tx_files_step2 = clusterlib.TxFiles( - signing_key_files=[issuer_addr.skey_file, plutus_common.SIGNING_KEY_GOLDEN], - ) - txouts_step2 = [ - clusterlib.TxOut(address=issuer_addr.address, amount=lovelace_amount), - *mint_txouts, - ] - - # Generate a dummy redeemer in order to create a txbody from which - # we can generate a tx and then derive the correct redeemer - redeemer_file_dummy = pl.Path(f"{temp_template}_dummy_script_context.redeemer") - clusterlib_utils.create_script_context( - cluster_obj=cluster, plutus_version=1, redeemer_file=redeemer_file_dummy - ) - - plutus_mint_data_dummy = [ - clusterlib.Mint( - txouts=mint_txouts, - script_file=plutus_common.MINTING_CONTEXT_EQUIVALENCE_PLUTUS_V1, - collaterals=collateral_utxos, - execution_units=( - plutus_common.MINTING_CONTEXT_EQUIVALENCE_COST.per_time, - plutus_common.MINTING_CONTEXT_EQUIVALENCE_COST.per_space, - ), - redeemer_file=redeemer_file_dummy, - ) - ] - - tx_output_dummy = cluster.g_transaction.build_raw_tx_bare( - out_file=f"{temp_template}_dummy_tx.body", - txins=mint_utxos, - txouts=txouts_step2, - mint=plutus_mint_data_dummy, - tx_files=tx_files_step2, - fee=minting_cost.fee + mint_raw.FEE_MINT_TXSIZE, - required_signers=[plutus_common.SIGNING_KEY_GOLDEN], - invalid_before=1, - invalid_hereafter=invalid_hereafter, - script_valid=False, - ) - assert tx_output_dummy - - # Generate the "real" redeemer - redeemer_file = pl.Path(f"{temp_template}_script_context.redeemer") - - plutus_common.create_script_context_w_blockers( - cluster_obj=cluster, - plutus_version=1, - redeemer_file=redeemer_file, - tx_file=tx_output_dummy.out_file, - ) - - plutus_mint_data = [ - dataclasses.replace(plutus_mint_data_dummy[0], redeemer_file=redeemer_file) - ] - - tx_raw_output_step2 = cluster.g_transaction.build_raw_tx_bare( - out_file=f"{temp_template}_step2_tx.body", - txins=mint_utxos, - txouts=txouts_step2, - mint=plutus_mint_data, - tx_files=tx_files_step2, - fee=minting_cost.fee + mint_raw.FEE_MINT_TXSIZE, - required_signers=[plutus_common.SIGNING_KEY_GOLDEN], - invalid_before=1, - invalid_hereafter=invalid_hereafter, - ) - - tx_signed_step2 = cluster.g_transaction.sign_tx( - tx_body_file=tx_raw_output_step2.out_file, - signing_key_files=tx_files_step2.signing_key_files, - tx_name=f"{temp_template}_step2", - ) - cluster.g_transaction.submit_tx(tx_file=tx_signed_step2, txins=mint_utxos) - - assert ( - cluster.g_query.get_address_balance(issuer_addr.address) - == issuer_fund_balance - tx_raw_output_step2.fee - ), f"Incorrect balance for token issuer address `{issuer_addr.address}`" - - out_utxos = cluster.g_query.get_utxo(tx_raw_output=tx_raw_output_step2) - token_utxo = clusterlib.filter_utxos( - utxos=out_utxos, address=issuer_addr.address, coin=token - ) - assert token_utxo and token_utxo[0].amount == token_amount, "The token was not minted" - - common.check_missing_utxos(cluster_obj=cluster, utxos=out_utxos) - - dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_step1) - dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_raw_output_step2) - @allure.link(helpers.get_vcs_link()) @pytest.mark.skipif( VERSIONS.transaction_era < VERSIONS.BABBAGE, diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_build.py b/cardano_node_tests/tests/tests_plutus/test_spend_build.py index fd9b206a8..a91d2db36 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_build.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_build.py @@ -1,9 +1,7 @@ """Tests for spending with Plutus using `transaction build`.""" -import dataclasses import logging import pathlib as pl -import shutil import typing as tp import allure @@ -132,121 +130,6 @@ def test_txout_locking( expected_costs=[plutus_common.ALWAYS_SUCCEEDS[plutus_version].execution_cost], ) - @allure.link(helpers.get_vcs_link()) - @pytest.mark.skipif( - not shutil.which("create-script-context"), - reason="cannot find `create-script-context` on the PATH", - ) - @common.SKIPIF_MISMATCHED_ERAS - @pytest.mark.smoke - @pytest.mark.testnets - @pytest.mark.dbsync - def test_context_equivalence( - self, - cluster: clusterlib.ClusterLib, - pool_users: list[clusterlib.PoolUser], - ): - """Test context equivalence while spending a locked UTxO. - - Uses `cardano-cli transaction build` command for building the transactions. - - * Create a Tx output with a datum hash at the script address - * Check that the expected amount was locked at the script address - * Generate a dummy redeemer and a dummy Tx - * Derive the correct redeemer from the dummy Tx - * Spend the locked UTxO using the derived redeemer - * Check that the expected amount was spent - * (optional) Check transactions in db-sync - """ - __: tp.Any # mypy workaround - temp_template = common.get_test_id(cluster) - deposit_amount = cluster.g_query.get_address_deposit() - - # Create stake address registration cert - stake_addr_reg_cert_file = cluster.g_stake_address.gen_stake_addr_registration_cert( - addr_name=f"{temp_template}_addr2", - deposit_amt=common.get_conway_address_deposit(cluster_obj=cluster), - stake_vkey_file=pool_users[0].stake.vkey_file, - ) - - tx_files = clusterlib.TxFiles(certificate_files=[stake_addr_reg_cert_file]) - - # Generate a dummy redeemer in order to create a txbody from which - # we can generate a tx and then derive the correct redeemer - redeemer_file_dummy = pl.Path(f"{temp_template}_dummy_script_context.redeemer") - clusterlib_utils.create_script_context( - cluster_obj=cluster, plutus_version=1, redeemer_file=redeemer_file_dummy - ) - - plutus_op_dummy = plutus_common.PlutusOp( - script_file=plutus_common.CONTEXT_EQUIVALENCE_PLUTUS_V1, - datum_file=plutus_common.DATUM_42_TYPED, - redeemer_file=redeemer_file_dummy, - execution_cost=plutus_common.CONTEXT_EQUIVALENCE_COST, - ) - - # Fund the script address - script_utxos, collateral_utxos, __ = spend_build._build_fund_script( - temp_template=temp_template, - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - plutus_op=plutus_op_dummy, - amount=1_000_000, - ) - - invalid_hereafter = cluster.g_query.get_slot_no() + 200 - - __, tx_output_dummy, __ = spend_build._build_spend_locked_txin( - temp_template=f"{temp_template}_dummy", - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - script_utxos=script_utxos, - collateral_utxos=collateral_utxos, - plutus_op=plutus_op_dummy, - amount=-1, - deposit_amount=deposit_amount, - tx_files=tx_files, - invalid_before=1, - invalid_hereafter=invalid_hereafter, - script_valid=False, - submit_tx=False, - ) - assert tx_output_dummy - - # Generate the "real" redeemer - redeemer_file = pl.Path(f"{temp_template}_script_context.redeemer") - - plutus_common.create_script_context_w_blockers( - cluster_obj=cluster, - plutus_version=1, - redeemer_file=redeemer_file, - tx_file=tx_output_dummy.out_file, - ) - - plutus_op = dataclasses.replace(plutus_op_dummy, redeemer_file=redeemer_file) - - __, tx_output, __ = spend_build._build_spend_locked_txin( - temp_template=temp_template, - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - script_utxos=script_utxos, - collateral_utxos=collateral_utxos, - plutus_op=plutus_op, - amount=-1, - deposit_amount=deposit_amount, - tx_files=tx_files, - invalid_before=1, - invalid_hereafter=invalid_hereafter, - ) - - # Check expected fees - if tx_output: - expected_fee = 372_438 - assert common.is_fee_in_interval(tx_output.fee, expected_fee, frac=0.15) - @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("embed_datum", (True, False), ids=("embedded_datum", "datum")) @pytest.mark.parametrize( diff --git a/cardano_node_tests/tests/tests_plutus/test_spend_raw.py b/cardano_node_tests/tests/tests_plutus/test_spend_raw.py index caf571100..4d08ffc89 100644 --- a/cardano_node_tests/tests/tests_plutus/test_spend_raw.py +++ b/cardano_node_tests/tests/tests_plutus/test_spend_raw.py @@ -1,10 +1,8 @@ """Tests for spending with Plutus using `transaction build-raw`.""" -import dataclasses import itertools import logging import pathlib as pl -import shutil import time import typing as tp @@ -175,114 +173,6 @@ def test_txout_locking( if utxo_err: pytest.fail(utxo_err) - @allure.link(helpers.get_vcs_link()) - @pytest.mark.skipif( - not shutil.which("create-script-context"), - reason="cannot find `create-script-context` on the PATH", - ) - @common.SKIPIF_MISMATCHED_ERAS - @pytest.mark.smoke - @pytest.mark.testnets - @pytest.mark.dbsync - def test_context_equivalence( - self, - cluster: clusterlib.ClusterLib, - pool_users: list[clusterlib.PoolUser], - ): - """Test context equivalence while spending a locked UTxO. - - * Create a Tx output with a datum hash at the script address - * Check that the expected amount was locked at the script address - * Generate a dummy redeemer and a dummy Tx - * Derive the correct redeemer from the dummy Tx - * Spend the locked UTxO using the derived redeemer - * Check that the expected amount was spent - * (optional) Check transactions in db-sync - """ - __: tp.Any # mypy workaround - temp_template = common.get_test_id(cluster) - amount = 1_000_000 - deposit_amount = cluster.g_query.get_address_deposit() - - # Create stake address registration cert - stake_addr_reg_cert_file = cluster.g_stake_address.gen_stake_addr_registration_cert( - addr_name=f"{temp_template}_addr0", - deposit_amt=common.get_conway_address_deposit(cluster_obj=cluster), - stake_vkey_file=pool_users[0].stake.vkey_file, - ) - - tx_files = clusterlib.TxFiles(certificate_files=[stake_addr_reg_cert_file]) - - # Generate a dummy redeemer in order to create a txbody from which - # we can generate a tx and then derive the correct redeemer - redeemer_file_dummy = pl.Path(f"{temp_template}_dummy_script_context.redeemer") - clusterlib_utils.create_script_context( - cluster_obj=cluster, plutus_version=1, redeemer_file=redeemer_file_dummy - ) - - plutus_op_dummy = plutus_common.PlutusOp( - script_file=plutus_common.CONTEXT_EQUIVALENCE_PLUTUS_V1, - datum_file=plutus_common.DATUM_42_TYPED, - redeemer_file=redeemer_file_dummy, - execution_cost=plutus_common.CONTEXT_EQUIVALENCE_COST, - ) - - # Fund the script address - script_utxos, collateral_utxos, __ = spend_raw._fund_script( - temp_template=temp_template, - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - plutus_op=plutus_op_dummy, - amount=amount, - ) - - invalid_hereafter = cluster.g_query.get_slot_no() + 200 - - __, tx_output_dummy = spend_raw._spend_locked_txin( - temp_template=f"{temp_template}_dummy", - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - script_utxos=script_utxos, - collateral_utxos=collateral_utxos, - plutus_op=plutus_op_dummy, - amount=amount, - deposit_amount=deposit_amount, - tx_files=tx_files, - invalid_before=1, - invalid_hereafter=invalid_hereafter, - script_valid=False, - submit_tx=False, - ) - assert tx_output_dummy - - # Generate the "real" redeemer - redeemer_file = pl.Path(f"{temp_template}_script_context.redeemer") - - plutus_common.create_script_context_w_blockers( - cluster_obj=cluster, - plutus_version=1, - redeemer_file=redeemer_file, - tx_file=tx_output_dummy.out_file, - ) - - plutus_op = dataclasses.replace(plutus_op_dummy, redeemer_file=redeemer_file) - - spend_raw._spend_locked_txin( - temp_template=temp_template, - cluster_obj=cluster, - payment_addr=pool_users[0].payment, - dst_addr=pool_users[1].payment, - script_utxos=script_utxos, - collateral_utxos=collateral_utxos, - plutus_op=plutus_op, - amount=amount, - tx_files=tx_files, - invalid_before=1, - invalid_hereafter=invalid_hereafter, - ) - @allure.link(helpers.get_vcs_link()) @pytest.mark.parametrize("embed_datum", (True, False), ids=("embedded_datum", "datum")) @pytest.mark.parametrize( diff --git a/cardano_node_tests/utils/clusterlib_utils.py b/cardano_node_tests/utils/clusterlib_utils.py index 5a645cea3..746b5a8ec 100644 --- a/cardano_node_tests/utils/clusterlib_utils.py +++ b/cardano_node_tests/utils/clusterlib_utils.py @@ -1305,41 +1305,6 @@ def datum_hash_from_txout(*, cluster_obj: clusterlib.ClusterLib, txout: clusterl return datum_hash -def create_script_context( - *, - cluster_obj: clusterlib.ClusterLib, - plutus_version: int, - redeemer_file: pl.Path, - tx_file: pl.Path | None = None, -) -> None: - """Run the `create-script-context` command (available in plutus-apps).""" - if plutus_version == 1: - version_arg = "--plutus-v1" - elif plutus_version == 2: - version_arg = "--plutus-v2" - else: - msg = f"Unknown plutus version: {plutus_version}" - raise ValueError(msg) - - if tx_file: - cmd_args = [ - "create-script-context", - "--generate-tx", - str(tx_file), - version_arg, - *cluster_obj.magic_args, - "--out-file", - str(redeemer_file), - ] - else: - cmd_args = ["create-script-context", version_arg, "--out-file", str(redeemer_file)] - - helpers.run_command(cmd_args) - if not redeemer_file.exists(): - err = f"Expected file not created: {redeemer_file}" - raise FileNotFoundError(err) - - def cli_has(command: str) -> bool: """Check if a cardano-cli subcommand or argument is available. diff --git a/cardano_node_tests/utils/helpers.py b/cardano_node_tests/utils/helpers.py index d8507e2f6..cd10c33a8 100644 --- a/cardano_node_tests/utils/helpers.py +++ b/cardano_node_tests/utils/helpers.py @@ -287,7 +287,7 @@ def is_in_interval(num1: float, num2: float, *, frac: float = 0.1) -> bool: def tool_has(command: str) -> bool: """Check if a tool has a subcommand or argument available. - E.g. `tool_has_arg("create-script-context --plutus-v1")` + E.g. `tool_has("cardano-cli legacy governance")` """ err_str = "" try: