diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 0343db57ec8..bd84a3d9954 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -173,6 +173,7 @@ test-suite cardano-testnet-test Cardano.Testnet.Test.Cli.Babbage.Transaction Cardano.Testnet.Test.Cli.Conway.DRepRetirement Cardano.Testnet.Test.Cli.Conway.Plutus + Cardano.Testnet.Test.Cli.Conway.RepeatedCertificatesInTransaction Cardano.Testnet.Test.Cli.Conway.StakeSnapshot Cardano.Testnet.Test.Cli.KesPeriodInfo Cardano.Testnet.Test.Cli.Queries diff --git a/cardano-testnet/src/Testnet/Components/SPO.hs b/cardano-testnet/src/Testnet/Components/SPO.hs index ba73c57c7dc..1f1dc8ecaf6 100644 --- a/cardano-testnet/src/Testnet/Components/SPO.hs +++ b/cardano-testnet/src/Testnet/Components/SPO.hs @@ -1,14 +1,16 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Testnet.Components.SPO ( checkStakeKeyRegistered - , convertToEraFlag , createScriptStakeRegistrationCertificate , createStakeDelegationCertificate , createStakeKeyRegistrationCertificate + , createStakeKeyDeregistrationCertificate , decodeEraUTxO , registerSingleSpo ) where @@ -115,12 +117,12 @@ createStakeDelegationCertificate -> String -- ^ Pool id -> FilePath -> m () -createStakeDelegationCertificate tempAbsP anyCera delegatorStakeVerKey poolId outputFp = +createStakeDelegationCertificate tempAbsP (AnyCardanoEra cEra) delegatorStakeVerKey poolId outputFp = GHC.withFrozenCallStack $ do let tempAbsPath' = unTmpAbsPath tempAbsP - void $ execCli - [ "stake-address", "delegation-certificate" - , convertToEraFlag anyCera + execCli_ + [ eraToString cEra + , "stake-address", "stake-delegation-certificate" , "--stake-verification-key-file", delegatorStakeVerKey , "--stake-pool-id", poolId , "--out-file", tempAbsPath' outputFp @@ -131,44 +133,71 @@ createStakeKeyRegistrationCertificate => TmpAbsolutePath -> AnyCardanoEra -> FilePath -- ^ Stake verification key file + -> Int -- ^ deposit amount used only in Conway -> FilePath -- ^ Output file path -> m () -createStakeKeyRegistrationCertificate tempAbsP anyCEra stakeVerKey outputFp = - GHC.withFrozenCallStack $ do - let tempAbsPath' = unTmpAbsPath tempAbsP - - void $ execCli - [ "stake-address", "registration-certificate" - , convertToEraFlag anyCEra - , "--stake-verification-key-file", stakeVerKey - , "--out-file", tempAbsPath' outputFp - ] +createStakeKeyRegistrationCertificate tempAbsP (AnyCardanoEra cEra) stakeVerKey deposit outputFp = GHC.withFrozenCallStack $ do + sbe <- requireEon cEra + let tempAbsPath' = unTmpAbsPath tempAbsP + extraArgs = caseShelleyToBabbageOrConwayEraOnwards + (const []) + (const ["--key-reg-deposit-amt", show deposit]) + sbe + execCli_ $ + [ eraToString cEra + , "stake-address", "registration-certificate" + , "--stake-verification-key-file", stakeVerKey + , "--out-file", tempAbsPath' outputFp + ] + <> extraArgs createScriptStakeRegistrationCertificate :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) => TmpAbsolutePath -> AnyCardanoEra -> FilePath -- ^ Script file - -> Int -- ^ Registration deposit amount + -> Int -- ^ Registration deposit amount used only in Conway -> FilePath -- ^ Output file path -> m () -createScriptStakeRegistrationCertificate tempAbsP anyCEra scriptFile deposit outputFp = +createScriptStakeRegistrationCertificate tempAbsP (AnyCardanoEra cEra) scriptFile deposit outputFp = GHC.withFrozenCallStack $ do + sbe <- requireEon cEra let tempAbsPath' = unTmpAbsPath tempAbsP - - void $ execCli - [ anyEraToString anyCEra + extraArgs = caseShelleyToBabbageOrConwayEraOnwards + (const []) + (const ["--key-reg-deposit-amt", show deposit]) + sbe + execCli_ $ + [ eraToString cEra , "stake-address", "registration-certificate" , "--stake-script-file", scriptFile - , "--key-reg-deposit-amt", show deposit , "--out-file", tempAbsPath' outputFp ] + <> extraArgs - --- TODO: Remove me and replace with new era based commands --- i.e "conway", "babbage" etc -convertToEraFlag :: AnyCardanoEra -> String -convertToEraFlag era = "--" <> anyEraToString era <> "-era" +createStakeKeyDeregistrationCertificate + :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) + => TmpAbsolutePath + -> AnyCardanoEra + -> FilePath -- ^ Stake verification key file + -> Int -- ^ deposit amount used only in Conway + -> FilePath -- ^ Output file path + -> m () +createStakeKeyDeregistrationCertificate tempAbsP (AnyCardanoEra cEra) stakeVerKey deposit outputFp = + GHC.withFrozenCallStack $ do + sbe <- requireEon cEra + let tempAbsPath' = unTmpAbsPath tempAbsP + extraArgs = caseShelleyToBabbageOrConwayEraOnwards + (const []) + (const ["--key-reg-deposit-amt", show deposit]) + sbe + execCli_ $ + [ eraToString cEra + , "stake-address" , "deregistration-certificate" + , "--stake-verification-key-file", stakeVerKey + , "--out-file", tempAbsPath' outputFp + ] + <> extraArgs -- | Related documentation: https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/stake-pool-operations/8_register_stakepool.md registerSingleSpo @@ -192,7 +221,6 @@ registerSingleSpo registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') cTestnetOptions execConfig (fundingInput, fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do let testnetMag = cardanoTestnetMagic cTestnetOptions - eraFlag= convertToEraFlag $ cardanoNodeEra cTestnetOptions workDir <- H.note tempAbsPath' @@ -251,11 +279,12 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') cTestnetOptions -- 5. Create registration certificate let poolRegCertFp = spoReqDir "registration.cert" + let era = cardanoNodeEra cTestnetOptions -- The pledge, pool cost and pool margin can all be 0 execCli_ - [ "stake-pool", "registration-certificate" - , "--babbage-era" + [ anyEraToString era + , "stake-pool", "registration-certificate" , "--testnet-magic", show @Int testnetMag , "--pool-pledge", "0" , "--pool-cost", "0" @@ -272,15 +301,14 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') cTestnetOptions -- Create pledger registration certificate - createStakeKeyRegistrationCertificate - tap - (cardanoNodeEra cTestnetOptions) + createStakeKeyRegistrationCertificate tap era poolOwnerstakeVkeyFp + 2_000_000 (workDir "pledger.regcert") void $ execCli' execConfig - [ "transaction", "build" - , eraFlag + [ anyEraToString era + , "transaction", "build" , "--change-address", changeAddr , "--tx-in", Text.unpack $ renderTxIn fundingInput , "--tx-out", poolowneraddresswstakecred <> "+" <> show @Int 5_000_000 @@ -310,7 +338,7 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') cTestnetOptions ] -- TODO: Currently we can't propagate the error message thrown by checkStakeKeyRegistered when using byDurationM -- Instead we wait 15 seconds - threadDelay 15_000000 + threadDelay 15_000_000 -- Check the pledger/owner stake key was registered delegsAndRewards <- checkStakeKeyRegistered @@ -331,4 +359,3 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') cTestnetOptions poolColdVkeyFp currentRegistedPoolsJson return (poolId, poolColdSkeyFp, poolColdVkeyFp, vrfSkeyFp, vrfVkeyFp) - diff --git a/cardano-testnet/src/Testnet/Property/Utils.hs b/cardano-testnet/src/Testnet/Property/Utils.hs index 804c65bb3fe..30c5a673868 100644 --- a/cardano-testnet/src/Testnet/Property/Utils.hs +++ b/cardano-testnet/src/Testnet/Property/Utils.hs @@ -3,6 +3,7 @@ {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} module Testnet.Property.Utils ( integration @@ -19,6 +20,7 @@ module Testnet.Property.Utils , getShelleyGenesisHash , decodeEraUTxO + , requireEon ) where import Cardano.Api @@ -36,6 +38,7 @@ import Data.Aeson.Key import Data.Aeson.KeyMap hiding (map) import qualified Data.ByteString as BS import Data.Text (Text) +import Data.Typeable import Data.Word import GHC.Stack import qualified GHC.Stack as GHC @@ -44,6 +47,8 @@ import qualified System.Environment as IO import System.Info (os) import qualified System.IO.Unsafe as IO +import Testnet.Start.Types + import qualified Hedgehog as H import qualified Hedgehog.Extras as H import Hedgehog.Internal.Property (MonadTest) @@ -122,3 +127,18 @@ runInBackground act = void . H.evalM $ allocate (H.async act) cleanUp decodeEraUTxO :: (IsShelleyBasedEra era, MonadTest m) => ShelleyBasedEra era -> Aeson.Value -> m (UTxO era) decodeEraUTxO _ = H.jsonErrorFail . Aeson.fromJSON + + +requireEon :: forall eon era m. Eon eon + => HasCallStack + => Typeable (eon era) + => MonadTest m + => CardanoEra era -- ^ node era + -> m (eon era) +requireEon era = withFrozenCallStack $ + maybe + (H.note_ errorMessage >> H.failure) + pure + (forEraMaybeEon era) + where + errorMessage = "Cannot witness '" <> show (typeRep (Proxy @(eon era))) <> "' in " <> eraToString era <> " era." diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs index 80afa1b97c1..bce8115ecaf 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/LeadershipSchedule.hs @@ -1,5 +1,4 @@ {-# LANGUAGE BlockArguments #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NumericUnderscores #-} @@ -135,6 +134,7 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch tempAbsPath (cardanoNodeEra cTestnetOptions) testDelegatorVkeyFp + 2_000_000 testDelegatorRegCertFp -- Test stake address deleg cert @@ -161,12 +161,12 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch UTxO utxo2 <- H.noteShowM $ decodeEraUTxO sbe utxo2Json txin2 <- H.noteShow =<< H.headM (Map.keys utxo2) - let eraFlag = convertToEraFlag $ cardanoNodeEra cTestnetOptions + let eraString = anyEraToString $ cardanoNodeEra cTestnetOptions delegRegTestDelegatorTxBodyFp = work "deleg-register-test-delegator.txbody" void $ execCli' execConfig - [ "transaction", "build" - , eraFlag + [ eraString + , "transaction", "build" , "--change-address", testDelegatorPaymentAddr -- NB: A large balance ends up at our test delegator's address , "--tx-in", Text.unpack $ renderTxIn txin2 , "--tx-out", utxoAddr <> "+" <> show @Int 5_000_000 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs index 616dc3193e9..ff14b15057d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/Transaction.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/DRepRetirement.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/DRepRetirement.hs index 1ece0bbec81..279359f1e4e 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/DRepRetirement.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/DRepRetirement.hs @@ -7,12 +7,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -#if __GLASGOW_HASKELL__ >= 908 -{-# OPTIONS_GHC -Wno-x-partial #-} -#endif - -{- HLINT ignore "Use head" -} - module Cardano.Testnet.Test.Cli.Conway.DRepRetirement ( hprop_drep_retirement ) where @@ -64,7 +58,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA TestnetRuntime { testnetMagic , poolNodes - , wallets + , wallets=wallet0:_ , configurationFile } <- cardanoTestnetDefault fastTestnetOptions conf @@ -111,7 +105,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA , "--out-file", drepCertFile n ] - txin1 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 0 + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 -- Submit registration certificates drepRegTxbodyFp <- H.note $ work "drep.registration.txbody" @@ -120,7 +114,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA H.noteM_ $ H.execCli' execConfig [ "conway", "transaction", "build" , "--tx-in", Text.unpack $ renderTxIn txin1 - , "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0 + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--certificate-file", drepCertFile 1 , "--certificate-file", drepCertFile 2 , "--certificate-file", drepCertFile 3 @@ -131,7 +125,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA H.noteM_ $ H.execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", drepRegTxbodyFp - , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0 + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair wallet0 , "--signing-key-file", drepSKeyFp 1 , "--signing-key-file", drepSKeyFp 2 , "--signing-key-file", drepSKeyFp 3 @@ -161,12 +155,12 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA H.noteM_ $ H.execCli' execConfig [ "conway", "query", "utxo" - , "--address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0 + , "--address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--cardano-mode" , "--out-file", work "utxo-11.json" ] - txin2 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 0 + txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 drepRetirementRegTxbodyFp <- H.note $ work "drep.retirement.txbody" drepRetirementRegTxSignedFp <- H.note $ work "drep.retirement.tx" @@ -174,7 +168,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA H.noteM_ $ H.execCli' execConfig [ "conway", "transaction", "build" , "--tx-in", Text.unpack $ renderTxIn txin2 - , "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0 + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--certificate-file", dreprRetirementCertFile , "--witness-override", "2" , "--out-file", drepRetirementRegTxbodyFp @@ -183,7 +177,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA H.noteM_ $ H.execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", drepRetirementRegTxbodyFp - , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0 + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair wallet0 , "--signing-key-file", drepSKeyFp 1 , "--out-file", drepRetirementRegTxSignedFp ] diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs index 8be8df0831b..6c1a09f6311 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/Plutus.hs @@ -10,7 +10,6 @@ {- HLINT ignore "Redundant id" -} {- HLINT ignore "Redundant return" -} {- HLINT ignore "Use head" -} -{- HLINT ignore "Use let" -} module Cardano.Testnet.Test.Cli.Conway.Plutus ( hprop_plutus_v3 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/RepeatedCertificatesInTransaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/RepeatedCertificatesInTransaction.hs new file mode 100644 index 00000000000..2ba09e53563 --- /dev/null +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/RepeatedCertificatesInTransaction.hs @@ -0,0 +1,134 @@ +{-# LANGUAGE DisambiguateRecordFields #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE NumericUnderscores #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +module Cardano.Testnet.Test.Cli.Conway.RepeatedCertificatesInTransaction where + +import Cardano.Api hiding (Value) + +import Cardano.Testnet + +import Prelude + +import Control.Monad (void) +import qualified Data.Aeson as A +import qualified Data.Aeson.Lens as L +import Data.String +import qualified Data.Text as Text +import Lens.Micro +import System.FilePath (()) +import qualified System.Info as SYS + +import Testnet.Components.Configuration (anyEraToString) +import Testnet.Components.Query +import Testnet.Components.SPO +import Testnet.Process.Cli hiding (File) +import qualified Testnet.Process.Run as H +import Testnet.Process.Run +import qualified Testnet.Property.Utils as H +import Testnet.Runtime + +import Hedgehog (Property, (===)) +import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO +import qualified Hedgehog.Extras.Test.Base as H +import qualified Hedgehog.Extras.Test.File as H + +hprop_repeated_certificates_in_transaction :: Property +hprop_repeated_certificates_in_transaction = H.integrationRetryWorkspace 0 "repeated-certificates-in-tx" $ \tempAbsBasePath' -> do + H.note_ SYS.os + conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' + let tempAbsPath' = unTmpAbsPath tempAbsPath + work <- H.createDirectoryIfMissing $ tempAbsPath' "work" + + let + sbe = ShelleyBasedEraBabbage + era = AnyCardanoEra $ toCardanoEra sbe + eraString = anyEraToString era + + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath' + options = cardanoDefaultTestnetOptions + { cardanoNodeEra = era + } + + TestnetRuntime + { configurationFile + , testnetMagic + , poolNodes + , wallets=wallet0:wallet1:_ + } <- cardanoTestnetDefault options conf + + poolNode1 <- H.headM poolNodes + poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 + execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + + let socketName' = IO.sprocketName poolSprocket1 + socketBase = IO.sprocketBase poolSprocket1 -- /tmp + socketPath = socketBase socketName' + epochStateView <- getEpochStateView (File configurationFile) (File socketPath) + + + let testStakeDelegator = work "test-delegator" + + H.createDirectoryIfMissing_ testStakeDelegator + let testDelegatorVkeyFp = testStakeDelegator "test-delegator.vkey" + testDelegatorSKeyFp = testStakeDelegator "test-delegator.skey" + testDelegatorPaymentVKeyFp = testStakeDelegator "test-delegator-payment.vkey" + testDelegatorPaymentSKeyFp = testStakeDelegator "test-delegator-payment.skey" + testDelegatorRegCertFp = testStakeDelegator "test-delegator.regcert" + testDelegatorDeregCertFp = testStakeDelegator "test-delegator.deregcert" + + _ <- cliStakeAddressKeyGen work + $ KeyNames testDelegatorVkeyFp testDelegatorSKeyFp + _ <- cliAddressKeyGen work + $ KeyNames testDelegatorPaymentVKeyFp testDelegatorPaymentSKeyFp + + testDelegatorPaymentAddr <- execCli + [ "address", "build" + , "--testnet-magic", show @Int testnetMagic + , "--payment-verification-key-file", testDelegatorPaymentVKeyFp + , "--stake-verification-key-file", testDelegatorVkeyFp + ] + + -- Test stake address registration cert + createStakeKeyRegistrationCertificate + tempAbsPath + era + testDelegatorVkeyFp + 2_000_000 + testDelegatorRegCertFp + + createStakeKeyDeregistrationCertificate + tempAbsPath + era + testDelegatorVkeyFp + 2_000_000 + testDelegatorDeregCertFp + + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 + multipleCertTxBodyFp <- H.note $ work "registration.txbody" + void $ execCli' execConfig + [ eraString + , "transaction", "build" + , "--change-address", testDelegatorPaymentAddr + , "--tx-in", Text.unpack $ renderTxIn txin1 + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 5_000_000 + , "--witness-override", show @Int 2 + , "--certificate-file", testDelegatorRegCertFp + , "--certificate-file", testDelegatorDeregCertFp + , "--certificate-file", testDelegatorRegCertFp + , "--certificate-file", testDelegatorDeregCertFp + , "--certificate-file", testDelegatorRegCertFp + , "--out-file", multipleCertTxBodyFp + ] + + txJson <- (H.leftFail . A.eitherDecode @A.Value . fromString) =<< H.execCli + ["transaction", "view" + , "--tx-file", multipleCertTxBodyFp + ] + A.Success certificates <- fmap (A.fromJSON @[A.Value]) . H.nothingFail $ txJson ^? L.key "certificates" + H.noteShow_ $ A.encode certificates + length certificates === 5 + diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs index a115589db66..8f3cdf289f8 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Conway/StakeSnapshot.hs @@ -3,8 +3,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} - module Cardano.Testnet.Test.Cli.Conway.StakeSnapshot ( hprop_stakeSnapshot ) where diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs index cc7c7c90e91..24b67202fb7 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/KesPeriodInfo.hs @@ -127,6 +127,7 @@ hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempA tempAbsPath (cardanoNodeEra cTestnetOptions) testDelegatorVkeyFp + 2_000_000 testDelegatorRegCertFp -- Test stake address deleg cert @@ -153,12 +154,12 @@ hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempA UTxO utxo2 <- H.noteShowM $ decodeEraUTxO sbe utxo2Json txin2 <- H.noteShow =<< H.headM (Map.keys utxo2) - let eraFlag = convertToEraFlag $ cardanoNodeEra cTestnetOptions + let eraString = anyEraToString $ cardanoNodeEra cTestnetOptions delegRegTestDelegatorTxBodyFp = work "deleg-register-test-delegator.txbody" void $ execCli' execConfig - [ "transaction", "build" - , eraFlag + [ eraString + , "transaction", "build" , "--change-address", testDelegatorPaymentAddr -- NB: A large balance ends up at our test delegator's address , "--tx-in", Text.unpack $ renderTxIn txin2 , "--tx-out", utxoAddr <> "+" <> show @Int 5_000_000 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs index aaaaae4e847..9b9e132af7e 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/LedgerEvents/Gov/InfoAction.hs @@ -8,13 +8,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -#if __GLASGOW_HASKELL__ >= 908 --- Data.List has a lot of partial functions and GHC >= 9.8 warns about these. -{-# OPTIONS_GHC -Wno-x-partial #-} -#endif - -{- HLINT ignore "Use head" -} - module Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction ( hprop_ledger_events_info_action ) where @@ -72,7 +65,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t testnetRuntime@TestnetRuntime { testnetMagic , poolNodes - , wallets + , wallets=wallet0:wallet1:_ , configurationFile } <- cardanoTestnetDefault fastTestnetOptions conf @@ -132,16 +125,16 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t ] -- Retrieve UTxOs for registration submission - txin1 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 0 + txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 drepRegTxbodyFp <- H.note $ work "drep.registration.txbody" drepRegTxSignedFp <- H.note $ work "drep.registration.tx" void $ H.execCli' execConfig [ "conway", "transaction", "build" - , "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0 + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin1 - , "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 1)) <> "+" <> show @Int 5_000_000 + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 5_000_000 , "--certificate-file", drepCertFile 1 , "--certificate-file", drepCertFile 2 , "--certificate-file", drepCertFile 3 @@ -152,7 +145,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t void $ H.execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", drepRegTxbodyFp - , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0 + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair wallet0 , "--signing-key-file", drepSKeyFp 1 , "--signing-key-file", drepSKeyFp 2 , "--signing-key-file", drepSKeyFp 3 @@ -179,13 +172,13 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t txbodyFp <- H.note $ work "tx.body" txbodySignedFp <- H.note $ work "tx.body.signed" - txin2 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 1 + txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 H.noteM_ $ H.execCli' execConfig [ "conway", "transaction", "build" - , "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 1 + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", Text.unpack $ renderTxIn txin2 - , "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 0)) <> "+" <> show @Int 5_000_000 + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet0) <> "+" <> show @Int 5_000_000 , "--proposal-file", infoActionFp , "--out-file", txbodyFp ] @@ -193,7 +186,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t void $ H.execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", txbodyFp - , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 1 + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair wallet1 , "--out-file", txbodySignedFp ] @@ -238,7 +231,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t ] -- We need more UTxOs - txin3 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 0 + txin3 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 voteTxFp <- H.note $ work gov "vote.tx" voteTxBodyFp <- H.note $ work gov "vote.txbody" @@ -246,9 +239,9 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t -- Submit votes void $ H.execCli' execConfig [ "conway", "transaction", "build" - , "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0 + , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin3 - , "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 1)) <> "+" <> show @Int 3_000_000 + , "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 3_000_000 , "--vote-file", voteFp 1 , "--vote-file", voteFp 2 , "--vote-file", voteFp 3 @@ -260,7 +253,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t void $ H.execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", voteTxBodyFp - , "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0 + , "--signing-key-file", paymentSKey $ paymentKeyInfoPair wallet0 , "--signing-key-file", drepSKeyFp 1 , "--signing-key-file", drepSKeyFp 2 , "--signing-key-file", drepSKeyFp 3 @@ -297,9 +290,9 @@ foldBlocksCheckProposalWasSubmitted -> IO (Maybe LedgerEvent, FoldStatus) -- ^ Accumulator at block i and fold status foldBlocksCheckProposalWasSubmitted txid _ _ allEvents _ _ = do let newGovProposal = filter (filterNewGovProposals txid) allEvents - if null newGovProposal - then return (Nothing, ContinueFold) - else return (Just $ newGovProposal !! 0, StopFold) + pure $ case newGovProposal of + [] -> (Nothing, ContinueFold) + proposal:_ -> (Just proposal, StopFold) retrieveGovernanceActionIndex 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 7870e463193..762402b3d42 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -10,6 +10,7 @@ import qualified Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot import qualified Cardano.Testnet.Test.Cli.Babbage.Transaction import qualified Cardano.Testnet.Test.Cli.Conway.DRepRetirement as DRepRetirement import qualified Cardano.Testnet.Test.Cli.Conway.Plutus +import qualified Cardano.Testnet.Test.Cli.Conway.RepeatedCertificatesInTransaction import qualified Cardano.Testnet.Test.Cli.KesPeriodInfo import qualified Cardano.Testnet.Test.Cli.Queries import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber @@ -62,11 +63,11 @@ tests = do [ H.ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule.hprop_leadershipSchedule -- FAILS , H.ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot.hprop_stakeSnapshot , H.ignoreOnWindows "transaction" Cardano.Testnet.Test.Cli.Babbage.Transaction.hprop_transaction + , H.ignoreOnWindows "repeated-certificates-in-tx" Cardano.Testnet.Test.Cli.Conway.RepeatedCertificatesInTransaction.hprop_repeated_certificates_in_transaction ] -- TODO: Conway - Re-enable when create-staked is working in conway again - --, testGroup "Conway" + -- , testGroup "Conway" -- [ H.ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Conway.StakeSnapshot.hprop_stakeSnapshot - -- ] -- Ignored on Windows due to : commitBuffer: invalid argument (invalid character) -- as a result of the kes-period-info output to stdout. , H.ignoreOnWindows "kes-period-info" Cardano.Testnet.Test.Cli.KesPeriodInfo.hprop_kes_period_info