diff --git a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal index f01eb46d08e..2e491e0c435 100644 --- a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal +++ b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal @@ -82,10 +82,10 @@ library -- IOG dependencies -------------------------- build-depends: - , cardano-api ^>=10.19 - , plutus-ledger-api ^>=1.53 - , plutus-tx ^>=1.53 - , plutus-tx-plugin ^>=1.53 + , cardano-api ^>=10.21 + , plutus-ledger-api ^>=1.56 + , plutus-tx ^>=1.56 + , plutus-tx-plugin ^>=1.56 ------------------------ -- Non-IOG dependencies diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index 5beffe64a9d..7a2fd1fea7d 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -111,9 +111,9 @@ library , attoparsec-aeson , base16-bytestring , bytestring - , cardano-api ^>= 10.19 + , cardano-api ^>= 10.21 , cardano-binary - , cardano-cli ^>= 10.13 + , cardano-cli ^>= 10.14 , cardano-crypto-class , cardano-crypto-wrapper , cardano-data diff --git a/cabal.project b/cabal.project index 3ef2447a9db..754a12f2819 100644 --- a/cabal.project +++ b/cabal.project @@ -13,8 +13,8 @@ repository cardano-haskell-packages -- See CONTRIBUTING for information about these, including some Nix commands -- you need to run if you change them index-state: - , hackage.haskell.org 2025-10-17T00:26:22Z - , cardano-haskell-packages 2025-11-20T19:55:27Z + , hackage.haskell.org 2025-12-02T22:23:29Z + , cardano-haskell-packages 2025-12-16T19:04:42Z packages: cardano-node @@ -35,8 +35,8 @@ packages: -- Needed when cross compiling extra-packages: alex -program-options - ghc-options: -Werror +-- program-options +-- ghc-options: -Werror test-show-details: direct @@ -72,3 +72,21 @@ if impl (ghc >= 9.12) -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. + + + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-api.git + tag: 61e4cdd85f35e9088c4e1a869ff0d2b33473f5ff + --sha256: sha256-Xmni6Kal8fE77ul7HjFB0bvJRZHr07bjiJ4zrkrcMVU= + subdir: cardano-api + + + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-cli.git + tag: f7daf209b31b57564ed79086c08a7cd5e2326fff + --sha256: sha256-+uS6wo+lfYkfZLAz6A7QIFZCiLezMOkRqTEdTrUGMdM= + subdir: cardano-cli \ No newline at end of file diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 5d2f7626072..56d81e0083a 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -88,5 +88,5 @@ test-suite chairman-tests ghc-options: -threaded -rtsopts "-with-rtsopts=-N -T" build-tool-depends: cardano-node:cardano-node - , cardano-cli:cardano-cli ^>= 10.13 + , cardano-cli:cardano-cli ^>= 10.14 , cardano-node-chairman:cardano-node-chairman diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 8eac42d6384..0a1ee7df755 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -138,7 +138,7 @@ library , async , base16-bytestring , bytestring - , cardano-api ^>= 10.19 + , cardano-api ^>= 10.21 , cardano-crypto-class ^>=2.2.3.2 , cardano-crypto-wrapper , cardano-git-rev ^>=0.2.2 diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 9e9cc03aba1..69ebde187a3 100644 --- a/cardano-submit-api/cardano-submit-api.cabal +++ b/cardano-submit-api/cardano-submit-api.cabal @@ -39,9 +39,9 @@ library , aeson , async , bytestring - , cardano-api ^>= 10.19 + , cardano-api ^>= 10.21 , cardano-binary - , cardano-cli ^>= 10.13 + , cardano-cli ^>= 10.14 , cardano-crypto-class ^>=2.2.3.2 , http-media , iohk-monitoring diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index c7238d39b58..30a1ae5fb87 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -41,8 +41,8 @@ library , annotated-exception , ansi-terminal , bytestring - , cardano-api ^>= 10.19 - , cardano-cli:{cardano-cli, cardano-cli-test-lib} ^>= 10.13 + , cardano-api ^>= 10.21 + , cardano-cli:{cardano-cli, cardano-cli-test-lib} ^>= 10.14 , cardano-crypto-class ^>=2.2.3.2 , cardano-crypto-wrapper , cardano-git-rev ^>= 0.2.2 @@ -209,8 +209,12 @@ test-suite cardano-testnet-test Cardano.Testnet.Test.Cli.QuerySlotNumber Cardano.Testnet.Test.Cli.Plutus.Scripts Cardano.Testnet.Test.Cli.Plutus.CostCalculation + Cardano.Testnet.Test.Cli.Plutus.MultiAssetReturnCollateral + Cardano.Testnet.Test.Cli.Scripts.Simple.CostCalculation + Cardano.Testnet.Test.Cli.Scripts.Simple.Mint Cardano.Testnet.Test.Cli.StakeSnapshot Cardano.Testnet.Test.Cli.Transaction + Cardano.Testnet.Test.Cli.Transaction.BuildEstimate Cardano.Testnet.Test.Cli.Transaction.RegisterDeregisterStakeAddress Cardano.Testnet.Test.DumpConfig Cardano.Testnet.Test.FoldEpochState diff --git a/cardano-testnet/src/Testnet/Components/Query.hs b/cardano-testnet/src/Testnet/Components/Query.hs index 394e0876bd2..27bb3cc0eca 100644 --- a/cardano-testnet/src/Testnet/Components/Query.hs +++ b/cardano-testnet/src/Testnet/Components/Query.hs @@ -31,6 +31,7 @@ module Testnet.Components.Query , findAllUtxos , findUtxosWithAddress , findLargestUtxoWithAddress + , findLargestMultiAssetUtxoWithAddress , findLargestUtxoForPaymentKey , checkDRepsNumber @@ -350,6 +351,27 @@ findLargestUtxoWithAddress epochStateView sbe address = withFrozenCallStack $ do . listToMaybe $ sortOn (\(_, TxOut _ txOutValue _ _) -> Down $ txOutValueToLovelace txOutValue) utxos +-- | Retrieve the largest utxo with a multi-asset +findLargestMultiAssetUtxoWithAddress + :: HasCallStack + => MonadAssertion m + => MonadIO m + => MonadTest m + => EpochStateView + -> ShelleyBasedEra era + -> Text -- ^ Address + -> m (Maybe (TxIn, TxOut CtxUTxO era)) +findLargestMultiAssetUtxoWithAddress epochStateView sbe address = withFrozenCallStack $ do + utxos <- toList <$> findUtxosWithAddress epochStateView sbe address + let sortedUTxOs = sortOn (\(_, TxOut _ txOutValue _ _) -> Down $ txOutValueToLovelace txOutValue) utxos + utxosWithMas = filter (\(_,TxOut _ txOutValue _ _) -> isMultiAssetPresent txOutValue) sortedUTxOs + pure $ listToMaybe utxosWithMas + +isMultiAssetPresent :: TxOutValue era -> Bool +isMultiAssetPresent v = + Map.size (valueToPolicyAssets $ txOutValueToValue v) > 0 + + -- | Retrieve a largest UTxO for a payment key info - a convenience wrapper for -- 'findLargestUtxoWithAddress'. findLargestUtxoForPaymentKey diff --git a/cardano-testnet/src/Testnet/Defaults.hs b/cardano-testnet/src/Testnet/Defaults.hs index b84c3508ead..f47a3f61170 100644 --- a/cardano-testnet/src/Testnet/Defaults.hs +++ b/cardano-testnet/src/Testnet/Defaults.hs @@ -40,6 +40,7 @@ module Testnet.Defaults , plutusV3Script , plutusV3SupplementalDatumScript , plutusV2StakeScript + , simpleScript ) where import Cardano.Api (AnyShelleyBasedEra (..), CardanoEra (..), File (..), @@ -592,6 +593,12 @@ defaultUtxoKeys n = , signingKey = File $ "utxo-keys" "utxo" <> show n "utxo.skey" } + +simpleScript :: Text -> Text +simpleScript signerRequired = + "{ \"scripts\": [ { \"keyHash\": \"" <> signerRequired <> "\", \"type\": \"sig\" } ], \"type\": \"all\" }" + + -- | Default plutus script that always succeeds plutusV3Script :: Text plutusV3Script = diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/CostCalculation.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/CostCalculation.hs index 27f8db29252..ca9127ab980 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/CostCalculation.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/CostCalculation.hs @@ -8,17 +8,17 @@ module Cardano.Testnet.Test.Cli.Plutus.CostCalculation , hprop_included_plutus_cost_calculation , hprop_included_simple_script_cost_calculation -- | Execute tests in this module with: - -- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc/"@ + -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc/"@ ) where import Cardano.Api hiding (Value) import Cardano.Api.Experimental (Some (Some)) import Cardano.Api.Ledger (EpochInterval (..)) - import Cardano.Testnet import Prelude +import Testnet.Types import Control.Monad (void) import Data.Aeson (Value, encodeFile) @@ -37,14 +37,13 @@ import qualified System.Info as SYS import Testnet.Components.Query (findLargestUtxoForPaymentKey, getEpochStateView, getTxIx, watchEpochStateUpdate) +import qualified Testnet.Defaults as Defaults import Testnet.Process.Cli.Transaction (TxOutAddress (..), mkSpendOutputsOnlyTx, retrieveTransactionId, signTx, submitTx) import Testnet.Process.Run (execCli', mkExecConfig) import Testnet.Process.RunIO (liftIOAnnotated) import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Start.Types (eraToString) -import Testnet.Types (PaymentKeyInfo (paymentKeyInfoAddr), paymentKeyInfoPair, - verificationKey) import Hedgehog (Property) import qualified Hedgehog as H @@ -53,7 +52,7 @@ import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.Golden as H import qualified Hedgehog.Extras.Test.TestWatchdog as H --- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Ref Script/"@ +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Ref Script/"'@ hprop_ref_plutus_cost_calculation :: Property hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os @@ -145,7 +144,16 @@ hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-scri refScriptUnlock <- H.createDirectoryIfMissing $ work "ref-script-unlock" let unsignedUnlockTx = File $ refScriptUnlock "unsigned-tx.tx" largestUTxO <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - + refScriptHash <- execCli' execConfig [ eraName, "transaction", "policyid", "--script-file", unFile plutusV3Script] + H.note_ $ "Reference script hash: " <> refScriptHash + + void $ execCli' execConfig + [ eraName, "query", "utxo" + , "--whole-utxo" + , "--cardano-mode" + , "--out-file", work "utxo-1.json" + ] + H.cat $ work "utxo-1.json" void $ execCli' execConfig @@ -201,7 +209,7 @@ hprop_ref_plutus_cost_calculation = integrationRetryWorkspace 2 "ref-plutus-scri H.diffVsGoldenFile output "test/cardano-testnet-test/files/calculatePlutusScriptCost.json" --- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Normal Script/"@ +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Normal Script/"'@ hprop_included_plutus_cost_calculation :: Property hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-plutus-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os @@ -231,8 +239,12 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p epochStateView <- getEpochStateView configurationFile (nodeSocketPath poolNode1) includedScriptLockWork <- H.createDirectoryIfMissing $ work "included-script-lock" - plutusV3Script <- - File <$> liftIOAnnotated (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus") + + plutusScriptFp <- H.note $ work "always-succeeds-script.plutusV3" + H.writeFile plutusScriptFp $ Text.unpack Defaults.plutusV3Script + + --_plutusV3Script <- + -- File <$> liftIOAnnotated (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus") let includedScriptLockAmount = 10_000_000 enoughAmountForFees = 2_000_000 -- Needs to be more than min ada @@ -246,7 +258,7 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p includedScriptLockWork "tx-body" wallet0 - [(ScriptAddress plutusV3Script, includedScriptLockAmount, Nothing)] + [(ScriptAddress $ File plutusScriptFp, includedScriptLockAmount, Nothing)] signedTxIncludedScriptLock <- signTx execConfig @@ -270,7 +282,8 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p includedScriptUnlock <- H.createDirectoryIfMissing $ work "included-script-unlock" let unsignedIncludedScript = File $ includedScriptUnlock "unsigned-tx.tx" newLargestUTxO <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - + scriptHash <- execCli' execConfig [ eraName, "transaction", "policyid", "--script-file", plutusScriptFp] + H.note_ $ "Script hash: " <> scriptHash void $ execCli' execConfig @@ -278,7 +291,7 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p , "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", prettyShow (TxIn txIdIncludedScriptLock txIxIncludedScriptLock) - , "--tx-in-script-file", unFile plutusV3Script + , "--tx-in-script-file", plutusScriptFp , "--tx-in-redeemer-value", "42" , "--tx-in-collateral", prettyShow newLargestUTxO , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show (unCoin (includedScriptLockAmount - enoughAmountForFees)) @@ -311,7 +324,7 @@ hprop_included_plutus_cost_calculation = integrationRetryWorkspace 2 "included-p (unFile includedScriptCostOutput) "test/cardano-testnet-test/files/calculatePlutusScriptCost.json" --- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Simple Script/"@ +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Spec.hs.Spec.Ledger Events.Plutus.Cost Calc.Simple Script/"'@ hprop_included_simple_script_cost_calculation :: Property hprop_included_simple_script_cost_calculation = integrationRetryWorkspace 2 "included-simple-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do H.note_ SYS.os diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/MultiAssetReturnCollateral.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/MultiAssetReturnCollateral.hs new file mode 100644 index 00000000000..537e579682c --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/MultiAssetReturnCollateral.hs @@ -0,0 +1,193 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + + + +module Cardano.Testnet.Test.Cli.Plutus.MultiAssetReturnCollateral + ( hprop_collateral_with_tokens + ) where + +import Cardano.Api +import Cardano.Testnet + +import Prelude +import qualified Data.Aeson as Aeson +import Control.Monad (void) +import Data.Default.Class +import qualified Data.Text as T +import System.FilePath (()) + +import Testnet.Components.Configuration +import Testnet.Components.Query +import Testnet.Defaults +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace, decodeEraUTxO) +import Testnet.Types + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Extras as H + +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Collateral With Multiassets/"'@ +hprop_collateral_with_tokens :: Property +hprop_collateral_with_tokens = integrationWorkspace "collateral-with-tokens" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do + conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' + ceo = ConwayEraOnwardsConway + sbe = convert ceo + era = toCardanoEra sbe + anyEra = AnyCardanoEra era + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + + TestnetRuntime + { configurationFile + , testnetMagic + , testnetNodes + , wallets=wallet0:wallet1:_ + } <- createAndRunTestnet options def conf + + node <- H.headM testnetNodes + poolSprocket1 <- H.noteShow $ nodeSprocket node + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + H.noteShow_ wallet0 + let utxoAddr = T.unpack $ paymentKeyInfoAddr wallet0 + utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 + socketPath = nodeSocketPath node + + epochStateView <- getEpochStateView configurationFile socketPath + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 + txinCollateral <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 + + void $ execCli' execConfig + [ anyEraToString anyEra, "query", "utxo" + , "--address", T.unpack $ paymentKeyInfoAddr wallet0 + , "--cardano-mode" + , "--out-file", work "utxo-1.json" + ] + + utxo1Json <- H.leftFailM . H.readJsonFile $ work "utxo-1.json" + H.noteShowM_ $ decodeEraUTxO sbe utxo1Json + -- Create a simple always-succeeds Plutus V3 script + plutusScript <- H.note $ work "always-succeeds-script.plutusV3" + H.writeFile plutusScript $ T.unpack plutusV3Script + + + -- Get the policy ID + mintingPolicyId <- filter (/= '\n') <$> + execCli' execConfig + [ anyEraToString anyEra, "transaction" + , "policyid" + , "--script-file", plutusScript + ] + + let assetName = "7161636f696e" -- "qacoin" in hex + + -- Create a Plutus script address + plutusSpendingScriptAddr <- + execCli' execConfig + [ "latest", "address", "build" + , "--payment-script-file", plutusScript + ] + + + -- STEP 1: Mint tokens and send to an address we control + -- This address will later be used as a collateral UTxO + let mintTokensTxBody = work "mint-tokens-tx-body" + mintTokensTx = work "mint-tokens-tx" + collateralAddr = T.unpack $ paymentKeyInfoAddr wallet1 + mintValue = mconcat ["100 ", mintingPolicyId, ".", assetName] + collateralValue = mconcat [collateralAddr, "+", show @Int 3_000_000, "+", mintValue] + fundScriptValue = mconcat [plutusSpendingScriptAddr, "+", show @Int 5_000_000] + + void $ execCli' execConfig + [ anyEraToString anyEra, "transaction", "build" + , "--change-address", utxoAddr + , "--tx-in", T.unpack $ renderTxIn txin1 + , "--tx-in-collateral", T.unpack $ renderTxIn txinCollateral + , "--witness-override", show @Int 2 + , "--tx-out", collateralValue + , "--tx-out", fundScriptValue + , "--tx-out-datum-hash-value", "0" + , "--mint", mintValue + , "--mint-script-file", plutusScript + , "--mint-redeemer-value", "0" + , "--out-file", mintTokensTxBody + ] + + void $ execCli' execConfig + [ "latest", "transaction", "sign" + , "--tx-body-file", mintTokensTxBody + , "--signing-key-file", utxoSKeyFile + , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet1 + , "--out-file", mintTokensTx + ] + + void $ execCli' execConfig + [ "latest", "transaction", "submit" + , "--tx-file", mintTokensTx + ] + + + -- STEP 2: Attempt to spend from script with collateral containing tokens + -- This will fail because collateral cannot contain non-ADA tokens + + -- Wait for transactions to be processed and find UTxOs + _ <- waitForBlocks epochStateView 1 + + -- Find the UTxO with tokens at wallet1 (for collateral) + txinCollateralWithTokensM <- + findLargestMultiAssetUtxoWithAddress epochStateView sbe $ T.pack collateralAddr + (txinCollateralWithTokens, collateralTxOut) <- H.evalMaybe txinCollateralWithTokensM + H.note_ "Collateral TxOut" + H.noteShow_ collateralTxOut + -- Find the UTxO at the script address + plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 10) $ + findLargestUtxoWithAddress epochStateView sbe $ T.pack plutusSpendingScriptAddr + + let spendScriptUTxOTxBody = work "spend-script-utxo-tx-body" + spendScriptUTxOTx = work "spend-script-utxo-tx" + + void $ execCli' execConfig + [ anyEraToString anyEra, "transaction", "build" + , "--change-address", T.unpack $ paymentKeyInfoAddr wallet0 + , "--tx-in", T.unpack $ renderTxIn plutusScriptTxIn + , "--tx-in-script-file", plutusScript + , "--tx-in-datum-value", "0" + , "--tx-in-redeemer-value", "0" + , "--tx-in-collateral", T.unpack $ renderTxIn txinCollateralWithTokens -- This is the key issue - using collateral with tokens + , "--out-file", spendScriptUTxOTxBody + ] + let prettyTxBodyFile = work "spend-script-utxo-tx-body-view.json" + void $ execCli' execConfig ["debug", "transaction", "view", "--tx-body-file", spendScriptUTxOTxBody, "--out-file", prettyTxBodyFile] + + txBodyPrettyJson :: Aeson.Value <- H.leftFailM . H.readJsonFile $ prettyTxBodyFile + H.note_ "Tx body" + H.noteShowPretty_ txBodyPrettyJson + + void $ execCli' execConfig + [ "latest", "transaction", "sign" + , "--tx-body-file", spendScriptUTxOTxBody + , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet1 + , "--out-file", spendScriptUTxOTx + ] + + let prettyTxFile = work "spend-script-utxo-tx-view.json" + void $ execCli' execConfig ["debug", "transaction", "view", "--tx-file", spendScriptUTxOTx, "--out-file", prettyTxFile] + + txPrettyJson :: Aeson.Value <- H.leftFailM . H.readJsonFile $ prettyTxFile + H.noteShowPretty_ txPrettyJson + + -- This will fail with the "CollateralContainsNonADA" error + void $ execCli' execConfig + [ "latest", "transaction", "submit" + , "--tx-file", spendScriptUTxOTx + ] + + H.success \ No newline at end of file diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/Scripts.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/Scripts.hs index 04af096fb13..50c7433572f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/Scripts.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Plutus/Scripts.hs @@ -44,7 +44,7 @@ import qualified Hedgehog.Extras as H -- Voting NO -- Proposing NO -- Execute me with: --- @DISABLE_RETRIES=1 cabal run cardano-testnet-test -- -p "/Spec.hs.Spec.Ledger Events.Plutus.Scripts/"@ +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/PlutusV3 purposes/"'@ hprop_plutus_purposes_v3 :: Property hprop_plutus_purposes_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' @@ -194,7 +194,7 @@ hprop_plutus_purposes_v3 = integrationWorkspace "all-plutus-script-purposes" $ \ -- | -- Execute me with: --- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/PlutusV2 Create transaction with two script certs/"'@ +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/PlutusV2 transaction with two script certs/"'@ hprop_tx_two_script_certs_v2 :: Property hprop_tx_two_script_certs_v2 = integrationWorkspace "tx-2-script-certs" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' @@ -229,7 +229,7 @@ hprop_tx_two_script_certs_v2 = integrationWorkspace "tx-2-script-certs" $ \tempA txin <- T.unpack . renderTxIn <$> findLargestUtxoForPaymentKey epochStateView sbe wallet0 plutusScript <- H.note $ work "always-succeeds-script.plutusV2" - H.writeFile plutusScript $ T.unpack plutusV2StakeScript + H.writeFile plutusScript $ T.unpack plutusV3Script scriptStakeRegistrationCertificate <- H.note $ work "script-stake-registration-certificate" @@ -257,7 +257,9 @@ hprop_tx_two_script_certs_v2 = integrationWorkspace "tx-2-script-certs" $ \tempA let txbody = work "two-certs-tx-body" tx = work "two-certs-tx" txout = mconcat [ utxoAddr, "+", show @Int 2_000_000 ] - + + s <- execCli' execConfig [anyEraToString anyEra, "transaction", "policyid", "--script-file", plutusScript] + H.note_ $ "Script hash: " <> s let txBuildArgs = [ anyEraToString anyEra, "transaction", "build" , "--change-address", T.unpack $ paymentKeyInfoAddr wallet0 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/CostCalculation.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/CostCalculation.hs new file mode 100644 index 00000000000..3c46c75f64c --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/CostCalculation.hs @@ -0,0 +1,192 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Cardano.Testnet.Test.Cli.Scripts.Simple.CostCalculation + ( hprop_ref_simple_script_mint + ) where + +import Cardano.Api hiding (Value) +import Cardano.Api.Experimental (Some (Some)) +import Cardano.Api.Ledger (EpochInterval (..)) +import Cardano.Testnet + +import Prelude +import Testnet.Types + +import Control.Monad (void) + +import Data.Default.Class (Default (def)) +import qualified Data.Text as Text +import System.Directory (makeAbsolute) +import System.FilePath (()) +import qualified System.Info as SYS + +import Testnet.Components.Query (getEpochStateView, getTxIx, + watchEpochStateUpdate) +import qualified Testnet.Defaults as Defaults +import Testnet.Process.Cli.Transaction (TxOutAddress (..), mkSpendOutputsOnlyTx, + retrieveTransactionId, signTx, submitTx) +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Process.RunIO (liftIOAnnotated) +import Testnet.Property.Util (integrationRetryWorkspace) +import Testnet.Start.Types (eraToString) + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Extras.Test.Base as H +import qualified Hedgehog.Extras.Test.File as H +import qualified Hedgehog.Extras.Test.TestWatchdog as H + +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Simple Script.Simple Reference Script Mint/"'@ +hprop_ref_simple_script_mint :: Property +hprop_ref_simple_script_mint = integrationRetryWorkspace 2 "ref-simple-script" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do + H.note_ SYS.os + conf@Conf{tempAbsPath} <- mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let + sbe = ShelleyBasedEraConway + era = toCardanoEra sbe + cEra = AnyCardanoEra era + eraName = eraToString era + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' + options = def{cardanoNodeEra = AnyShelleyBasedEra sbe} + + TestnetRuntime + { configurationFile + , testnetMagic + , testnetNodes + , wallets = wallet0 : wallet1 : _ + } <- + createAndRunTestnet options def conf + + poolNode1 <- H.headM testnetNodes + poolSprocket1 <- H.noteShow $ nodeSprocket poolNode1 + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + epochStateView <- getEpochStateView configurationFile (nodeSocketPath poolNode1) + + refScriptSizeWork <- H.createDirectoryIfMissing $ work "ref-script-publish" + -- No longer using plutus script for reference script + _plutusV3Script <- + File <$> liftIOAnnotated (makeAbsolute "test/cardano-testnet-test/files/plutus/v3/always-succeeds.plutus") + + let utxoVKeyFile2 = verificationKeyFp $ paymentKeyInfoPair wallet1 + + reqSignerHash <- filter (/= '\n') <$> + execCli' execConfig + [ eraName, "address", "key-hash" + , "--payment-verification-key-file", utxoVKeyFile2 + ] + simpleScriptFp <- H.note $ work "example-simple-script.json" + H.writeFile simpleScriptFp $ Text.unpack $ Defaults.simpleScript $ Text.pack reqSignerHash + let scriptPublishUTxOAmount = 10_000_000 + + -- Submit a transaction to publish the reference script + txBodyPublishRefScript <- + mkSpendOutputsOnlyTx + execConfig + epochStateView + sbe + refScriptSizeWork + "tx-body" + wallet0 + [(ScriptAddress $ File simpleScriptFp, scriptPublishUTxOAmount, Just $ File simpleScriptFp)] + signedTxPublishRefScript <- + signTx + execConfig + cEra + refScriptSizeWork + "signed-tx" + txBodyPublishRefScript + [Some $ paymentKeyInfoPair wallet0] + submitTx execConfig cEra signedTxPublishRefScript + + -- Wait until transaction is on chain and obtain transaction identifier + txIdPublishRefScript <- retrieveTransactionId execConfig signedTxPublishRefScript + txIxPublishRefScript <- + H.evalMaybeM $ + watchEpochStateUpdate + epochStateView + (EpochInterval 2) + (getTxIx sbe txIdPublishRefScript scriptPublishUTxOAmount) + + -- Submit a transaction to lock money in the reference script + refScriptLock <- H.createDirectoryIfMissing $ work "ref-script-lock" + + let transferAmount = 20_000_000 + enoughAmountForFees = 2_000_000 -- Needs to be more than min ada + txBodyLock <- + mkSpendOutputsOnlyTx + execConfig + epochStateView + sbe + refScriptLock + "tx-body" + wallet0 + [(ScriptAddress $ File simpleScriptFp, transferAmount, Nothing)] + signedTxLock <- + signTx execConfig cEra refScriptLock "signed-tx" txBodyLock [Some $ paymentKeyInfoPair wallet0] + submitTx execConfig cEra signedTxLock + + -- Wait until transaction is on chain and obtain transaction identifier + txIdLock <- retrieveTransactionId execConfig signedTxLock + txIxLock <- + H.evalMaybeM $ + watchEpochStateUpdate epochStateView (EpochInterval 2) (getTxIx sbe txIdLock transferAmount) + + -- Create transaction that uses reference script + refScriptUnlock <- H.createDirectoryIfMissing $ work "ref-script-unlock" + let unsignedUnlockTx = File $ refScriptUnlock "unsigned-tx.tx" + refScriptHash <- execCli' execConfig [ eraName, "transaction", "policyid", "--script-file", simpleScriptFp] + H.note_ $ "Reference script hash: " <> refScriptHash + + void $ execCli' execConfig + [ eraName, "query", "utxo" + , "--whole-utxo" + , "--cardano-mode" + , "--out-file", work "utxo-1.json" + ] + H.cat $ work "utxo-1.json" + -- Attempt to mint from a refernce script + let assetName = "4D696C6C6172436F696E" + + + simpleMintingPolicyId <- filter (/= '\n') <$> + execCli' execConfig + [ eraName, "transaction" + , "policyid" + , "--script-file", simpleScriptFp + ] + let mintValue = mconcat ["5 ", simpleMintingPolicyId, ".", assetName] + void $ + execCli' + execConfig + [ eraName + , "transaction", "build" + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 + , "--tx-in", prettyShow (TxIn txIdLock txIxLock) + , "--mint", mintValue + , "--simple-minting-script-tx-in-reference", prettyShow (TxIn txIdPublishRefScript txIxPublishRefScript) + , "--policy-id", simpleMintingPolicyId + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show (unCoin (transferAmount - enoughAmountForFees)) + , "--out-file", unFile unsignedUnlockTx + ] + viewTx <- execCli' execConfig + ["debug" + , "transaction", "view" + , "--tx-file", unFile unsignedUnlockTx + ] + H.note_ viewTx + signedUnlockTx <- + signTx + execConfig + cEra + refScriptUnlock + "signed-tx" + unsignedUnlockTx + [Some $ paymentKeyInfoPair wallet1] + + submitTx execConfig cEra signedUnlockTx diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/Mint.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/Mint.hs new file mode 100644 index 00000000000..5886068ebca --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Scripts/Simple/Mint.hs @@ -0,0 +1,193 @@ + +{-# LANGUAGE DisambiguateRecordFields #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + + +module Cardano.Testnet.Test.Cli.Scripts.Simple.Mint + ( hprop_simple_script_mint + ) where + +import Cardano.Api +import qualified Cardano.Api.Ledger as L + +import Cardano.Testnet + +import Prelude + +import Control.Monad (void) +import Data.Default.Class +import qualified Data.Text as T +import System.FilePath (()) + +import Testnet.Components.Configuration +import Testnet.Components.Query +import Testnet.Defaults +import Testnet.Process.Cli.SPO +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) +import Testnet.Types + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Extras as H + +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Simple Script.Simple Script Mint/"'@ +hprop_simple_script_mint :: Property +hprop_simple_script_mint = integrationWorkspace "simple-script-mint" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do + conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' + ceo = ConwayEraOnwardsConway + sbe = convert ceo + era = toCardanoEra sbe + anyEra = AnyCardanoEra era + options = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + + TestnetRuntime + { configurationFile + , testnetMagic + , testnetNodes + , wallets=wallet0:wallet1:_ + } <- createAndRunTestnet options def conf + + node <- H.headM testnetNodes + poolSprocket1 <- H.noteShow $ nodeSprocket node + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + H.noteShow_ wallet0 + let utxoAddr = T.unpack $ paymentKeyInfoAddr wallet0 + utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 + utxoSKeyFile2 = signingKeyFp $ paymentKeyInfoPair wallet1 + utxoVKeyFile2 = verificationKeyFp $ paymentKeyInfoPair wallet1 + socketPath = nodeSocketPath node + + epochStateView <- getEpochStateView configurationFile socketPath + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 + + plutusScript <- H.note $ work "always-succeeds-script.plutusV3" + H.writeFile plutusScript $ T.unpack plutusV3SupplementalDatumScript + + let sendAdaToScriptAddressTxBody = work "send-ada-to-script-address-tx-body" + + plutusSpendingScriptAddr <- + execCli' execConfig + [ "latest", "address", "build" + , "--payment-script-file", plutusScript + ] + + let assetName = "4D696C6C6172436F696E" + H.note_ $ "plutusSpendingScriptAddr: " <> plutusSpendingScriptAddr + + scriptdatumhash <- filter (/= '\n') <$> + execCli' execConfig + [ "latest", "transaction", "hash-script-data" + , "--script-data-value", "0" + ] + + supplementalDatumJsonFile + <- H.note $ work "supplemental-datum.json" + H.writeFile supplementalDatumJsonFile "{\"int\":1}" + + scriptStakeRegistrationCertificate + <- H.note $ work "script-stake-registration-certificate" + + keyDeposit <- fromIntegral . L.unCoin <$> getKeyDeposit epochStateView ceo + -- Create script stake registration certificate + createScriptStakeRegistrationCertificate + tempAbsPath + anyEra + plutusScript + keyDeposit + scriptStakeRegistrationCertificate + + -- 1. Put UTxO and datum at script address + -- Register script stake address + void $ execCli' execConfig + [ anyEraToString anyEra, "transaction", "build" + , "--change-address", T.unpack $ paymentKeyInfoAddr wallet0 + , "--tx-in", T.unpack $ renderTxIn txin1 + , "--tx-out", plutusSpendingScriptAddr <> "+" <> show @Int 5_000_000 + , "--tx-out-datum-hash", scriptdatumhash + , "--out-file", sendAdaToScriptAddressTxBody + ] + + let sendAdaToScriptAddressTx = work "send-ada-to-script-address-tx" + void $ execCli' execConfig + [ "latest", "transaction", "sign" + , "--tx-body-file", sendAdaToScriptAddressTxBody + , "--signing-key-file", utxoSKeyFile + , "--out-file", sendAdaToScriptAddressTx + ] + + void $ execCli' execConfig + [ "latest", "transaction", "submit" + , "--tx-file", sendAdaToScriptAddressTx + ] + + -- 2. Successfully mint + txinCollateral <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 + plutusScriptTxIn <- fmap fst . retryUntilJustM epochStateView (WaitForBlocks 3) $ + findLargestUtxoWithAddress epochStateView sbe $ T.pack plutusSpendingScriptAddr + + let spendScriptUTxOTxBody = work "spend-script-utxo-tx-body" + spendScriptUTxOTx = work "spend-script-utxo-tx" + + txoutWithSupplementalDatum = mconcat [utxoAddr, "+", show @Int 1_000_000] + + -- Mint with a simple script + reqSignerHash <- filter (/= '\n') <$> + execCli' execConfig + [ anyEraToString anyEra, "address", "key-hash" + , "--payment-verification-key-file", utxoVKeyFile2 + ] + simpleScriptFp <- H.note $ work "example-simple-script.json" + H.writeFile simpleScriptFp $ T.unpack $ simpleScript $ T.pack reqSignerHash + + simpleMintingPolicyId <- filter (/= '\n') <$> + execCli' execConfig + [ anyEraToString anyEra, "transaction" + , "policyid" + , "--script-file", simpleScriptFp + ] + let mintValue = mconcat ["5 ", simpleMintingPolicyId, ".", assetName] + txout = mconcat [ utxoAddr, "+", show @Int 2_000_000 + , "+", mintValue + ] + void $ execCli' execConfig + [ anyEraToString anyEra, "transaction", "build" + , "--change-address", T.unpack $ paymentKeyInfoAddr wallet1 + , "--tx-in-collateral", T.unpack $ renderTxIn txinCollateral + , "--tx-in", T.unpack $ renderTxIn plutusScriptTxIn + , "--tx-in-script-file", plutusScript + , "--tx-in-datum-value", "0" + , "--tx-in-redeemer-value", "0" + , "--mint", mintValue + , "--mint-script-file", simpleScriptFp + , "--certificate-file", scriptStakeRegistrationCertificate + , "--certificate-script-file", plutusScript + , "--certificate-redeemer-value", "0" + , "--tx-out", txout + , "--tx-out", txoutWithSupplementalDatum + , "--tx-out-datum-embed-file", supplementalDatumJsonFile + , "--out-file", spendScriptUTxOTxBody + ] + + void $ execCli' execConfig + [ "latest", "transaction", "sign" + , "--tx-body-file", spendScriptUTxOTxBody + , "--signing-key-file", utxoSKeyFile2 + , "--out-file", spendScriptUTxOTx + ] + + void $ execCli' execConfig + [ "latest", "transaction", "submit" + , "--tx-file", spendScriptUTxOTx + ] + + H.success \ No newline at end of file diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/BuildEstimate.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/BuildEstimate.hs new file mode 100644 index 00000000000..71d8f1b0d6e --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/BuildEstimate.hs @@ -0,0 +1,110 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +module Cardano.Testnet.Test.Cli.Transaction.BuildEstimate + ( hprop_tx_build_estimate + ) where + +import Cardano.Api as Api + +import Cardano.Testnet + +import Prelude + +import Control.Monad +import Data.Default.Class + +import qualified Data.Text as Text +import System.FilePath (()) + +import Testnet.Components.Configuration +import Testnet.Components.Query +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.SPO ( + createStakeKeyRegistrationCertificate) +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) +import Testnet.Start.Types +import Testnet.Types + +import Hedgehog +import qualified Hedgehog.Extras as H + + +-- | Execute me with: +-- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Transaction Build Estimate/"'@ +hprop_tx_build_estimate :: Property +hprop_tx_build_estimate = integrationWorkspace "transaction-build-estimate" $ \tempAbsBasePath' -> H.runWithDefaultWatchdog_ $ do + -- Start a local test net + conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath + + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let ceo = ConwayEraOnwardsConway + sbe = convert ceo + eraName = eraToString sbe + fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe } + shelleyOptions = def { genesisEpochLength = 200 } + + TestnetRuntime + { testnetMagic + , testnetNodes + , wallets=wallet0:wallet1:_ + , configurationFile + } + <- createAndRunTestnet fastTestnetOptions shelleyOptions conf + + node <- H.headM testnetNodes + poolSprocket1 <- H.noteShow $ nodeSprocket node + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + let socketPath = nodeSocketPath node + + epochStateView <- getEpochStateView configurationFile socketPath + + H.note_ $ "Sprocket: " <> show poolSprocket1 + H.note_ $ "Abs path: " <> tempAbsBasePath' + H.note_ $ "Socketpath: " <> unFile socketPath + H.note_ $ "Foldblocks config file: " <> unFile configurationFile + + -- Register stake address + let stakeCertFp = work "stake.regcert" + stakeKeys = KeyPair { verificationKey = File $ work "stake.vkey" + , signingKey = File $ work "stake.skey" + } + + cliStakeAddressKeyGen stakeKeys + keyDeposit <- getKeyDeposit epochStateView ceo + createStakeKeyRegistrationCertificate + tempAbsPath (AnyShelleyBasedEra sbe) (verificationKey stakeKeys) keyDeposit stakeCertFp + + + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 + + void $ execCli' execConfig + [ eraName, "query", "protocol-parameters" + , "--cardano-mode" + , "--out-file", work "pparams.json" + ] + + void $ execCli' execConfig + [ eraName, "transaction", "build-estimate" + , "--shelley-key-witnesses", "2" + , "--byron-key-witnesses", "0" + , "--reference-script-size", "0" + , "--total-utxo-value", "10800380" + , "--tx-in", Text.unpack $ renderTxIn txin1 + , "--certificate-file", stakeCertFp + , "--certificate-file", stakeCertFp + , "--certificate-file", stakeCertFp + , "--certificate-file", stakeCertFp + , "--certificate-file", stakeCertFp + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 10_000_000 + , "--protocol-params-file", work "pparams.json" + , "--out-file", "test_addr_registration_certificate_order[build_estimate-submit_api]_ci2_hcrhrg_tx.body" + ] \ No newline at end of file diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/RegisterDeregisterStakeAddress.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/RegisterDeregisterStakeAddress.hs index 3b4e7ff5e9d..0aadc10d042 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/RegisterDeregisterStakeAddress.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Transaction/RegisterDeregisterStakeAddress.hs @@ -36,6 +36,7 @@ import Hedgehog import qualified Hedgehog as H import qualified Hedgehog.Extras as H + -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/register deregister stake address in transaction build/"'@ hprop_tx_register_deregister_stake_address :: Property diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs index 6b7ed5028c2..2ee101ed924 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/CommitteeAddNew.hs @@ -131,6 +131,7 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co createStakeKeyRegistrationCertificate tempAbsPath (AnyShelleyBasedEra sbe) (verificationKey stakeKeys) keyDeposit stakeCertFp + stakeCertTxBodyFp <- H.note $ work "stake.registration.txbody" stakeCertTxSignedFp <- H.note $ work "stake.registration.tx" @@ -153,14 +154,20 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co , "--signing-key-file", signingKeyFp stakeKeys , "--out-file", stakeCertTxSignedFp ] + -- TODO: Left off here. No certificate was in transaction! + stakeCertTx <- execCli' execConfig + ["debug", "transaction" + , "view", "--output-json", "--tx-body-file", stakeCertTxBodyFp + ] + H.note_ $ "Stake registration transaction: " <> stakeCertTx void $ execCli' execConfig [ eraName, "transaction", "submit" , "--tx-file", stakeCertTxSignedFp ] -- make sure that stake registration cert gets into a block - _ <- waitForBlocks epochStateView 1 + _ <- waitForBlocks epochStateView 15 minGovActDeposit <- getMinGovActionDeposit epochStateView ceo @@ -187,6 +194,20 @@ hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-co txbodyFp <- H.note $ work "tx.body" txin1' <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 + + + void $ execCli' execConfig + [ eraName, "stake-address", "key-hash" + , "--stake-verification-key-file", verificationKeyFp stakeKeys + , "--out-file", gov "stake-hash.addr" + ] + + stakeKeyHash <- H.readFile $ gov "stake-hash.addr" + + H.note_ $ "Stake key hash:" <> stakeKeyHash + + + -- Create temporary HTTP server with files required by the call to `cardano-cli` -- In this case, the server emulates an IPFS gateway serveFilesWhile diff --git a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs index a142563b4ae..24c486ce4d1 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -23,6 +23,7 @@ import qualified Cardano.Testnet.Test.Gov.DRepRetirement as Gov import qualified Cardano.Testnet.Test.Gov.GovActionTimeout as Gov import qualified Cardano.Testnet.Test.Gov.InfoAction as LedgerEvents import qualified Cardano.Testnet.Test.Gov.PParamChangeFailsSPO as Gov +import qualified Cardano.Testnet.Test.Cli.Scripts.Simple.Mint import qualified Cardano.Testnet.Test.Gov.ProposeNewConstitution as Gov import qualified Cardano.Testnet.Test.Gov.Transaction.HashMismatch as WrongHash import qualified Cardano.Testnet.Test.Gov.TreasuryDonation as Gov @@ -33,6 +34,9 @@ import qualified Cardano.Testnet.Test.RunTestnet import qualified Cardano.Testnet.Test.SanityCheck as LedgerEvents import qualified Cardano.Testnet.Test.SubmitApi.Transaction import qualified Cardano.Testnet.Test.UpdateTimeStamps +import qualified Cardano.Testnet.Test.Cli.Scripts.Simple.CostCalculation +import qualified Cardano.Testnet.Test.Cli.Transaction.BuildEstimate +import qualified Cardano.Testnet.Test.Cli.Plutus.MultiAssetReturnCollateral import Prelude @@ -79,9 +83,15 @@ tests = do , ignoreOnWindows "InfoAction" LedgerEvents.hprop_ledger_events_info_action , ignoreOnWindows "Transaction Build Wrong Hash" WrongHash.hprop_transaction_build_wrong_hash ] + , T.testGroup "Simple Script" + [ ignoreOnWindows "Simple Script Mint" Cardano.Testnet.Test.Cli.Scripts.Simple.Mint.hprop_simple_script_mint + , ignoreOnWindows "Simple Reference Script Mint" Cardano.Testnet.Test.Cli.Scripts.Simple.CostCalculation.hprop_ref_simple_script_mint + + ] , T.testGroup "Plutus" [ ignoreOnWindows "PlutusV3 purposes" Cardano.Testnet.Test.Cli.Plutus.Scripts.hprop_plutus_purposes_v3 , ignoreOnWindows "PlutusV2 transaction with two script certs" Cardano.Testnet.Test.Cli.Plutus.Scripts.hprop_tx_two_script_certs_v2 + , ignoreOnWindows "Collateral With Multiassets" Cardano.Testnet.Test.Cli.Plutus.MultiAssetReturnCollateral.hprop_collateral_with_tokens , T.testGroup "Cost Calc" [ ignoreOnWindows "Ref Script" Cardano.Testnet.Test.Cli.Plutus.CostCalculation.hprop_ref_plutus_cost_calculation , ignoreOnWindows "Normal Script" Cardano.Testnet.Test.Cli.Plutus.CostCalculation.hprop_included_plutus_cost_calculation @@ -99,6 +109,7 @@ tests = do , ignoreOnWindows "Shutdown On SlotSynced" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSlotSynced , ignoreOnWindows "stake snapshot" Cardano.Testnet.Test.Cli.StakeSnapshot.hprop_stakeSnapshot , ignoreOnWindows "simple transaction build" Cardano.Testnet.Test.Cli.Transaction.hprop_transaction + , ignoreOnWindows "Transaction Build Estimate" Cardano.Testnet.Test.Cli.Transaction.BuildEstimate.hprop_tx_build_estimate , ignoreOnWindows "register deregister stake address in transaction build" Cardano.Testnet.Test.Cli.Transaction.RegisterDeregisterStakeAddress.hprop_tx_register_deregister_stake_address -- FIXME -- , ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.LeadershipSchedule.hprop_leadershipSchedule diff --git a/cardano-testnet/test/cardano-testnet-test/files/calculatePlutusScriptCost.json b/cardano-testnet/test/cardano-testnet-test/files/calculatePlutusScriptCost.json index 98a7e4de9bd..b2d1ef63f2c 100644 --- a/cardano-testnet/test/cardano-testnet-test/files/calculatePlutusScriptCost.json +++ b/cardano-testnet/test/cardano-testnet-test/files/calculatePlutusScriptCost.json @@ -7,4 +7,4 @@ "lovelaceCost": 34, "scriptHash": "186e32faa80a26810392fda6d559c7ed4721a65ce1c9d4ef3e1c87b4" } -] \ No newline at end of file +] diff --git a/cardano-testnet/test/cardano-testnet-test/files/emptysimplescriptcostcalc.json b/cardano-testnet/test/cardano-testnet-test/files/emptysimplescriptcostcalc.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/files/emptysimplescriptcostcalc.json @@ -0,0 +1 @@ +[] \ No newline at end of file