diff --git a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs index 4f07f2449fd..d84616db172 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs @@ -4,9 +4,10 @@ module Spec.Chairman.Cardano where -import qualified Cardano.Testnet as H +import Cardano.Testnet (NodeRuntime (nodeName), allNodes, cardanoDefaultTestnetOptions, + cardanoTestnetDefault, mkConf) -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (integrationRetryWorkspace) import qualified Hedgehog as H @@ -14,9 +15,9 @@ import Spec.Chairman.Chairman (chairmanOver) -- TODO: Conway broken in conway hprop_chairman :: H.Property -hprop_chairman = H.integrationRetryWorkspace 2 "cardano-chairman" $ \tempAbsPath' -> do - conf <- H.mkConf tempAbsPath' +hprop_chairman = integrationRetryWorkspace 2 "cardano-chairman" $ \tempAbsPath' -> do + conf <- mkConf tempAbsPath' - allNodes <- fmap H.nodeName . H.allNodes <$> H.cardanoTestnetDefault H.cardanoDefaultTestnetOptions conf + allNodes' <- fmap nodeName . allNodes <$> cardanoTestnetDefault cardanoDefaultTestnetOptions conf - chairmanOver 120 50 conf allNodes + chairmanOver 120 50 conf allNodes' diff --git a/cardano-node-chairman/testnet/Main.hs b/cardano-node-chairman/testnet/Main.hs deleted file mode 100644 index 0a15b56ec04..00000000000 --- a/cardano-node-chairman/testnet/Main.hs +++ /dev/null @@ -1,17 +0,0 @@ -module Main where - -import Control.Monad -import Data.Function -import Data.Semigroup -import Options.Applicative -import System.IO (IO) - -import Testnet.Commands - -main :: IO () -main = do - Crypto.cryptoInit - - join $ customExecParser - (prefs $ showHelpOnEmpty <> showHelpOnError) - (info (commands <**> helper) idm) diff --git a/cardano-node-chairman/testnet/Testnet/Commands.hs b/cardano-node-chairman/testnet/Testnet/Commands.hs deleted file mode 100644 index fdf394aa1d8..00000000000 --- a/cardano-node-chairman/testnet/Testnet/Commands.hs +++ /dev/null @@ -1,26 +0,0 @@ -module Testnet.Commands where - -import Data.Function -import Data.Monoid -import Options.Applicative -import System.IO (IO) - -import Testnet.Commands.Cardano -import Testnet.Commands.Version - -{- HLINT ignore "Monoid law, left identity" -} - -commands :: Parser (IO ()) -commands = commandsTestnet <|> commandsGeneral - -commandsTestnet :: Parser (IO ()) -commandsTestnet = hsubparser $ mempty - <> commandGroup "Testnets:" - <> cmdByron - <> cmdCardano - <> cmdShelley - -commandsGeneral :: Parser (IO ()) -commandsGeneral = hsubparser $ mempty - <> commandGroup "General:" - <> cmdVersion diff --git a/cardano-node-chairman/testnet/Testnet/Commands/Cardano.hs b/cardano-node-chairman/testnet/Testnet/Commands/Cardano.hs deleted file mode 100644 index 5367427c484..00000000000 --- a/cardano-node-chairman/testnet/Testnet/Commands/Cardano.hs +++ /dev/null @@ -1,90 +0,0 @@ -{-# LANGUAGE TypeApplications #-} - -module Testnet.Commands.Cardano - ( CardanoOptions(..) - , cmdCardano - , runCardanoOptions - ) where - -import Data.Eq -import Data.Function -import Data.Int -import Data.Maybe -import Data.Semigroup -import GHC.Enum -import Options.Applicative -import qualified Options.Applicative as OA -import System.IO (IO) -import Text.Read -import Text.Show - -import Testnet.Cardano -import Testnet.Run (runTestnet) - -data CardanoOptions = CardanoOptions - { maybeTestnetMagic :: Maybe Int - , testnetOptions :: CardanoTestnetOptions - } deriving (Eq, Show) - -optsTestnet :: Parser CardanoTestnetOptions -optsTestnet = CardanoTestnetOptions - <$> OA.option auto - ( OA.long "num-bft-nodes" - <> OA.help "Number of BFT nodes" - <> OA.metavar "COUNT" - <> OA.showDefault - <> OA.value (numBftNodes defaultTestnetOptions) - ) - <*> OA.option auto - ( OA.long "num-pool-nodes" - <> OA.help "Number of pool nodes" - <> OA.metavar "COUNT" - <> OA.showDefault - <> OA.value (numPoolNodes defaultTestnetOptions) - ) - <*> OA.option (OA.eitherReader readEither) - ( OA.long "era" - <> OA.help ("Era to upgrade to. " <> show @[Era] [minBound .. maxBound]) - <> OA.metavar "ERA" - <> OA.showDefault - <> OA.value (era defaultTestnetOptions) - ) - <*> OA.option auto - ( OA.long "epoch-length" - <> OA.help "Epoch length" - <> OA.metavar "MILLISECONDS" - <> OA.showDefault - <> OA.value (epochLength defaultTestnetOptions) - ) - <*> OA.option auto - ( OA.long "slot-length" - <> OA.help "Slot length" - <> OA.metavar "SECONDS" - <> OA.showDefault - <> OA.value (slotLength defaultTestnetOptions) - ) - <*> OA.option auto - ( OA.long "active-slots-coeff" - <> OA.help "Active slots co-efficient" - <> OA.metavar "DOUBLE" - <> OA.showDefault - <> OA.value (activeSlotsCoeff defaultTestnetOptions) - ) - -optsCardano :: Parser CardanoOptions -optsCardano = CardanoOptions - <$> optional - ( OA.option auto - ( long "testnet-magic" - <> help "Testnet magic" - <> metavar "INT" - ) - ) - <*> optsTestnet - -runCardanoOptions :: CardanoOptions -> IO () -runCardanoOptions options = - runTestnet $ Testnet.Cardano.testnet (testnetOptions options) - -cmdCardano :: Mod CommandFields (IO ()) -cmdCardano = command "cardano" $ flip info idm $ runCardanoOptions <$> optsCardano diff --git a/cardano-node-chairman/testnet/Testnet/Commands/Version.hs b/cardano-node-chairman/testnet/Testnet/Commands/Version.hs deleted file mode 100644 index 086b2d990f4..00000000000 --- a/cardano-node-chairman/testnet/Testnet/Commands/Version.hs +++ /dev/null @@ -1,37 +0,0 @@ -module Testnet.Commands.Version - ( VersionOptions(..) - , cmdVersion - , runVersionOptions - ) where - -import Cardano.Git.Rev (gitRev) - -import Data.Eq -import Data.Function -import Data.Monoid -import qualified Data.Text as T -import Data.Version (showVersion) -import Options.Applicative -import System.Info (arch, compilerName, compilerVersion, os) -import qualified System.IO as IO -import System.IO (IO) -import Text.Show - -import Paths_cardano_node_chairman (version) - -data VersionOptions = VersionOptions deriving (Eq, Show) - -optsVersion :: Parser VersionOptions -optsVersion = pure VersionOptions - -runVersionOptions :: VersionOptions -> IO () -runVersionOptions VersionOptions = do - IO.putStrLn $ mconcat - [ "cardano-node ", showVersion version - , " - ", os, "-", arch - , " - ", compilerName, "-", showVersion compilerVersion - , "\ngit rev ", T.unpack gitRev - ] - -cmdVersion :: Mod CommandFields (IO ()) -cmdVersion = command "version" $ flip info idm $ runVersionOptions <$> optsVersion diff --git a/cardano-node-chairman/testnet/Testnet/Run.hs b/cardano-node-chairman/testnet/Testnet/Run.hs deleted file mode 100644 index 0e7ff22b3b8..00000000000 --- a/cardano-node-chairman/testnet/Testnet/Run.hs +++ /dev/null @@ -1,62 +0,0 @@ -module Testnet.Run - ( runTestnet - ) where - -import qualified Control.Concurrent as IO -import qualified Control.Concurrent.STM as STM -import Control.Monad -import Control.Monad.IO.Class -import Control.Monad.Trans.Resource -import Data.Bool -import Data.Function -import Data.Int -import Data.Maybe -import qualified System.Console.ANSI as ANSI -import System.Console.ANSI (Color (..), ColorIntensity (..), ConsoleLayer (..), SGR (..)) -import qualified System.Exit as IO -import qualified System.IO as IO -import System.IO (IO) - -import qualified Testnet.Conf as H - -import qualified Hedgehog as H -import qualified Hedgehog.Extras.Test.Base as H -import qualified Hedgehog.Extras.Test.Process as H -import qualified Test.Base as H - -testnetProperty :: (H.Conf -> H.Integration ()) -> H.Property -testnetProperty tn = H.integrationRetryWorkspace 2 "testnet-chairman" $ \tempAbsPath' -> do - base <- H.note =<< H.noteIO . IO.canonicalizePath =<< H.getProjectBase - configurationTemplate <- H.noteShow $ base "configuration/defaults/byron-mainnet/configuration.yaml" - conf <- H.mkConf tempAbsPath' - - -- Fork a thread to keep alive indefinitely any resources allocated by testnet. - void . liftResourceT . resourceForkIO . forever . liftIO $ IO.threadDelay 10000000 - - void $ tn conf - - H.failure -- Intentional failure to force failure report - -runTestnet :: (H.Conf -> H.Integration a) -> IO () -runTestnet tn = do - tvRunning <- STM.newTVarIO False - - void . H.check $ testnetProperty $ \c -> do - void $ tn c - H.evalIO . STM.atomically $ STM.writeTVar tvRunning True - - running <- STM.readTVarIO tvRunning - - if running - then do - ANSI.setSGR [SetColor Foreground Vivid Green] - IO.putStr "Testnet is running. Type CTRL-C to exit." - ANSI.setSGR [Reset] - IO.putStrLn "" - void . forever $ IO.threadDelay 10000000 - else do - ANSI.setSGR [SetColor Foreground Vivid Red] - IO.putStr "Failed to start testnet." - ANSI.setSGR [Reset] - IO.putStrLn "" - IO.exitFailure diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 5294df7ee2c..2f9010c4d26 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -91,15 +91,16 @@ library exposed-modules: Cardano.Testnet Parsers.Run Testnet.Components.Configuration - Testnet.Components.DRep Testnet.Components.Query - Testnet.Components.SPO Testnet.Components.TestWatchdog Testnet.Defaults Testnet.EpochStateProcessing Testnet.Filepath Testnet.Ping - Testnet.Process.Cli + Testnet.Process.Cli.DRep + Testnet.Process.Cli.Keys + Testnet.Process.Cli.SPO + Testnet.Process.Cli.Transaction Testnet.Process.Run Testnet.Property.Assert Testnet.Property.Run diff --git a/cardano-testnet/src/Parsers/Cardano.hs b/cardano-testnet/src/Parsers/Cardano.hs index 77fba0cff2c..e19864459da 100644 --- a/cardano-testnet/src/Parsers/Cardano.hs +++ b/cardano-testnet/src/Parsers/Cardano.hs @@ -1,7 +1,10 @@ +{-# LANGUAGE NumericUnderscores #-} module Parsers.Cardano ( cmdCardano ) where +import Cardano.Api (bounded) + import Cardano.CLI.Environment import Cardano.CLI.EraBased.Options.Common hiding (pNetworkId) import Cardano.CLI.Legacy.Options @@ -9,11 +12,10 @@ import Cardano.CLI.Legacy.Options import Prelude import qualified Data.List as L +import Data.Word (Word64) import Options.Applicative import qualified Options.Applicative as OA -import Testnet.Process.Cli (pNetworkId) -import Testnet.Property.Util import Testnet.Start.Cardano import Testnet.Start.Types import Testnet.Types (readNodeLoggingFormat) @@ -112,3 +114,22 @@ parseNodeConfigFile = NodeConfigurationYaml <$> cmdCardano :: EnvCli -> Mod CommandFields CardanoTestnetOptions cmdCardano envCli = command' "cardano" "Start a testnet in any era" (optsTestnet envCli) + +pNetworkId :: Parser Int +pNetworkId = + OA.option (bounded "TESTNET_MAGIC") $ mconcat + [ OA.long "testnet-magic" + , OA.metavar "INT" + , OA.help "Specify a testnet magic id." + ] + +pMaxLovelaceSupply :: Parser Word64 +pMaxLovelaceSupply = + option auto + ( long "max-lovelace-supply" + <> help "Max lovelace supply that your testnet starts with." + <> metavar "WORD64" + <> showDefault + <> value 10_020_000_000 + ) + diff --git a/cardano-testnet/src/Testnet/Components/Configuration.hs b/cardano-testnet/src/Testnet/Components/Configuration.hs index e3dc4bff338..8114b25a521 100644 --- a/cardano-testnet/src/Testnet/Components/Configuration.hs +++ b/cardano-testnet/src/Testnet/Components/Configuration.hs @@ -6,21 +6,29 @@ {-# LANGUAGE TypeApplications #-} module Testnet.Components.Configuration - ( anyEraToString - , createConfigJson + ( createConfigJson , createSPOGenesisAndFiles - , eraToString , mkTopologyConfig , numSeededUTxOKeys + + , getByronGenesisHash + , getShelleyGenesisHash + , NumPools , numPools , NumDReps , numDReps + + , anyEraToString + , eraToString ) where import Cardano.Api.Ledger (StandardCrypto) import Cardano.Api.Shelley hiding (Value, cardanoEra) +import Cardano.Chain.Genesis (GenesisHash (unGenesisHash), readGenesisData) +import qualified Cardano.Crypto.Hash.Blake2b as Crypto +import qualified Cardano.Crypto.Hash.Class as Crypto import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis) import Cardano.Ledger.Conway.Genesis (ConwayGenesis) import qualified Cardano.Node.Configuration.Topology as NonP2P @@ -30,15 +38,19 @@ import Ouroboros.Network.PeerSelection.LedgerPeers import Ouroboros.Network.PeerSelection.PeerTrustable import Ouroboros.Network.PeerSelection.State.LocalRootPeers +import Control.Exception.Safe (MonadCatch) import Control.Monad -import Control.Monad.Catch (MonadCatch) -import Data.Aeson (Value (..)) +import Data.Aeson +import qualified Data.Aeson as Aeson import qualified Data.Aeson.Encode.Pretty as A -import Data.Aeson.KeyMap (KeyMap) +import Data.Aeson.Key hiding (fromString) +import Data.Aeson.KeyMap hiding (map) import qualified Data.Aeson.Lens as L +import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS import qualified Data.List as List import Data.String +import Data.Text (Text) import qualified Data.Text as Text import GHC.Stack (HasCallStack) import qualified GHC.Stack as GHC @@ -49,7 +61,6 @@ import System.FilePath.Posix (takeDirectory, ()) import Testnet.Defaults import Testnet.Filepath import Testnet.Process.Run (execCli_) -import Testnet.Property.Util import Testnet.Start.Types (CardanoTestnetOptions (..), anyEraToString, eraToString) import Hedgehog @@ -81,6 +92,29 @@ createConfigJson (TmpAbsolutePath tempAbsPath) era = GHC.withFrozenCallStack $ d getHash :: (MonadTest m, MonadIO m) => CardanoEra a -> Text.Text -> m (KeyMap Value) getHash e = getShelleyGenesisHash (tempAbsPath defaultGenesisFilepath e) + +-- Generate hashes for genesis.json files + +getByronGenesisHash + :: (H.MonadTest m, MonadIO m) + => FilePath + -> m (KeyMap Aeson.Value) +getByronGenesisHash path = do + e <- runExceptT $ readGenesisData path + (_, genesisHash) <- H.leftFail e + let genesisHash' = unGenesisHash genesisHash + pure . singleton "ByronGenesisHash" $ toJSON genesisHash' + +getShelleyGenesisHash + :: (H.MonadTest m, MonadIO m) + => FilePath + -> Text + -> m (KeyMap Aeson.Value) +getShelleyGenesisHash path key = do + content <- H.evalIO $ BS.readFile path + let genesisHash = Crypto.hashWith id content :: Crypto.Hash Crypto.Blake2b_256 BS.ByteString + pure . singleton (fromText key) $ toJSON genesisHash + numSeededUTxOKeys :: Int numSeededUTxOKeys = 3 diff --git a/cardano-testnet/src/Testnet/Components/DRep.hs b/cardano-testnet/src/Testnet/Process/Cli/DRep.hs similarity index 75% rename from cardano-testnet/src/Testnet/Components/DRep.hs rename to cardano-testnet/src/Testnet/Process/Cli/DRep.hs index 7147fda3dc4..4ffde9b535e 100644 --- a/cardano-testnet/src/Testnet/Components/DRep.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/DRep.hs @@ -4,17 +4,12 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} -module Testnet.Components.DRep - ( VoteFile - , generateDRepKeyPair +module Testnet.Process.Cli.DRep + ( generateDRepKeyPair , generateRegistrationCertificate , createCertificatePublicationTxBody , generateVoteFiles , createVotingTxBody - , signTx - , submitTx - , failToSubmitTx - , retrieveTransactionId , registerDRep , delegateToDRep , getLastPParamUpdateActionId @@ -28,20 +23,16 @@ import Control.Monad (forM, void) import Control.Monad.Catch (MonadCatch) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Lens as AL -import Data.List (isInfixOf) import Data.Text (Text) import qualified Data.Text as Text import Data.Word (Word32) -import GHC.IO.Exception (ExitCode (..)) import GHC.Stack import Lens.Micro ((^?)) import System.FilePath (()) -import Testnet.Components.Query (EpochStateView, findLargestUtxoForPaymentKey, - getCurrentEpochNo, getMinDRepDeposit, waitUntilEpoch) -import qualified Testnet.Process.Cli as H -import qualified Testnet.Process.Run as H -import Testnet.Start.Types (anyEraToString) +import Testnet.Components.Query +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (execCli', execCliStdoutToJson) import Testnet.Types import Hedgehog (MonadTest, evalMaybe) @@ -65,7 +56,7 @@ generateDRepKeyPair execConfig work prefix = do let dRepKeyPair = KeyPair { verificationKey = File $ baseDir "verification.vkey" , signingKey = File $ baseDir "signature.skey" } - void $ H.execCli' execConfig [ "conway", "governance", "drep", "key-gen" + void $ execCli' execConfig [ "conway", "governance", "drep", "key-gen" , "--verification-key-file", verificationKeyFp dRepKeyPair , "--signing-key-file", signingKeyFp dRepKeyPair ] @@ -95,7 +86,7 @@ generateRegistrationCertificate -> m (File Certificate In) generateRegistrationCertificate execConfig work prefix drepKeyPair depositAmount = do let dRepRegistrationCertificate = File (work prefix <> ".regcert") - void $ H.execCli' execConfig [ "conway", "governance", "drep", "registration-certificate" + void $ execCli' execConfig [ "conway", "governance", "drep", "registration-certificate" , "--drep-verification-key-file", verificationKeyFp drepKeyPair , "--key-reg-deposit-amt", show @Integer depositAmount , "--out-file", unFile dRepRegistrationCertificate @@ -104,7 +95,6 @@ generateRegistrationCertificate execConfig work prefix drepKeyPair depositAmount -- DRep registration transaction composition (without signing) -data TxBody -- | Composes a certificate publication transaction body (without signing) using @cardano-cli@. -- @@ -127,7 +117,7 @@ createCertificatePublicationTxBody createCertificatePublicationTxBody execConfig epochStateView sbe work prefix cert wallet = do let dRepRegistrationTxBody = File (work prefix <> ".txbody") walletLargestUTXO <- findLargestUtxoForPaymentKey epochStateView sbe wallet - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet , "--tx-in", Text.unpack $ renderTxIn walletLargestUTXO @@ -138,13 +128,13 @@ createCertificatePublicationTxBody execConfig epochStateView sbe work prefix cer return dRepRegistrationTxBody -- Vote file generation -data VoteFile -- | Generates decentralized representative (DRep) voting files (without signing) -- using @cardano-cli@. -- -- Returns a list of generated @File VoteFile In@ representing the paths to -- the generated voting files. +-- TODO: unify with SPO.generateVoteFiles generateVoteFiles :: MonadTest m => MonadIO m @@ -164,7 +154,7 @@ generateVoteFiles execConfig work prefix governanceActionTxId governanceActionIn baseDir <- H.createDirectoryIfMissing $ work prefix forM (zip [(1 :: Integer)..] allVotes) $ \(idx, (drepKeyPair, vote)) -> do let path = File (baseDir "vote-drep-" <> show idx) - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "governance", "vote", "create" , "--" ++ vote , "--governance-action-tx-id", governanceActionTxId @@ -200,7 +190,7 @@ createVotingTxBody createVotingTxBody execConfig epochStateView sbe work prefix votes wallet = do let votingTxBody = File (work prefix <> ".txbody") walletLargestUTXO <- findLargestUtxoForPaymentKey epochStateView sbe wallet - void $ H.execCli' execConfig $ + void $ execCli' execConfig $ [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet , "--tx-in", Text.unpack $ renderTxIn walletLargestUTXO @@ -210,99 +200,6 @@ createVotingTxBody execConfig epochStateView sbe work prefix votes wallet = do ] return votingTxBody --- Transaction signing - -data SignedTx - --- | Calls @cardano-cli@ to signs a transaction body using the specified key pairs. --- --- This function takes five parameters: --- --- Returns the generated @File SignedTx In@ file path to the signed transaction file. -signTx - :: MonadTest m - => MonadCatch m - => MonadIO m - => H.ExecConfig -- ^ Specifies the CLI execution configuration. - -> AnyCardanoEra -- ^ Specifies the current Cardano era. - -> FilePath -- ^ Base directory path where the signed transaction file will be stored. - -> String -- ^ Prefix for the output signed transaction file name. The extension will be @.tx@. - -> File TxBody In -- ^ Transaction body to be signed, obtained using 'createCertificatePublicationTxBody' or similar. - -> [SomeKeyPair] -- ^ List of key pairs used for signing the transaction. - -> m (File SignedTx In) -signTx execConfig cEra work prefix txBody signatoryKeyPairs = do - let signedTx = File (work prefix <> ".tx") - void $ H.execCli' execConfig $ - [ anyEraToString cEra, "transaction", "sign" - , "--tx-body-file", unFile txBody - ] ++ (concat [["--signing-key-file", signingKeyFp kp] | SomeKeyPair kp <- signatoryKeyPairs]) ++ - [ "--out-file", unFile signedTx - ] - return signedTx - --- | Submits a signed transaction using @cardano-cli@. -submitTx - :: HasCallStack - => MonadTest m - => MonadCatch m - => MonadIO m - => H.ExecConfig -- ^ Specifies the CLI execution configuration. - -> AnyCardanoEra -- ^ Specifies the current Cardano era. - -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. - -> m () -submitTx execConfig cEra signedTx = - void $ H.execCli' execConfig - [ anyEraToString cEra, "transaction", "submit" - , "--tx-file", unFile signedTx - ] - --- | Attempts to submit a transaction that is expected to fail using @cardano-cli@. --- --- If the submission fails (the expected behavior), the function succeeds. --- If the submission succeeds unexpectedly, it raises a failure message that is --- meant to be caught by @Hedgehog@. -failToSubmitTx - :: MonadTest m - => MonadCatch m - => MonadIO m - => HasCallStack - => H.ExecConfig -- ^ Specifies the CLI execution configuration. - -> AnyCardanoEra -- ^ Specifies the current Cardano era. - -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. - -> String -- ^ Substring of the error to check for to ensure submission failed for - -- the right reason. - -> m () -failToSubmitTx execConfig cEra signedTx reasonForFailure = withFrozenCallStack $ do - (exitCode, _, stderr) <- H.execFlexAny' execConfig "cardano-cli" "CARDANO_CLI" - [ anyEraToString cEra, "transaction", "submit" - , "--tx-file", unFile signedTx - ] - case exitCode of -- Did it fail? - ExitSuccess -> H.failMessage callStack "Transaction submission was expected to fail but it succeeded" - _ -> if reasonForFailure `isInfixOf` stderr -- Did it fail for the expected reason? - then return () - else H.failMessage callStack $ "Transaction submission failed for the wrong reason (not " ++ - show reasonForFailure ++ "): " ++ stderr - --- | Retrieves the transaction ID (governance action ID) from a signed --- transaction file using @cardano-cli@. --- --- Returns the transaction ID (governance action ID) as a 'String'. -retrieveTransactionId - :: HasCallStack - => MonadTest m - => MonadCatch m - => MonadIO m - => H.ExecConfig -- ^ Specifies the CLI execution configuration. - -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. - -> m String -retrieveTransactionId execConfig signedTxBody = do - txidOutput <- H.execCli' execConfig - [ "transaction", "txid" - , "--tx-file", unFile signedTxBody - ] - return $ mconcat $ lines txidOutput - -- | Register a Delegate Representative (DRep) using @cardano-cli@, -- generating a fresh key pair in the process. -- @@ -371,7 +268,7 @@ delegateToDRep execConfig epochStateView configurationFile' socketPath sbe work -- Create vote delegation certificate let voteDelegationCertificatePath = baseDir "delegation-certificate.delegcert" - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "stake-address", "vote-delegation-certificate" , "--drep-verification-key-file", drepVKey , "--stake-verification-key-file", vKeyFile @@ -408,7 +305,7 @@ getLastPParamUpdateActionId => H.ExecConfig -- ^ Specifies the CLI execution configuration. -> m (Maybe (String, Word32)) getLastPParamUpdateActionId execConfig = do - govStateJSON :: Aeson.Value <- H.execCliStdoutToJson execConfig + govStateJSON :: Aeson.Value <- execCliStdoutToJson execConfig [ "conway", "query", "gov-state" , "--volatile-tip" ] diff --git a/cardano-testnet/src/Testnet/Process/Cli.hs b/cardano-testnet/src/Testnet/Process/Cli/Keys.hs similarity index 73% rename from cardano-testnet/src/Testnet/Process/Cli.hs rename to cardano-testnet/src/Testnet/Process/Cli/Keys.hs index 022b7fd901e..9886098f7a4 100644 --- a/cardano-testnet/src/Testnet/Process/Cli.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/Keys.hs @@ -1,13 +1,12 @@ {-# LANGUAGE DataKinds #-} -module Testnet.Process.Cli +module Testnet.Process.Cli.Keys ( cliAddressKeyGen , cliNodeKeyGen , cliNodeKeyGenVrf , cliNodeKeyGenKes , cliStakeAddressKeyGen , execCliStdoutToJson - , pNetworkId , OperatorCounter @@ -19,25 +18,19 @@ module Testnet.Process.Cli , cliByronSigningKeyAddress ) where -import Cardano.Api (ByronAddr, ByronKeyLegacy, File (..), FileDirection (..), StakeKey, - bounded) +import Cardano.Api (ByronAddr, ByronKeyLegacy, File (..), FileDirection (..), StakeKey) import Cardano.Api.Shelley (KesKey, StakePoolKey) import Control.Monad.Catch (MonadCatch) import Control.Monad.IO.Class (MonadIO) -import qualified Data.Aeson as Aeson -import qualified Data.String import GHC.Stack (HasCallStack) import qualified GHC.Stack as GHC -import Options.Applicative hiding (command) -import qualified Options.Applicative as Opt import System.FilePath.Posix import Testnet.Process.Run import Testnet.Types hiding (testnetMagic) import Hedgehog (MonadTest) -import Hedgehog.Extras (ExecConfig) import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H (writeFile) @@ -92,20 +85,6 @@ cliNodeKeyGen keyPair (File counterPath) = , "--operational-certificate-issue-counter-file", counterPath ] --- | Call a command of the CLI that returns JSON to stdout. Then parse it, --- and deserialize it to a Haskell value. Fail the test if a step fails. --- If your CLI command doesn't support --- returning JSON to stdout, and needs going through a file instead, probably --- you should add a similar function to this one. -execCliStdoutToJson :: () - => (HasCallStack, Aeson.FromJSON a, MonadTest m, MonadCatch m, MonadIO m) - => ExecConfig -- ^ The configuration with which to call the CLI - -> [String] -- ^ The CLI command to execute - -> m a -execCliStdoutToJson execConfig cmd = GHC.withFrozenCallStack $ do - result <- execCli' execConfig cmd - H.leftFail $ Aeson.eitherDecode $ Data.String.fromString result - -- | The 'OperatorCounter' data OperatorCounter @@ -143,11 +122,3 @@ cliByronSigningKeyAddress tmp testnetMagic (File key) destPath = do H.writeFile addrPath addr return $ File addrPath -pNetworkId :: Parser Int -pNetworkId = - Opt.option (bounded "TESTNET_MAGIC") $ mconcat - [ Opt.long "testnet-magic" - , Opt.metavar "INT" - , Opt.help "Specify a testnet magic id." - ] - diff --git a/cardano-testnet/src/Testnet/Components/SPO.hs b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs similarity index 95% rename from cardano-testnet/src/Testnet/Components/SPO.hs rename to cardano-testnet/src/Testnet/Process/Cli/SPO.hs index ce7892e8990..fdefc8badef 100644 --- a/cardano-testnet/src/Testnet/Components/SPO.hs +++ b/cardano-testnet/src/Testnet/Process/Cli/SPO.hs @@ -5,14 +5,12 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} - -module Testnet.Components.SPO +module Testnet.Process.Cli.SPO ( checkStakeKeyRegistered , createScriptStakeRegistrationCertificate , createStakeDelegationCertificate , createStakeKeyRegistrationCertificate , createStakeKeyDeregistrationCertificate - , decodeEraUTxO , registerSingleSpo , generateVoteFiles ) where @@ -39,12 +37,10 @@ import qualified GHC.Stack as GHC import Lens.Micro import System.FilePath.Posix (()) -import Testnet.Components.DRep (VoteFile) import Testnet.Filepath -import Testnet.Process.Cli -import qualified Testnet.Process.Run as H +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.Transaction import Testnet.Process.Run (execCli, execCli', execCli_) -import Testnet.Property.Util import Testnet.Start.Types import Testnet.Types @@ -65,9 +61,9 @@ checkStakePoolRegistered tempAbsP execConfig poolColdVkeyFp outputFp = oFpAbs = tempAbsPath' outputFp stakePoolId' <- filter ( /= '\n') <$> - execCli [ "stake-pool", "id" - , "--cold-verification-key-file", poolColdVkeyFp - ] + execCli [ "stake-pool", "id" + , "--cold-verification-key-file", poolColdVkeyFp + ] -- Check to see if stake pool was registered void $ execCli' execConfig @@ -299,11 +295,12 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile s cliAddressKeyGen $ KeyPair (File poolOwnerPaymentVkeyFp) (File poolOwnerPaymentSkeyFp) - poolowneraddresswstakecred <- execCli [ "address", "build" - , "--payment-verification-key-file", poolOwnerPaymentVkeyFp - , "--stake-verification-key-file", poolOwnerstakeVkeyFp - , "--testnet-magic", show @Int testnetMag - ] + poolowneraddresswstakecred <- + execCli [ "address", "build" + , "--payment-verification-key-file", poolOwnerPaymentVkeyFp + , "--stake-verification-key-file", poolOwnerstakeVkeyFp + , "--testnet-magic", show @Int testnetMag + ] -- 3. Generate pool cold keys let poolColdVkeyFp = spoReqDir "pool-cold.vkey" @@ -410,6 +407,7 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile s -- -- Returns a list of generated @File VoteFile In@ representing the paths to -- the generated voting files. +-- TODO: unify with DRep.generateVoteFiles generateVoteFiles :: (MonadTest m, MonadIO m, MonadCatch m) => ConwayEraOnwards era -- ^ The conway era onwards witness for the era in which the -- transaction will be constructed. @@ -428,7 +426,7 @@ generateVoteFiles ceo execConfig work prefix governanceActionTxId governanceActi baseDir <- H.createDirectoryIfMissing $ work prefix forM (zip [(1 :: Integer)..] allVotes) $ \(idx, (spoKeys, vote)) -> do let path = File (baseDir "vote-spo-" <> show idx) - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraToString $ toCardanoEra ceo , "governance", "vote", "create" , "--" ++ vote , "--governance-action-tx-id", governanceActionTxId diff --git a/cardano-testnet/src/Testnet/Process/Cli/Transaction.hs b/cardano-testnet/src/Testnet/Process/Cli/Transaction.hs new file mode 100644 index 00000000000..0d32eebc626 --- /dev/null +++ b/cardano-testnet/src/Testnet/Process/Cli/Transaction.hs @@ -0,0 +1,126 @@ +{-# LANGUAGE DataKinds #-} + +module Testnet.Process.Cli.Transaction + ( signTx + , submitTx + , failToSubmitTx + , retrieveTransactionId + , SignedTx + , TxBody + , VoteFile + ) where + +import Cardano.Api hiding (Certificate, TxBody) + +import Prelude + +import Control.Monad (void) +import Control.Monad.Catch (MonadCatch) +import Data.List (isInfixOf) +import GHC.IO.Exception (ExitCode (..)) +import GHC.Stack +import System.FilePath (()) + +import Testnet.Process.Run (execCli') +import Testnet.Start.Types (anyEraToString) +import Testnet.Types + +import Hedgehog (MonadTest) +import qualified Hedgehog.Extras as H + +-- Transaction signing +data VoteFile + +data TxBody + +data SignedTx + +-- | Calls @cardano-cli@ to signs a transaction body using the specified key pairs. +-- +-- This function takes five parameters: +-- +-- Returns the generated @File SignedTx In@ file path to the signed transaction file. +signTx + :: MonadTest m + => MonadCatch m + => MonadIO m + => H.ExecConfig -- ^ Specifies the CLI execution configuration. + -> AnyCardanoEra -- ^ Specifies the current Cardano era. + -> FilePath -- ^ Base directory path where the signed transaction file will be stored. + -> String -- ^ Prefix for the output signed transaction file name. The extension will be @.tx@. + -> File TxBody In -- ^ Transaction body to be signed, obtained using 'createCertificatePublicationTxBody' or similar. + -> [SomeKeyPair] -- ^ List of key pairs used for signing the transaction. + -> m (File SignedTx In) +signTx execConfig cEra work prefix txBody signatoryKeyPairs = do + let signedTx = File (work prefix <> ".tx") + void $ execCli' execConfig $ + [ anyEraToString cEra, "transaction", "sign" + , "--tx-body-file", unFile txBody + ] ++ (concat [["--signing-key-file", signingKeyFp kp] | SomeKeyPair kp <- signatoryKeyPairs]) ++ + [ "--out-file", unFile signedTx + ] + return signedTx + +-- | Submits a signed transaction using @cardano-cli@. +submitTx + :: HasCallStack + => MonadTest m + => MonadCatch m + => MonadIO m + => H.ExecConfig -- ^ Specifies the CLI execution configuration. + -> AnyCardanoEra -- ^ Specifies the current Cardano era. + -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. + -> m () +submitTx execConfig cEra signedTx = + void $ execCli' execConfig + [ anyEraToString cEra, "transaction", "submit" + , "--tx-file", unFile signedTx + ] + +-- | Attempts to submit a transaction that is expected to fail using @cardano-cli@. +-- +-- If the submission fails (the expected behavior), the function succeeds. +-- If the submission succeeds unexpectedly, it raises a failure message that is +-- meant to be caught by @Hedgehog@. +failToSubmitTx + :: MonadTest m + => MonadCatch m + => MonadIO m + => HasCallStack + => H.ExecConfig -- ^ Specifies the CLI execution configuration. + -> AnyCardanoEra -- ^ Specifies the current Cardano era. + -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. + -> String -- ^ Substring of the error to check for to ensure submission failed for + -- the right reason. + -> m () +failToSubmitTx execConfig cEra signedTx reasonForFailure = withFrozenCallStack $ do + (exitCode, _, stderr) <- H.execFlexAny' execConfig "cardano-cli" "CARDANO_CLI" + [ anyEraToString cEra, "transaction", "submit" + , "--tx-file", unFile signedTx + ] + case exitCode of -- Did it fail? + ExitSuccess -> H.failMessage callStack "Transaction submission was expected to fail but it succeeded" + _ -> if reasonForFailure `isInfixOf` stderr -- Did it fail for the expected reason? + then return () + else H.failMessage callStack $ "Transaction submission failed for the wrong reason (not " ++ + show reasonForFailure ++ "): " ++ stderr + +-- | Retrieves the transaction ID (governance action ID) from a signed +-- transaction file using @cardano-cli@. +-- +-- Returns the transaction ID (governance action ID) as a 'String'. +retrieveTransactionId + :: HasCallStack + => MonadTest m + => MonadCatch m + => MonadIO m + => H.ExecConfig -- ^ Specifies the CLI execution configuration. + -> File SignedTx In -- ^ Signed transaction to be submitted, obtained using 'signTx'. + -> m String +retrieveTransactionId execConfig signedTxBody = do + txidOutput <- execCli' execConfig + [ "transaction", "txid" + , "--tx-file", unFile signedTxBody + ] + return $ mconcat $ lines txidOutput + diff --git a/cardano-testnet/src/Testnet/Process/Run.hs b/cardano-testnet/src/Testnet/Process/Run.hs index 0d27086d2a3..9cf8fcf4543 100644 --- a/cardano-testnet/src/Testnet/Process/Run.hs +++ b/cardano-testnet/src/Testnet/Process/Run.hs @@ -8,6 +8,7 @@ module Testnet.Process.Run , execCliAny , execCreateScriptContext , execCreateScriptContext' + , execCliStdoutToJson , initiateProcess , procCli , procNode @@ -32,6 +33,7 @@ import qualified Data.ByteString.Lazy as LBS import Data.Function import qualified Data.List as List import Data.Monoid (Last (..)) +import Data.String (fromString) import qualified Data.Text as Text import GHC.Stack (HasCallStack) import qualified GHC.Stack as GHC @@ -45,11 +47,11 @@ import qualified System.Process as IO import System.Process import Hedgehog (MonadTest) +import qualified Hedgehog.Extras as H import Hedgehog.Extras.Internal.Plan (Component (..), Plan (..)) import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO import qualified Hedgehog.Extras.Stock.OS as OS import Hedgehog.Extras.Test.Process (ExecConfig) -import qualified Hedgehog.Extras.Test.Process as H import qualified Hedgehog.Internal.Property as H -- | Path to the bash executable. This is used on Windows so that the caller can supply a Windows @@ -114,6 +116,20 @@ execCreateScriptContext' execCreateScriptContext' execConfig = GHC.withFrozenCallStack $ H.execFlex' execConfig "create-script-context" "CREATE_SCRIPT_CONTEXT" +-- | Call a command of the CLI that returns JSON to stdout. Then parse it, +-- and deserialize it to a Haskell value. Fail the test if a step fails. +-- If your CLI command doesn't support +-- returning JSON to stdout, and needs going through a file instead, probably +-- you should add a similar function to this one. +execCliStdoutToJson :: () + => (HasCallStack, Aeson.FromJSON a, MonadTest m, MonadCatch m, MonadIO m) + => ExecConfig -- ^ The configuration with which to call the CLI + -> [String] -- ^ The CLI command to execute + -> m a +execCliStdoutToJson execConfig cmd = GHC.withFrozenCallStack $ do + result <- execCli' execConfig cmd + H.leftFail . Aeson.eitherDecode $ fromString result + -- | Create a 'CreateProcess' describing how to start the cardano-cli process -- and an argument list. procCli diff --git a/cardano-testnet/src/Testnet/Property/Run.hs b/cardano-testnet/src/Testnet/Property/Run.hs index 940d625ec6e..12699b2057a 100644 --- a/cardano-testnet/src/Testnet/Property/Run.hs +++ b/cardano-testnet/src/Testnet/Property/Run.hs @@ -23,7 +23,7 @@ import qualified System.Exit as IO import qualified System.Info as SYS import qualified System.IO as IO -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (integrationWorkspace) import Testnet.Start.Types import Hedgehog (Property) @@ -61,7 +61,7 @@ runTestnet tn = do testnetProperty :: (Conf -> H.Integration ()) -> H.Property -testnetProperty tn = H.integrationWorkspace "testnet" $ \workspaceDir -> do +testnetProperty tn = integrationWorkspace "testnet" $ \workspaceDir -> do conf <- mkConf workspaceDir -- Fork a thread to keep alive indefinitely any resources allocated by testnet. diff --git a/cardano-testnet/src/Testnet/Property/Util.hs b/cardano-testnet/src/Testnet/Property/Util.hs index 3fabd5db81d..4a64d79ffbd 100644 --- a/cardano-testnet/src/Testnet/Property/Util.hs +++ b/cardano-testnet/src/Testnet/Property/Util.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE MonoLocalBinds #-} -{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -11,35 +10,16 @@ module Testnet.Property.Util , isLinux , runInBackground - -- ** Parsers - , pMaxLovelaceSupply - - -- ** Genesis - , getByronGenesisHash - , getShelleyGenesisHash - , decodeEraUTxO ) where import Cardano.Api -import Cardano.Chain.Genesis (GenesisHash (unGenesisHash), readGenesisData) -import qualified Cardano.Crypto.Hash.Blake2b as Crypto -import qualified Cardano.Crypto.Hash.Class as Crypto - import Control.Exception.Safe (MonadCatch) import Control.Monad import Control.Monad.Trans.Resource -import Data.Aeson import qualified Data.Aeson as Aeson -import Data.Aeson.Key -import Data.Aeson.KeyMap hiding (map) -import qualified Data.ByteString as BS -import Data.Text (Text) -import Data.Word import GHC.Stack -import qualified GHC.Stack as GHC -import Options.Applicative import qualified System.Environment as IO import System.Info (os) import qualified System.IO.Unsafe as IO @@ -57,12 +37,12 @@ disableRetries = IO.unsafePerformIO $ do -- TODO: Document what an Integration is integration :: HasCallStack => H.Integration () -> H.Property -integration f = GHC.withFrozenCallStack $ H.withTests 1 $ H.propertyOnce f +integration f = withFrozenCallStack $ H.withTests 1 $ H.propertyOnce f -- | The 'FilePath' in '(FilePath -> H.Integration ())' is the work space directory. -- This is created (and returned) via 'H.workspace'. integrationRetryWorkspace :: HasCallStack => Int -> FilePath -> (FilePath -> H.Integration ()) -> H.Property -integrationRetryWorkspace n workspaceName f = GHC.withFrozenCallStack $ +integrationRetryWorkspace n workspaceName f = withFrozenCallStack $ if disableRetries then integration $ @@ -74,40 +54,13 @@ integrationRetryWorkspace n workspaceName f = GHC.withFrozenCallStack $ -- | The 'FilePath' in '(FilePath -> H.Integration ())' is the work space directory. -- This is created (and returned) via 'H.workspace'. integrationWorkspace :: HasCallStack => FilePath -> (FilePath -> H.Integration ()) -> H.Property -integrationWorkspace workspaceName f = GHC.withFrozenCallStack $ +integrationWorkspace workspaceName f = withFrozenCallStack $ integration $ H.runFinallies $ H.workspace workspaceName f isLinux :: Bool isLinux = os == "linux" --- Parsers - -pMaxLovelaceSupply :: Parser Word64 -pMaxLovelaceSupply = - option auto - ( long "max-lovelace-supply" - <> help "Max lovelace supply that your testnet starts with." - <> metavar "WORD64" - <> showDefault - <> value 10_020_000_000 - ) - --- * Generate hashes for genesis.json files - -getByronGenesisHash :: (H.MonadTest m, MonadIO m) => FilePath -> m (KeyMap Aeson.Value) -getByronGenesisHash path = do - e <- runExceptT $ readGenesisData path - (_, genesisHash) <- H.leftFail e - let genesisHash' = unGenesisHash genesisHash - pure . singleton "ByronGenesisHash" $ toJSON genesisHash' - -getShelleyGenesisHash :: (H.MonadTest m, MonadIO m) => FilePath -> Text -> m (KeyMap Aeson.Value) -getShelleyGenesisHash path key = do - content <- H.evalIO $ BS.readFile path - let genesisHash = Crypto.hashWith id content :: Crypto.Hash Crypto.Blake2b_256 BS.ByteString - pure . singleton (fromText key) $ toJSON genesisHash - -- | Runs an action in background, and registers cleanup to `MonadResource m` -- The argument forces IO monad to prevent leaking of `MonadResource` to the child thread runInBackground :: MonadTest m diff --git a/cardano-testnet/src/Testnet/Start/Cardano.hs b/cardano-testnet/src/Testnet/Start/Cardano.hs index 6c4e9a90245..f86b9fcddb1 100644 --- a/cardano-testnet/src/Testnet/Start/Cardano.hs +++ b/cardano-testnet/src/Testnet/Start/Cardano.hs @@ -56,9 +56,8 @@ import Text.Printf (printf) import Testnet.Components.Configuration import qualified Testnet.Defaults as Defaults import Testnet.Filepath -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Assert as H +import Testnet.Process.Run (execCli', execCli_, mkExecConfig) +import Testnet.Property.Assert (assertChainExtended, assertExpectedSposInLedgerState) import Testnet.Runtime as TR import qualified Testnet.Start.Byron as Byron import Testnet.Start.Types @@ -392,7 +391,7 @@ cardanoTestnet now <- H.noteShowIO DTC.getCurrentTime deadline <- H.noteShow $ DTC.addUTCTime 45 now forM_ (map (nodeStdout . poolRuntime) poolNodes) $ \nodeStdoutFile -> do - H.assertChainExtended deadline (cardanoNodeLoggingFormat testnetOptions) nodeStdoutFile + assertChainExtended deadline (cardanoNodeLoggingFormat testnetOptions) nodeStdoutFile H.noteShowIO_ DTC.getCurrentTime @@ -412,7 +411,7 @@ cardanoTestnet let tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tmpAbsPath node1sprocket <- H.headM $ poolSprockets runtime - execConfig <- H.mkExecConfig tempBaseAbsPath node1sprocket testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath node1sprocket testnetMagic forM_ wallets $ \wallet -> do H.cat . signingKeyFp $ paymentKeyInfoPair wallet @@ -428,7 +427,7 @@ cardanoTestnet stakePoolsFp <- H.note $ tmpAbsPath "current-stake-pools.json" - H.assertExpectedSposInLedgerState stakePoolsFp testnetOptions execConfig + assertExpectedSposInLedgerState stakePoolsFp testnetOptions execConfig when (cardanoEnableNewEpochStateLogging testnetOptions) $ TR.startLedgerNewEpochStateLogging runtime tempBaseAbsPath diff --git a/cardano-testnet/src/Testnet/SubmitApi.hs b/cardano-testnet/src/Testnet/SubmitApi.hs index 2c27c4a83a4..f511fb4efbf 100644 --- a/cardano-testnet/src/Testnet/SubmitApi.hs +++ b/cardano-testnet/src/Testnet/SubmitApi.hs @@ -12,14 +12,13 @@ module Testnet.SubmitApi import Cardano.Api import Cardano.Testnet -import qualified Cardano.Testnet as H import Prelude import qualified System.IO as IO import qualified System.Process as IO -import qualified Testnet.Process.Run as H +import Testnet.Process.Run (procSubmitApi) import qualified Hedgehog as H import Hedgehog.Extras (Integration) @@ -49,7 +48,7 @@ withSubmitApi , maybePort } args f = do let logDir = makeLogDir $ TmpAbsolutePath tempAbsPath - tempBaseAbsPath = H.makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath + tempBaseAbsPath = makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath nodeStdoutFile <- H.noteTempFile logDir "submit-api.stdout.log" nodeStderrFile <- H.noteTempFile logDir "submit-api.stderr.log" @@ -59,7 +58,7 @@ withSubmitApi [submitApiPort] <- H.evalIO $ maybe (IO.allocateRandomPorts 1) (pure . (:[])) maybePort - cp <- H.procSubmitApi $ + cp <- procSubmitApi $ [ "--config", unFile configPath , "--cardano-mode" , "--epoch-slots", show epochSlots diff --git a/cardano-testnet/src/Testnet/Types.hs b/cardano-testnet/src/Testnet/Types.hs index a447ecf77aa..21ef1344249 100644 --- a/cardano-testnet/src/Testnet/Types.hs +++ b/cardano-testnet/src/Testnet/Types.hs @@ -38,7 +38,6 @@ module Testnet.Types , ShelleyGenesis(..) , shelleyGenesis , getStartTime - , fromNominalDiffTimeMicro ) where import Cardano.Api 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 719d756f23e..d56d3b78bb0 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 @@ -36,13 +36,12 @@ import System.FilePath (()) import qualified System.Info as SYS import Testnet.Components.Configuration -import Testnet.Components.SPO import Testnet.Components.TestWatchdog -import Testnet.Process.Cli -import qualified Testnet.Process.Run as H -import Testnet.Process.Run +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.SPO +import Testnet.Process.Run (execCli, execCli', mkExecConfig) import Testnet.Property.Assert -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (decodeEraUTxO, integrationRetryWorkspace) import Testnet.Runtime import Testnet.Types @@ -55,7 +54,7 @@ import qualified Hedgehog.Extras.Test.File as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/leadership-schedule/"'@ hprop_leadershipSchedule :: Property -hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-schedule" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_leadershipSchedule = integrationRetryWorkspace 2 "babbage-leadership-schedule" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath @@ -75,14 +74,14 @@ hprop_leadershipSchedule = H.integrationRetryWorkspace 2 "babbage-leadership-sch } <- cardanoTestnetDefault cTestnetOptions conf node1sprocket <- H.headM $ poolSprockets tr - execConfig <- H.mkExecConfig tempBaseAbsPath node1sprocket testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath node1sprocket testnetMagic let sbe = shelleyBasedEra @BabbageEra ----------------Need to register an SPO------------------ let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0 utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "query", "utxo" , "--address", utxoAddr , "--cardano-mode" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs index 863b428f65d..67fe4933181 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Babbage/StakeSnapshot.hs @@ -20,9 +20,8 @@ import qualified Data.Aeson.KeyMap as KM import qualified System.Info as SYS import Testnet.Components.TestWatchdog -import Testnet.Process.Cli (execCliStdoutToJson) -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCliStdoutToJson, mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import Hedgehog (Property, (===)) @@ -31,7 +30,7 @@ import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO import qualified Hedgehog.Extras.Test.Base as H hprop_stakeSnapshot :: Property -hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_stakeSnapshot = integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -53,7 +52,7 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \ poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic void $ waitUntilEpoch configurationFile (Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3) 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 d1556c7978a..658d8c9d51a 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 @@ -28,11 +28,9 @@ import Lens.Micro import System.FilePath (()) import qualified System.Info as SYS -import Testnet.Components.SPO import Testnet.Components.TestWatchdog -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (decodeEraUTxO, integrationRetryWorkspace) import Testnet.Types import Hedgehog (Property) @@ -41,7 +39,7 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H hprop_transaction :: Property -hprop_transaction = H.integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_transaction = integrationRetryWorkspace 0 "babbage-transaction" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -63,7 +61,7 @@ hprop_transaction = H.integrationRetryWorkspace 0 "babbage-transaction" $ \tempA poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic txbodyFp <- H.note $ work "tx.body" 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 529e2afaa44..97ce1d7071e 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 @@ -23,12 +23,11 @@ import System.FilePath (()) import qualified System.Info as SYS import Testnet.Components.Configuration -import Testnet.Components.SPO import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.SPO +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (decodeEraUTxO, integrationWorkspace) import Testnet.Types import Hedgehog (Property) @@ -44,7 +43,7 @@ import qualified Hedgehog.Extras as H -- Voting NO -- Proposing NO hprop_plutus_v3 :: Property -hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_plutus_v3 = integrationWorkspace "all-plutus-script-purposes" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -68,14 +67,14 @@ hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbs poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic H.noteShow_ wallet0 let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0 utxoAddr2 = Text.unpack $ paymentKeyInfoAddr wallet1 utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 utxoSKeyFile2 = signingKeyFp $ paymentKeyInfoPair wallet1 - void $ H.execCli' execConfig + void $ execCli' execConfig [ anyEraToString anyEra, "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -97,13 +96,13 @@ hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbs let sendAdaToScriptAddressTxBody = work "send-ada-to-script-address-tx-body" plutusSpendingScriptAddr <- - H.execCli' execConfig + execCli' execConfig [ "address", "build" , "--payment-script-file", plutusSpendingScript ] mintingPolicyId <- filter (/= '\n') <$> - H.execCli' execConfig + execCli' execConfig [ anyEraToString anyEra, "transaction" , "policyid" , "--script-file", plutusMintingScript @@ -112,7 +111,7 @@ hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbs H.note_ $ "plutusSpendingScriptAddr: " <> plutusSpendingScriptAddr scriptdatumhash <- filter (/= '\n') <$> - H.execCli' execConfig + execCli' execConfig [ "transaction", "hash-script-data" , "--script-data-value", "0" ] @@ -154,7 +153,7 @@ hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbs H.threadDelay 10_000_000 -- 2. Successfully spend conway spending script - void $ H.execCli' execConfig + void $ execCli' execConfig [ anyEraToString anyEra, "query", "utxo" , "--address", utxoAddr2 , "--cardano-mode" @@ -167,7 +166,7 @@ hprop_plutus_v3 = H.integrationWorkspace "all-plutus-script-purposes" $ \tempAbs H.note_ $ "keys2: " <> show (length keys2) txinCollateral <- H.noteShowM $ H.headM keys2 - void $ H.execCli' execConfig + void $ execCli' execConfig [ anyEraToString anyEra, "query", "utxo" , "--address", plutusSpendingScriptAddr , "--cardano-mode" 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 cdb001f0e14..f4071bd56a2 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 @@ -19,9 +19,8 @@ import qualified Data.Aeson.KeyMap as KM import qualified System.Info as SYS import Testnet.Components.TestWatchdog -import Testnet.Process.Cli (execCliStdoutToJson) -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCliStdoutToJson, mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import Hedgehog (Property, (===)) @@ -30,7 +29,7 @@ import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO import qualified Hedgehog.Extras.Test.Base as H hprop_stakeSnapshot :: Property -hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "conway-stake-snapshot" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_stakeSnapshot = integrationRetryWorkspace 2 "conway-stake-snapshot" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -51,7 +50,7 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "conway-stake-snapshot" $ \t poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic void $ waitUntilEpoch configurationFile (Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3) 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 f604c1d5272..83ad058a5e8 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 @@ -31,12 +31,11 @@ import System.FilePath (()) import qualified System.Info as SYS import Testnet.Components.Configuration -import Testnet.Components.SPO import Testnet.Components.TestWatchdog -import Testnet.Process.Cli -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.SPO +import Testnet.Process.Run (execCli, execCli', mkExecConfig) +import Testnet.Property.Util (decodeEraUTxO, integrationRetryWorkspace) import Testnet.Runtime import Testnet.Types @@ -49,7 +48,7 @@ import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H hprop_kes_period_info :: Property -hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } -- TODO: Move yaml filepath specification into individual node options @@ -72,12 +71,12 @@ hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempA , poolNodes } <- cardanoTestnetDefault cTestnetOptions conf node1sprocket <- H.headM $ poolSprockets runTime - execConfig <- H.mkExecConfig tempBaseAbsPath node1sprocket testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath node1sprocket testnetMagic -- We get our UTxOs from here let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0 utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0 - void $ H.execCli' execConfig + void $ execCli' execConfig [ anyEraToString anyEra, "query", "utxo" , "--address", utxoAddr , "--cardano-mode" @@ -152,7 +151,7 @@ hprop_kes_period_info = H.integrationRetryWorkspace 2 "kes-period-info" $ \tempA -- TODO: Refactor getting valid UTxOs into a function H.note_ "Get updated UTxO" - void $ H.execCli' execConfig + void $ execCli' execConfig [ anyEraToString anyEra, "query", "utxo" , "--address", utxoAddr , "--cardano-mode" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs index 7aae22fec8d..2960ec50a7f 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/Query.hs @@ -28,9 +28,8 @@ import System.FilePath (()) import Testnet.Components.Configuration (eraToString) import Testnet.Components.Query import Testnet.Components.TestWatchdog -import qualified Testnet.Process.Cli as H -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCli', execCliStdoutToJson, mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog @@ -44,7 +43,7 @@ import qualified Hedgehog.Extras.Test.Golden as H -- If you want to recreate golden files, run the comment with -- RECREATE_GOLDEN_FILES=1 as its prefix hprop_cli_queries :: Property -hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_cli_queries = integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath @@ -68,7 +67,7 @@ hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -83,13 +82,13 @@ hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> -- protocol-parameters do -- to stdout - protocolParametersOut <- H.execCli' execConfig [ eraName, "query", "protocol-parameters" ] + protocolParametersOut <- execCli' execConfig [ eraName, "query", "protocol-parameters" ] H.diffVsGoldenFile protocolParametersOut "test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt" -- protocol-parameters to a file let protocolParametersOutFile = work "protocol-parameters-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "protocol-parameters" + H.noteM_ $ execCli' execConfig [ eraName, "query", "protocol-parameters" , "--out-file", protocolParametersOutFile] H.diffFileVsGoldenFile protocolParametersOutFile @@ -98,32 +97,32 @@ hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> -- tip do -- to stdout - _ :: QueryTipLocalStateOutput <- H.noteShowM $ H.execCliStdoutToJson execConfig [ eraName, "query", "tip" ] + _ :: QueryTipLocalStateOutput <- H.noteShowM $ execCliStdoutToJson execConfig [ eraName, "query", "tip" ] -- to a file let tipOutFile = work "tip-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "tip" - , "--out-file", tipOutFile] + H.noteM_ $ execCli' execConfig [ eraName, "query", "tip" + , "--out-file", tipOutFile] _ :: QueryTipLocalStateOutput <- H.readJsonFileOk tipOutFile pure () -- stake-pools do -- to stdout - stakePoolsOut <- H.execCli' execConfig [ eraName, "query", "stake-pools" ] + stakePoolsOut <- execCli' execConfig [ eraName, "query", "stake-pools" ] H.assertWith stakePoolsOut $ \pools -> length (lines pools) == 3 -- Because, by default, 3 stake pools are created -- Light test of the query's answer, the ids should exist: forM_ (lines stakePoolsOut) $ \stakePoolId -> do - H.execCli' execConfig [ eraName, "query", "pool-state" - , "--stake-pool-id", stakePoolId ] + execCli' execConfig [ eraName, "query", "pool-state" + , "--stake-pool-id", stakePoolId ] -- to a file let stakePoolsOutFile = work "stake-pools-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "stake-pools" , "--out-file", stakePoolsOutFile] + H.noteM_ $ execCli' execConfig [ eraName, "query", "stake-pools" , "--out-file", stakePoolsOutFile] -- stake-distribution do -- to stdout - stakeDistrOut <- H.execCli' execConfig [ eraName, "query", "stake-distribution" ] + stakeDistrOut <- execCli' execConfig [ eraName, "query", "stake-distribution" ] -- stake addresses with stake let stakeAddresses :: [(Text, Text)] = map @@ -139,23 +138,23 @@ hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> length sa == 3 -- Light test of the query's answer, the ids should exist: forM_ stakeAddresses $ \(stakePoolId, _) -> do - H.execCli' execConfig [ eraName, "query", "pool-state" - , "--stake-pool-id", T.unpack stakePoolId ] + execCli' execConfig [ eraName, "query", "pool-state" + , "--stake-pool-id", T.unpack stakePoolId ] -- to a file let stakePoolsOutFile = work "stake-distribution-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "stake-distribution" - , "--out-file", stakePoolsOutFile] + H.noteM_ $ execCli' execConfig [ eraName, "query", "stake-distribution" + , "--out-file", stakePoolsOutFile] -- gov-state do -- to stdout - H.execCli' execConfig [ eraName, "query", "gov-state" ] + execCli' execConfig [ eraName, "query", "gov-state" ] >>= (`H.diffVsGoldenFile` "test/cardano-testnet-test/files/golden/queries/govStateOut.json") -- to a file let govStateOutFile = work "gov-state-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "gov-state", "--out-file", govStateOutFile] + H.noteM_ $ execCli' execConfig [ eraName, "query", "gov-state", "--out-file", govStateOutFile] H.diffFileVsGoldenFile govStateOutFile "test/cardano-testnet-test/files/golden/queries/govStateOut.json" @@ -165,12 +164,12 @@ hprop_cli_queries = H.integrationWorkspace "cli-queries" $ \tempAbsBasePath' -> -- to stdout -- TODO: deserialize to a Haskell value when -- https://github.com/IntersectMBO/cardano-cli/issues/606 is tackled - dreps :: Aeson.Value <- H.noteShowM $ H.execCliStdoutToJson execConfig [ eraName, "query", "drep-state", "--all-dreps"] + dreps :: Aeson.Value <- H.noteShowM $ execCliStdoutToJson execConfig [ eraName, "query", "drep-state", "--all-dreps"] assertArrayOfSize dreps 3 -- to a file let drepStateOutFile = work "drep-state-out.json" - H.noteM_ $ H.execCli' execConfig [ eraName, "query", "drep-state", "--all-dreps" - , "--out-file", drepStateOutFile] + H.noteM_ $ execCli' execConfig [ eraName, "query", "drep-state", "--all-dreps" + , "--out-file", drepStateOutFile] _ :: Aeson.Value <- H.readJsonFileOk drepStateOutFile pure () diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs index 88b11b9bc11..4b58bd2d07b 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Cli/QuerySlotNumber.hs @@ -14,6 +14,7 @@ module Cardano.Testnet.Test.Cli.QuerySlotNumber import Cardano.Api +import Cardano.Ledger.Shelley.Genesis (fromNominalDiffTimeMicro) import Cardano.Slotting.Slot import Cardano.Testnet @@ -25,9 +26,8 @@ import qualified Data.Time.Format as DT import qualified System.Info as SYS import Testnet.Components.TestWatchdog -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import Hedgehog (Property) @@ -37,7 +37,7 @@ import qualified Hedgehog.Internal.Property as H -- | Tests @query slot-number@ cardano-cli command that it returns correct slot numbers for provided utc time hprop_querySlotNumber :: Property -hprop_querySlotNumber = H.integrationRetryWorkspace 2 "query-slot-number" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_querySlotNumber = integrationRetryWorkspace 2 "query-slot-number" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf <- mkConf tempAbsBasePath' @@ -64,7 +64,7 @@ hprop_querySlotNumber = H.integrationRetryWorkspace 2 "query-slot-number" $ \tem poolNode1 <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath' poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath' poolSprocket1 testnetMagic id do H.note_ "Try to retrieve slot 5s before genesis" diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs index 03965ace67b..8cb48c28d03 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/FoldEpochState.hs @@ -16,7 +16,7 @@ import qualified System.Directory as IO import System.FilePath (()) import Testnet.Components.TestWatchdog -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog ((===)) @@ -25,7 +25,7 @@ import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as H import qualified Hedgehog.Extras.Test as H prop_foldEpochState :: H.Property -prop_foldEpochState = H.integrationWorkspace "foldEpochState" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +prop_foldEpochState = integrationWorkspace "foldEpochState" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf <- TN.mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath $ tempAbsPath conf 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 7940ccb41a6..adcbd61baa5 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 @@ -34,21 +34,22 @@ import Lens.Micro import System.FilePath (()) import Testnet.Components.Configuration -import qualified Testnet.Components.DRep as DRep import Testnet.Components.Query -import qualified Testnet.Components.SPO as SPO import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import qualified Testnet.Process.Cli.DRep as DRep +import Testnet.Process.Cli.Keys +import qualified Testnet.Process.Cli.SPO as SPO +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog import qualified Hedgehog.Extras as H hprop_constitutional_committee_add_new :: Property -hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional-committee-add-new" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_constitutional_committee_add_new = integrationWorkspace "constitutional-committee-add-new" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath @@ -86,7 +87,7 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- PoolNode{poolRuntime, poolKeys} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -104,7 +105,7 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- H.writeFile proposalAnchorFp "dummy anchor data" H.writeFile proposalDataFp "dummy proposal data" - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ eraName, "governance" , "hash", "anchor-data" , "--file-text", proposalAnchorFp ] @@ -114,7 +115,7 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- stakeVkeyFp = gov "stake.vkey" stakeSKeyFp = gov "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey = File stakeSKeyFp } @@ -124,13 +125,13 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- ccColdKeys <- H.noteShowM $ H.forConcurrently [1..3] $ \(i :: Int) -> do let coldVKey = ccColdVKeyFp i - _ <- H.execCli' execConfig + _ <- execCli' execConfig [ eraName, "governance", "committee", "key-gen-cold" , "--cold-verification-key-file", ccColdVKeyFp i , "--cold-signing-key-file", ccColdSKeyFp i ] fmap (coldVKey, i,) $ - parseKeyHashCred =<< H.execCli' execConfig + parseKeyHashCred =<< execCli' execConfig [ eraName, "governance", "committee", "key-hash" , "--verification-key-file", ccColdVKeyFp i ] @@ -140,7 +141,7 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- let ccExpiryEpoch = epochNo + 200 deadlineEpoch = EpochNo $ epochNo + 10 - _ <- H.execCli' execConfig $ + _ <- execCli' execConfig $ [ eraName, "governance", "action" , "update-committee" , "--testnet" , "--anchor-url", "https://tinyurl.com/3wrwb2as" @@ -156,7 +157,7 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- txbodyFp <- H.note $ work "tx.body" txin1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraToString era, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin1 @@ -170,10 +171,10 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- committeeMembers `H.assertWith` null signedProposalTx <- - DRep.signTx execConfig cEra work "signed-proposal" (File txbodyFp) [SomeKeyPair $ paymentKeyInfoPair wallet0] - DRep.submitTx execConfig cEra signedProposalTx + signTx execConfig cEra work "signed-proposal" (File txbodyFp) [SomeKeyPair $ paymentKeyInfoPair wallet0] + submitTx execConfig cEra signedProposalTx - governanceActionTxId <- H.noteM $ DRep.retrieveTransactionId execConfig signedProposalTx + governanceActionTxId <- H.noteM $ retrieveTransactionId execConfig signedProposalTx governanceActionIx <- H.nothingFailM . @@ -207,10 +208,10 @@ hprop_constitutional_committee_add_new = H.integrationWorkspace "constitutional- } drepSKeys = map (defaultDRepKeyPair . snd) drepVotes signingKeys = SomeKeyPair <$> paymentKeyInfoPair wallet0:poolNodePaymentKeyPair:drepSKeys - voteTxFp <- DRep.signTx + voteTxFp <- signTx execConfig cEra gov "signed-vote-tx" voteTxBodyFp signingKeys - DRep.submitTx execConfig cEra voteTxFp + submitTx execConfig cEra voteTxFp _ <- waitForEpochs epochStateView (L.EpochInterval 1) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs index c7e407de6d4..382f314c4a3 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs @@ -31,21 +31,16 @@ import GHC.Stack (HasCallStack, callStack) import Lens.Micro ((^.)) import System.FilePath (()) -import Testnet.Components.DRep (createVotingTxBody, delegateToDRep, generateVoteFiles, - getLastPParamUpdateActionId, registerDRep, retrieveTransactionId, signTx, - submitTx) -import Testnet.Components.Query (EpochStateView, checkDRepState, - findLargestUtxoForPaymentKey, getCurrentEpochNo, getEpochStateView, - getMinDRepDeposit) +import Testnet.Components.Query import Testnet.Components.TestWatchdog (runWithDefaultWatchdog_) import Testnet.Defaults (defaultDRepKeyPair, defaultDelegatorStakeKeyPair) import Testnet.EpochStateProcessing (watchEpochStateView) -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H -import Testnet.Types (KeyPair (..), PaymentKeyInfo (..), PoolNode (..), SomeKeyPair (..), - TestnetRuntime (TestnetRuntime, configurationFile, poolNodes, testnetMagic, wallets), - nodeSocketPath) +import Testnet.Process.Cli.DRep +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) +import Testnet.Types import Hedgehog (MonadTest, Property, annotateShow) import qualified Hedgehog.Extras as H @@ -53,7 +48,7 @@ import qualified Hedgehog.Extras as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/DRep Activity/"'@ hprop_check_drep_activity :: Property -hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_check_drep_activity = integrationWorkspace "test-activity" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -81,7 +76,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -251,7 +246,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat let stakeVkeyFp = baseDir "stake.vkey" stakeSKeyFp = baseDir "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey = File stakeSKeyFp } @@ -259,7 +254,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat proposalAnchorFile <- H.note $ baseDir "sample-proposal-anchor" H.writeFile proposalAnchorFile "dummy anchor data" - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", proposalAnchorFile ] @@ -268,7 +263,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat proposalFile <- H.note $ baseDir "sample-proposal-anchor" - void $ H.execCli' execConfig $ + void $ execCli' execConfig $ [ "conway", "governance", "action", "create-protocol-parameters-update" , "--testnet" , "--governance-action-deposit", show @Integer minDRepDeposit @@ -286,7 +281,7 @@ makeActivityChangeProposal execConfig epochStateView configurationFile socketPat proposalBody <- H.note $ baseDir "tx.body" txIn <- findLargestUtxoForPaymentKey epochStateView sbe wallet - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet , "--tx-in", Text.unpack $ renderTxIn txIn diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs index a26292bcc00..776d023b4b9 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepDeposit.hs @@ -8,9 +8,6 @@ import Cardano.Api import qualified Cardano.Api.Ledger as L import Cardano.Testnet - (CardanoTestnetOptions (cardanoEpochLength, cardanoNodeEra, cardanoNumDReps), - Conf (Conf, tempAbsPath), TmpAbsolutePath (unTmpAbsPath), - cardanoDefaultTestnetOptions, cardanoTestnetDefault, makeTmpBaseAbsPath, mkConf) import Prelude @@ -18,12 +15,12 @@ import Control.Monad (void) import qualified Data.Map as Map import System.FilePath (()) -import Testnet.Components.DRep (createCertificatePublicationTxBody, failToSubmitTx, - generateDRepKeyPair, generateRegistrationCertificate, registerDRep, signTx) -import Testnet.Components.Query (checkDRepState, getEpochStateView, getMinDRepDeposit) +import Testnet.Components.Query import Testnet.Components.TestWatchdog (runWithDefaultWatchdog_) -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.DRep +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog (Property) @@ -33,7 +30,7 @@ import qualified Hedgehog.Extras as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/DRep Deposits/"'@ hprop_ledger_events_drep_deposits :: Property -hprop_ledger_events_drep_deposits = H.integrationWorkspace "drep-deposits" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_drep_deposits = integrationWorkspace "drep-deposits" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' @@ -62,7 +59,7 @@ hprop_ledger_events_drep_deposits = H.integrationWorkspace "drep-deposits" $ \te PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs index e49c7db4728..3eb312311f4 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepRetirement.hs @@ -22,9 +22,9 @@ import System.FilePath (()) import Testnet.Components.Query import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.Keys +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import Hedgehog @@ -38,7 +38,7 @@ sbe = ShelleyBasedEraConway -- Execute this test with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/DRepRetirement/"'@ hprop_drep_retirement :: Property -hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_drep_retirement = integrationRetryWorkspace 2 "drep-retirement" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf@Conf { tempAbsPath } <- H.noteShowM $ mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -64,7 +64,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -79,7 +79,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA let stakeVkeyFp = gov "stake.vkey" stakeSKeyFp = gov "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey = File stakeSKeyFp } @@ -89,14 +89,14 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA -- Deregister first DRep let dreprRetirementCertFile = gov "drep-keys" <> "drep1.retirementcert" - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "governance", "drep", "retirement-certificate" , "--drep-verification-key-file", verificationKeyFp $ defaultDRepKeyPair 1 , "--deposit-amt", show @Int 1_000_000 , "--out-file", dreprRetirementCertFile ] - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "query", "utxo" , "--address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--cardano-mode" @@ -108,7 +108,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA drepRetirementRegTxbodyFp <- H.note $ work "drep.retirement.txbody" drepRetirementRegTxSignedFp <- H.note $ work "drep.retirement.tx" - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "transaction", "build" , "--tx-in", Text.unpack $ renderTxIn txin2 , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 @@ -117,7 +117,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA , "--out-file", drepRetirementRegTxbodyFp ] - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", drepRetirementRegTxbodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet0 @@ -125,7 +125,7 @@ hprop_drep_retirement = H.integrationRetryWorkspace 2 "drep-retirement" $ \tempA , "--out-file", drepRetirementRegTxSignedFp ] - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "transaction", "submit" , "--tx-file", drepRetirementRegTxSignedFp ] diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs index b70d4cc32cc..92383502126 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/InfoAction.hs @@ -34,9 +34,9 @@ import System.FilePath (()) import Testnet.Components.Query import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.Keys +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import Hedgehog @@ -45,7 +45,7 @@ import qualified Hedgehog.Extras as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/InfoAction/'@ hprop_ledger_events_info_action :: Property -hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_info_action = integrationRetryWorkspace 0 "info-hash" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf@Conf { tempAbsPath } <- H.noteShowM $ mkConf tempAbsBasePath' @@ -72,7 +72,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -88,7 +88,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t H.writeFile proposalAnchorFile "dummy anchor data" - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", proposalAnchorFile ] @@ -96,14 +96,14 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t let stakeVkeyFp = gov "stake.vkey" stakeSKeyFp = gov "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey= File stakeSKeyFp } -- Create info action proposal - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "governance", "action", "create-info" , "--testnet" , "--governance-action-deposit", show @Int 1_000_000 -- TODO: Get this from the node @@ -118,7 +118,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", Text.unpack $ renderTxIn txin2 @@ -127,19 +127,19 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t , "--out-file", txbodyFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", txbodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet1 , "--out-file", txbodySignedFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "submit" , "--tx-file", txbodySignedFp ] - txidString <- mconcat . lines <$> H.execCli' execConfig + txidString <- mconcat . lines <$> execCli' execConfig [ "transaction", "txid" , "--tx-file", txbodySignedFp ] @@ -162,7 +162,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t -- Proposal was successfully submitted, now we vote on the proposal and confirm it was ratified H.forConcurrently_ [1..3] $ \n -> do - H.execCli' execConfig + execCli' execConfig [ "conway", "governance", "vote", "create" , "--yes" , "--governance-action-tx-id", txidString @@ -178,7 +178,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t voteTxBodyFp <- H.note $ work gov "vote.txbody" -- Submit votes - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin3 @@ -191,7 +191,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "sign" , "--tx-body-file", voteTxBodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet0 @@ -201,7 +201,7 @@ hprop_ledger_events_info_action = H.integrationRetryWorkspace 0 "info-hash" $ \t , "--out-file", voteTxFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "submit" , "--tx-file", voteTxFp ] diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs index fc264643c42..57b00e946e6 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs @@ -34,14 +34,14 @@ import Lens.Micro import System.FilePath (()) import Testnet.Components.Configuration -import Testnet.Components.DRep (createVotingTxBody, generateVoteFiles, - retrieveTransactionId, signTx, submitTx) import Testnet.Components.Query import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.DRep +import Testnet.Process.Cli.Keys +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog @@ -50,7 +50,7 @@ import qualified Hedgehog.Extras as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/ProposeAndRatifyNewConstitution/"'@ hprop_ledger_events_propose_new_constitution :: Property -hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-new-constitution" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new-constitution" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -87,7 +87,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -105,12 +105,12 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n H.writeFile proposalAnchorFile "dummy anchor data" H.writeFile consitutionFile "dummy constitution data" - constitutionHash <- H.execCli' execConfig + constitutionHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", consitutionFile ] - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", proposalAnchorFile ] @@ -118,7 +118,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n let stakeVkeyFp = gov "stake.vkey" stakeSKeyFp = gov "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey = File stakeSKeyFp } @@ -129,14 +129,14 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n -- TODO: Update help text for policyid. The script hash is not -- only useful for minting scripts constitutionScriptHash <- filter (/= '\n') <$> - H.execCli' execConfig + execCli' execConfig [ anyEraToString cEra, "transaction" , "policyid" , "--script-file", guardRailScriptFp ] minDRepDeposit <- getMinDRepDeposit epochStateView ceo - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "governance", "action", "create-constitution" , "--testnet" , "--governance-action-deposit", show minDRepDeposit @@ -153,7 +153,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1 - void $ H.execCli' execConfig + void $ execCli' execConfig [ "conway", "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", Text.unpack $ renderTxIn txin2 diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs index fcae279c2b0..0d90f721489 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitutionSPO.hs @@ -25,15 +25,15 @@ import GHC.Stack (HasCallStack) import Lens.Micro import System.FilePath (()) -import Testnet.Components.DRep (createVotingTxBody, failToSubmitTx, retrieveTransactionId, - signTx, submitTx) import Testnet.Components.Query -import Testnet.Components.SPO (generateVoteFiles) import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.DRep +import Testnet.Process.Cli.Keys +import qualified Testnet.Process.Cli.SPO as SPO +import Testnet.Process.Cli.Transaction +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog @@ -44,7 +44,7 @@ import qualified Hedgehog.Extras as H -- Execute me with: -- @cabal test cardano-testnet-test --test-options '-p "/ProposeNewConstitutionSPO/"'@ hprop_ledger_events_propose_new_constitution_spo :: Property -hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propose-new-constitution-spo" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_propose_new_constitution_spo = integrationWorkspace "propose-new-constitution-spo" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath=tempAbsPath@(TmpAbsolutePath work) } <- mkConf tempAbsBasePath' let tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath @@ -69,7 +69,7 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -87,12 +87,12 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo H.writeFile proposalAnchorFile "dummy anchor data" H.writeFile constitutionFile "dummy constitution data" - constitutionHash <- H.execCli' execConfig + constitutionHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", constitutionFile ] - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ "conway", "governance" , "hash", "anchor-data", "--file-text", proposalAnchorFile ] @@ -100,7 +100,7 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo let stakeVkeyFp = gov "stake.vkey" stakeSKeyFp = gov "stake.skey" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey= File stakeSKeyFp } @@ -108,7 +108,7 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo minDRepDeposit <- getMinDRepDeposit epochStateView ceo -- Create constitution proposal - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "governance", "action", "create-constitution" , "--testnet" , "--governance-action-deposit", show minDRepDeposit @@ -124,7 +124,7 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo txIn1 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 - H.noteM_ $ H.execCli' execConfig + H.noteM_ $ execCli' execConfig [ "conway", "transaction", "build" , "--tx-in", Text.unpack $ renderTxIn txIn1 , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 @@ -150,7 +150,7 @@ hprop_ledger_events_propose_new_constitution_spo = H.integrationWorkspace "propo let L.GovActionIx governanceActionIndex = L.gaidGovActionIx govActionId - votes <- generateVoteFiles ceo execConfig work "vote-files" txIdString governanceActionIndex + votes <- SPO.generateVoteFiles ceo execConfig work "vote-files" txIdString governanceActionIndex [(defaultSpoKeys n, "yes") | n <- [1..3]] -- Submit votes diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs index 8ca69b180a5..6da4b2be09d 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryGrowth.hs @@ -22,7 +22,7 @@ import qualified System.Directory as IO import System.FilePath (()) import Testnet.Components.TestWatchdog -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Types import qualified Hedgehog as H @@ -32,7 +32,7 @@ import qualified Hedgehog.Extras.Test as H -- | Execute me with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/Treasury Growth/"'@ prop_check_if_treasury_is_growing :: H.Property -prop_check_if_treasury_is_growing = H.integrationRetryWorkspace 0 "growing-treasury" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasury" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start testnet conf@Conf{tempAbsPath=TmpAbsolutePath tempAbsPath'} <- TN.mkConf tempAbsBasePath' diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs index 40ab345ab4c..a6b3e69f1cb 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/TreasuryWithdrawal.hs @@ -39,9 +39,9 @@ import System.FilePath (()) import Testnet.Components.Query import Testnet.Components.TestWatchdog import Testnet.Defaults -import qualified Testnet.Process.Cli as P -import qualified Testnet.Process.Run as H -import qualified Testnet.Property.Util as H +import Testnet.Process.Cli.Keys (cliStakeAddressKeyGen) +import Testnet.Process.Run (execCli', mkExecConfig) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Start.Types (eraToString) import Testnet.Types @@ -49,7 +49,7 @@ import Hedgehog import qualified Hedgehog.Extras as H hprop_ledger_events_treasury_withdrawal:: Property -hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasury-withdrawal" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 1 "treasury-withdrawal" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf@Conf { tempAbsPath } <- H.noteShowM $ mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath tempBaseAbsPath = makeTmpBaseAbsPath tempAbsPath @@ -78,7 +78,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu PoolNode{poolRuntime} <- H.headM poolNodes poolSprocket1 <- H.noteShow $ nodeSprocket poolRuntime - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic let socketPath = nodeSocketPath poolRuntime epochStateView <- getEpochStateView configurationFile socketPath @@ -94,7 +94,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu H.writeFile proposalAnchorFile "dummy anchor data" - proposalAnchorDataHash <- H.execCli' execConfig + proposalAnchorDataHash <- execCli' execConfig [ eraName, "governance" , "hash", "anchor-data", "--file-text", proposalAnchorFile ] @@ -106,12 +106,12 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu stakeSKeyFp = gov "stake.skey" stakeCertFp = gov "stake.regcert" - P.cliStakeAddressKeyGen + cliStakeAddressKeyGen $ KeyPair { verificationKey = File stakeVkeyFp , signingKey= File stakeSKeyFp } - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "stake-address", "registration-certificate" , "--stake-verification-key-file", stakeVkeyFp , "--key-reg-deposit-amt", show @Int 0 -- TODO: why this needs to be 0???? @@ -121,7 +121,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu stakeCertTxBodyFp <- H.note $ work "stake.registration.txbody" stakeCertTxSignedFp <- H.note $ work "stake.registration.tx" - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", Text.unpack $ renderTxIn txin2 @@ -131,7 +131,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu , "--out-file", stakeCertTxBodyFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "sign" , "--tx-body-file", stakeCertTxBodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet1 @@ -139,7 +139,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu , "--out-file", stakeCertTxSignedFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "submit" , "--tx-file", stakeCertTxSignedFp ] @@ -148,7 +148,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu -- {{{ Create treasury withdrawal let withdrawalAmount = 3_300_777 :: Integer govActionDeposit <- getMinDRepDeposit epochStateView ceo - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "governance", "action", "create-treasury-withdrawal" , "--testnet" , "--anchor-url", "https://tinyurl.com/3wrwb2as" @@ -169,7 +169,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu txin3 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0 - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0 , "--tx-in", Text.unpack $ renderTxIn txin3 @@ -178,20 +178,20 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu , "--out-file", txbodyFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "sign" , "--tx-body-file", txbodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet0 , "--out-file", txbodySignedFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "submit" , "--tx-file", txbodySignedFp ] -- }}} - txidString <- mconcat . lines <$> H.execCli' execConfig + txidString <- mconcat . lines <$> execCli' execConfig [ "transaction", "txid" , "--tx-file", txbodySignedFp ] @@ -206,7 +206,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu -- Proposal was successfully submitted, now we vote on the proposal and confirm it was ratified H.forConcurrently_ [1..3] $ \n -> do - H.execCli' execConfig + execCli' execConfig [ eraName, "governance", "vote", "create" , "--yes" , "--governance-action-tx-id", txidString @@ -220,7 +220,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu voteTxFp <- H.note $ work gov "vote.tx" voteTxBodyFp <- H.note $ work gov "vote.txbody" -- {{{ Submit votes - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "build" , "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1 , "--tx-in", Text.unpack $ renderTxIn txin4 @@ -232,7 +232,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu , "--out-file", voteTxBodyFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "sign" , "--tx-body-file", voteTxBodyFp , "--signing-key-file", signingKeyFp $ paymentKeyInfoPair wallet1 @@ -242,7 +242,7 @@ hprop_ledger_events_treasury_withdrawal = H.integrationRetryWorkspace 1 "treasu , "--out-file", voteTxFp ] - void $ H.execCli' execConfig + void $ execCli' execConfig [ eraName, "transaction", "submit" , "--tx-file", voteTxFp ] diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs index 533b816b4f9..658fc3157a0 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Node/Shutdown.hs @@ -34,11 +34,11 @@ import qualified System.IO as IO import qualified System.Process as IO import System.Process (interruptProcessGroupOf) +import Testnet.Components.Configuration import Testnet.Components.TestWatchdog import Testnet.Defaults -import Testnet.Process.Run -import qualified Testnet.Property.Util as H -import Testnet.Property.Util +import Testnet.Process.Run (execCli_, initiateProcess, procNode) +import Testnet.Property.Util (integrationRetryWorkspace) import Testnet.Start.Byron import Testnet.Types @@ -59,7 +59,7 @@ import qualified Hedgehog.Extras.Test.Process as H -- -- TODO: Use cardanoTestnet in hprop_shutdown hprop_shutdown :: Property -hprop_shutdown = H.integrationRetryWorkspace 2 "shutdown" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_shutdown = integrationRetryWorkspace 2 "shutdown" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do conf <- mkConf tempAbsBasePath' let tempBaseAbsPath' = makeTmpBaseAbsPath $ tempAbsPath conf tempAbsPath' = unTmpAbsPath $ tempAbsPath conf @@ -184,7 +184,7 @@ hprop_shutdown = H.integrationRetryWorkspace 2 "shutdown" $ \tempAbsBasePath' -> hprop_shutdownOnSlotSynced :: Property -hprop_shutdownOnSlotSynced = H.integrationRetryWorkspace 2 "shutdown-on-slot-synced" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_shutdownOnSlotSynced = integrationRetryWorkspace 2 "shutdown-on-slot-synced" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net -- TODO: Move yaml filepath specification into individual node options conf <- mkConf tempAbsBasePath' @@ -233,7 +233,7 @@ hprop_shutdownOnSlotSynced = H.integrationRetryWorkspace 2 "shutdown-on-slot-syn -- Execute this test with: -- @DISABLE_RETRIES=1 cabal test cardano-testnet-test --test-options '-p "/ShutdownOnSigint/"'@ hprop_shutdownOnSigint :: Property -hprop_shutdownOnSigint = H.integrationRetryWorkspace 2 "shutdown-on-sigint" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_shutdownOnSigint = integrationRetryWorkspace 2 "shutdown-on-sigint" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net -- TODO: Move yaml filepath specification into individual node options conf <- mkConf tempAbsBasePath' diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs index b22bbbc0d89..35693ad3a93 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs @@ -20,7 +20,7 @@ import GHC.IO.Exception (IOException) import GHC.Stack import Testnet.Components.TestWatchdog -import qualified Testnet.Property.Util as H +import Testnet.Property.Util (integrationWorkspace) import Testnet.Types import Hedgehog @@ -40,7 +40,7 @@ newtype AdditionalCatcher -- This sets the stage for more direct testing of clusters allowing us to avoid querying the node, dealing with serialization to and from disk, -- setting timeouts for expected results etc. hprop_ledger_events_sanity_check :: Property -hprop_ledger_events_sanity_check = H.integrationWorkspace "ledger-events-sanity-check" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_ledger_events_sanity_check = integrationWorkspace "ledger-events-sanity-check" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do -- Start a local test net conf <- mkConf tempAbsBasePath' diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs index 7e251cb7f6e..6fa826094fd 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SubmitApi/Babbage/Transaction.hs @@ -35,11 +35,9 @@ import System.FilePath (()) import qualified System.Info as SYS import Text.Regex (mkRegex, subRegex) -import Testnet.Components.SPO import Testnet.Components.TestWatchdog -import qualified Testnet.Process.Run as H -import Testnet.Process.Run -import qualified Testnet.Property.Util as H +import Testnet.Process.Run (execCli', mkExecConfig, procSubmitApi) +import Testnet.Property.Util (decodeEraUTxO, integrationRetryWorkspace) import Testnet.SubmitApi import Testnet.Types @@ -50,7 +48,7 @@ import qualified Hedgehog.Extras.Test.File as H import qualified Hedgehog.Extras.Test.Golden as H hprop_transaction :: Property -hprop_transaction = H.integrationRetryWorkspace 0 "submit-api-babbage-transaction" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do +hprop_transaction = integrationRetryWorkspace 0 "submit-api-babbage-transaction" $ \tempAbsBasePath' -> runWithDefaultWatchdog_ $ do H.note_ SYS.os conf@Conf { tempAbsPath } <- mkConf tempAbsBasePath' let tempAbsPath' = unTmpAbsPath tempAbsPath @@ -77,7 +75,7 @@ hprop_transaction = H.integrationRetryWorkspace 0 "submit-api-babbage-transactio poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1 - execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic + execConfig <- mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic void $ procSubmitApi [ "--config", unFile configurationFile 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 216a2cfa116..c7314f26ed0 100644 --- a/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs +++ b/cardano-testnet/test/cardano-testnet-test/cardano-testnet-test.hs @@ -32,7 +32,7 @@ import qualified System.Exit as IO import qualified System.IO as IO import System.IO (BufferMode (LineBuffering), hSetBuffering, hSetEncoding, stdout, utf8) -import qualified Testnet.Property.Run as H +import Testnet.Property.Run (ignoreOnMacAndWindows, ignoreOnWindows) import qualified Test.Tasty as T import Test.Tasty (TestTree) @@ -45,50 +45,50 @@ tests = do pure $ T.testGroup "test/Spec.hs" [ T.testGroup "Spec" [ T.testGroup "Ledger Events" - [ H.ignoreOnWindows "Sanity Check" LedgerEvents.hprop_ledger_events_sanity_check - , H.ignoreOnWindows "Treasury Growth" Gov.prop_check_if_treasury_is_growing + [ ignoreOnWindows "Sanity Check" LedgerEvents.hprop_ledger_events_sanity_check + , ignoreOnWindows "Treasury Growth" Gov.prop_check_if_treasury_is_growing -- TODO: Replace foldBlocks with checkLedgerStateCondition , T.testGroup "Governance" - [ H.ignoreOnMacAndWindows "Committee Add New" Gov.hprop_constitutional_committee_add_new - , H.ignoreOnWindows "DRep Activity" Gov.hprop_check_drep_activity - , H.ignoreOnWindows "DRep Deposits" Gov.hprop_ledger_events_drep_deposits + [ ignoreOnMacAndWindows "Committee Add New" Gov.hprop_constitutional_committee_add_new + , ignoreOnWindows "DRep Activity" Gov.hprop_check_drep_activity + , ignoreOnWindows "DRep Deposits" Gov.hprop_ledger_events_drep_deposits -- FIXME Those tests are flaky - -- , H.ignoreOnWindows "InfoAction" LedgerEvents.hprop_ledger_events_info_action - , H.ignoreOnWindows "DRep Retirement" Gov.hprop_drep_retirement - , H.ignoreOnMacAndWindows "Propose And Ratify New Constitution" Gov.hprop_ledger_events_propose_new_constitution - , H.ignoreOnWindows "Propose New Constitution SPO" Gov.hprop_ledger_events_propose_new_constitution_spo - , H.ignoreOnWindows "Treasury Withdrawal" Gov.hprop_ledger_events_treasury_withdrawal + -- , ignoreOnWindows "InfoAction" LedgerEvents.hprop_ledger_events_info_action + , ignoreOnWindows "DRep Retirement" Gov.hprop_drep_retirement + , ignoreOnMacAndWindows "Propose And Ratify New Constitution" Gov.hprop_ledger_events_propose_new_constitution + , ignoreOnWindows "Propose New Constitution SPO" Gov.hprop_ledger_events_propose_new_constitution_spo + , ignoreOnWindows "Treasury Withdrawal" Gov.hprop_ledger_events_treasury_withdrawal ] , T.testGroup "Plutus" - [ H.ignoreOnWindows "PlutusV3" Cardano.Testnet.Test.Cli.Conway.Plutus.hprop_plutus_v3] + [ ignoreOnWindows "PlutusV3" Cardano.Testnet.Test.Cli.Conway.Plutus.hprop_plutus_v3] ] , T.testGroup "CLI" - [ H.ignoreOnWindows "Shutdown" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdown + [ ignoreOnWindows "Shutdown" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdown -- ShutdownOnSigint fails on Mac with -- "Log file: /private/tmp/tmp.JqcjW7sLKS/kes-period-info-2-test-30c2d0d8eb042a37/logs/test-spo.stdout.log had no logs indicating the relevant node has minted blocks." - , H.ignoreOnMacAndWindows "Shutdown On Sigint" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSigint + , ignoreOnMacAndWindows "Shutdown On Sigint" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSigint -- ShutdownOnSlotSynced FAILS Still. The node times out and it seems the "shutdown-on-slot-synced" flag does nothing - -- , H.ignoreOnWindows "ShutdownOnSlotSynced" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSlotSynced + -- , ignoreOnWindows "ShutdownOnSlotSynced" Cardano.Testnet.Test.Node.Shutdown.hprop_shutdownOnSlotSynced , T.testGroup "Babbage" - [ 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 + [ ignoreOnMacAndWindows "leadership-schedule" Cardano.Testnet.Test.Cli.Babbage.LeadershipSchedule.hprop_leadershipSchedule -- FAILS + , ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot.hprop_stakeSnapshot + , ignoreOnWindows "transaction" Cardano.Testnet.Test.Cli.Babbage.Transaction.hprop_transaction ] -- TODO: Conway - Re-enable when create-staked is working in conway again --, T.testGroup "Conway" - -- [ H.ignoreOnWindows "stake-snapshot" Cardano.Testnet.Test.Cli.Conway.StakeSnapshot.hprop_stakeSnapshot + -- [ 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 - , H.ignoreOnWindows "query-slot-number" Cardano.Testnet.Test.Cli.QuerySlotNumber.hprop_querySlotNumber - , H.ignoreOnWindows "foldEpochState receives ledger state" Cardano.Testnet.Test.FoldEpochState.prop_foldEpochState - , H.ignoreOnWindows "CliQueries" Cardano.Testnet.Test.Cli.Query.hprop_cli_queries + , ignoreOnWindows "kes-period-info" Cardano.Testnet.Test.Cli.KesPeriodInfo.hprop_kes_period_info + , ignoreOnWindows "query-slot-number" Cardano.Testnet.Test.Cli.QuerySlotNumber.hprop_querySlotNumber + , ignoreOnWindows "foldEpochState receives ledger state" Cardano.Testnet.Test.FoldEpochState.prop_foldEpochState + , ignoreOnWindows "CliQueries" Cardano.Testnet.Test.Cli.Query.hprop_cli_queries ] ] , T.testGroup "SubmitApi" [ T.testGroup "Babbage" - [ H.ignoreOnWindows "transaction" Cardano.Testnet.Test.SubmitApi.Babbage.Transaction.hprop_transaction + [ ignoreOnWindows "transaction" Cardano.Testnet.Test.SubmitApi.Babbage.Transaction.hprop_transaction ] ] ]