From 59adca1aa84f3281f1a54479c79b923622e1329b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 29 Sep 2023 17:56:55 +0200 Subject: [PATCH 1/9] create-poll, answer-poll, verify-poll: move to 'babbage governance' block --- cardano-cli/cardano-cli.cabal | 3 + .../CLI/EraBased/Commands/Governance.hs | 5 + .../CLI/EraBased/Commands/Governance/Poll.hs | 37 ++++ .../CLI/EraBased/Options/Governance.hs | 2 + .../CLI/EraBased/Options/Governance/Poll.hs | 69 +++++++ cardano-cli/src/Cardano/CLI/EraBased/Run.hs | 5 + .../CLI/EraBased/Run/Governance/Poll.hs | 170 ++++++++++++++++++ .../Cardano/CLI/Legacy/Commands/Governance.hs | 16 -- cardano-cli/src/Cardano/CLI/Legacy/Options.hs | 31 ---- .../src/Cardano/CLI/Legacy/Run/Governance.hs | 144 --------------- 10 files changed, 291 insertions(+), 191 deletions(-) create mode 100644 cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs create mode 100644 cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs create mode 100644 cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 90146c2766..35fd34ad96 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -75,6 +75,7 @@ library Cardano.CLI.EraBased.Commands.Governance.Actions Cardano.CLI.EraBased.Commands.Governance.Committee Cardano.CLI.EraBased.Commands.Governance.DRep + Cardano.CLI.EraBased.Commands.Governance.Poll Cardano.CLI.EraBased.Commands.Governance.Query Cardano.CLI.EraBased.Commands.Governance.Vote Cardano.CLI.EraBased.Commands.Key @@ -91,6 +92,7 @@ library Cardano.CLI.EraBased.Options.Governance.Actions Cardano.CLI.EraBased.Options.Governance.Committee Cardano.CLI.EraBased.Options.Governance.DRep + Cardano.CLI.EraBased.Options.Governance.Poll Cardano.CLI.EraBased.Options.Governance.Query Cardano.CLI.EraBased.Options.Governance.Vote Cardano.CLI.EraBased.Options.Key @@ -108,6 +110,7 @@ library Cardano.CLI.EraBased.Run.Governance.Actions Cardano.CLI.EraBased.Run.Governance.Committee Cardano.CLI.EraBased.Run.Governance.DRep + Cardano.CLI.EraBased.Run.Governance.Poll Cardano.CLI.EraBased.Run.Governance.Query Cardano.CLI.EraBased.Run.Governance.Vote Cardano.CLI.EraBased.Run.Key diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs index 79033712e8..1532c01e9c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs @@ -13,6 +13,7 @@ import Cardano.CLI.EraBased.Commands.Governance.Actions import Cardano.CLI.EraBased.Commands.Governance.Committee import Cardano.CLI.EraBased.Commands.Governance.DRep import Cardano.CLI.EraBased.Commands.Governance.Query +import Cardano.CLI.EraBased.Commands.Governance.Poll import Cardano.CLI.EraBased.Commands.Governance.Vote import Cardano.CLI.Types.Common @@ -36,6 +37,8 @@ data GovernanceCmds era (GovernanceCommitteeCmds era) | GovernanceDRepCmds (GovernanceDRepCmds era) + | GovernancePollCmds + (GovernancePollCmds era) | GovernanceVoteCmds (GovernanceVoteCmds era) | GovernanceQueryCmds @@ -55,6 +58,8 @@ renderGovernanceCmds = \case renderGovernanceCommitteeCmds cmds GovernanceDRepCmds cmds -> renderGovernanceDRepCmds cmds + GovernancePollCmds cmds -> + renderGovernancePollCmds cmds GovernanceVoteCmds cmds -> renderGovernanceVoteCmds cmds GovernanceQueryCmds cmds -> diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs new file mode 100644 index 0000000000..e2a6886e6d --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} + +module Cardano.CLI.EraBased.Commands.Governance.Poll + ( GovernancePollCmds(..) , renderGovernancePollCmds) where + +import Cardano.Api +import Cardano.Api.Shelley + +import Data.Text (Text) + +data GovernancePollCmds era + = GovernanceCreatePoll -- ^ Create a SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + Text -- ^ Prompt + [Text] -- ^ Choices + (Maybe Word) -- ^ Nonce + (File GovernancePoll Out) + | GovernanceAnswerPoll -- ^ Answer a SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + (File GovernancePoll In) -- ^ Poll file + (Maybe Word) -- ^ Answer index + (Maybe (File () Out)) -- ^ Tx file + | GovernanceVerifyPoll -- ^ Verify answer to a given SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + (File GovernancePoll In) -- Poll file + (File (Tx ()) In) -- Tx file + (Maybe (File () Out)) -- Tx file + + +renderGovernancePollCmds :: () + => GovernancePollCmds era + -> Text +renderGovernancePollCmds = \case + GovernanceCreatePoll {} -> "governance create-poll" + GovernanceAnswerPoll {} -> "governance answer-poll" + GovernanceVerifyPoll {} -> "governance verify-poll" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs index 09ac10b52a..aa9bebb41b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs @@ -15,6 +15,7 @@ import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.EraBased.Options.Governance.Actions import Cardano.CLI.EraBased.Options.Governance.Committee import Cardano.CLI.EraBased.Options.Governance.DRep +import Cardano.CLI.EraBased.Options.Governance.Poll import Cardano.CLI.EraBased.Options.Governance.Query import Cardano.CLI.EraBased.Options.Governance.Vote import Cardano.CLI.Types.Common @@ -39,6 +40,7 @@ pGovernanceCmds era envCli = , fmap GovernanceActionCmds <$> pGovernanceActionCmds era , fmap GovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era , fmap GovernanceDRepCmds <$> pGovernanceDRepCmds era + , fmap GovernancePollCmds <$> pGovernancePollCmds era , fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs new file mode 100644 index 0000000000..60bcac104a --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs @@ -0,0 +1,69 @@ +module Cardano.CLI.EraBased.Options.Governance.Poll + ( pGovernancePollCmds, + ) +where + +import Cardano.Api + +import Cardano.CLI.EraBased.Commands.Governance.Poll (GovernancePollCmds (..)) +import Cardano.CLI.EraBased.Options.Common +import Cardano.Prelude (catMaybes) + +import Data.Foldable +import Options.Applicative hiding (help, str) +import qualified Options.Applicative as Opt + +pGovernancePollCmds :: () + => CardanoEra era + -> Maybe (Parser (GovernancePollCmds era)) +pGovernancePollCmds era = + case parsers of + [] -> Nothing + _ -> Just $ asum parsers + where + parsers = + catMaybes + [ subParser "create-poll" + <$> ( Opt.info + <$> pGovernanceCreatePoll era + <*> pure (Opt.progDesc "Create an SPO poll") + ), + subParser "answer-poll" + <$> ( Opt.info + <$> pGovernanceAnswerPoll era + <*> pure (Opt.progDesc "Answer an SPO poll") + ), + subParser "verify-poll" + <$> ( Opt.info + <$> pGovernanceVerifyPoll era + <*> pure (Opt.progDesc "Verify an answer to a given SPO poll") + ) + ] + +pGovernanceCreatePoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceCreatePoll era = do + w <- maybeEonInEra era + pure $ + GovernanceCreatePoll w + <$> pPollQuestion + <*> some pPollAnswer + <*> optional pPollNonce + <*> pOutputFile + +pGovernanceAnswerPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceAnswerPoll era = do + w <- maybeEonInEra era + pure $ + GovernanceAnswerPoll w + <$> pPollFile + <*> optional pPollAnswerIndex + <*> optional pOutputFile + +pGovernanceVerifyPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceVerifyPoll era = do + w <- maybeEonInEra era + pure $ + GovernanceVerifyPoll w + <$> pPollFile + <*> pPollTxFile + <*> optional pOutputFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs index 6fb79dcf15..60045fcf0b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs @@ -31,6 +31,7 @@ import Cardano.CLI.Types.Errors.CmdError import Control.Monad.Trans.Except import Control.Monad.Trans.Except.Extra (firstExceptT) import Data.Function ((&)) +import Cardano.CLI.EraBased.Run.Governance.Poll (runGovernancePollCmds) runAnyEraCommand :: () => AnyEraCommand @@ -95,6 +96,10 @@ runGovernanceCmds = \case GovernanceDRepCmds cmds -> runGovernanceDRepCmds cmds + GovernancePollCmds cmds -> + runGovernancePollCmds cmds + & firstExceptT CmdGovernanceCmdError + GovernanceVoteCmds cmds -> runGovernanceVoteCmds cmds diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs new file mode 100644 index 0000000000..ef42f893b0 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs @@ -0,0 +1,170 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Cardano.CLI.EraBased.Run.Governance.Poll + ( runGovernancePollCmds + ) where + +import Cardano.Api +import Cardano.Api.Shelley +import qualified Cardano.Api.Shelley as Api + +import Cardano.CLI.EraBased.Commands.Governance.Poll +import Cardano.CLI.Read +import Cardano.CLI.Types.Errors.GovernanceCmdError + +import Control.Monad +import Control.Monad.IO.Class +import Control.Monad.Trans.Class (lift) +import Control.Monad.Trans.Except (ExceptT) +import Control.Monad.Trans.Except.Extra +import qualified Data.ByteString.Char8 as BSC +import Data.Function ((&)) +import Data.String (fromString) +import Data.Text (Text) +import qualified Data.Text as Text +import qualified Data.Text.Encoding as Text +import qualified Data.Text.IO as Text +import qualified Data.Text.Read as Text +import qualified System.IO as IO +import System.IO (stderr, stdin, stdout) + + +runGovernancePollCmds :: GovernancePollCmds era -> ExceptT GovernanceCmdError IO () +runGovernancePollCmds = \case + GovernanceCreatePoll w prompt choices nonce out -> + runGovernanceCreatePoll w prompt choices nonce out + GovernanceAnswerPoll w poll ix mOutFile -> + runGovernanceAnswerPoll w poll ix mOutFile + GovernanceVerifyPoll w poll metadata mOutFile -> + runGovernanceVerifyPoll w poll metadata mOutFile + +runGovernanceCreatePoll + :: BabbageEraOnwards era + -> Text + -> [Text] + -> Maybe Word + -> File GovernancePoll Out + -> ExceptT GovernanceCmdError IO () +runGovernanceCreatePoll _w govPollQuestion govPollAnswers govPollNonce out = do + let poll = GovernancePoll{ govPollQuestion, govPollAnswers, govPollNonce } + + let description = fromString $ "An on-chain poll for SPOs: " <> Text.unpack govPollQuestion + firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ + writeFileTextEnvelope out (Just description) poll + + let metadata = asTxMetadata poll + & metadataToJson TxMetadataJsonDetailedSchema + + let outPath = unFile out & Text.encodeUtf8 . Text.pack + + liftIO $ do + BSC.hPutStrLn stderr $ mconcat + [ "Poll created successfully.\n" + , "Please submit a transaction using the resulting metadata.\n" + ] + BSC.hPutStrLn stdout (prettyPrintJSON metadata) + BSC.hPutStrLn stderr $ mconcat + [ "\n" + , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " + , "from the build or build-raw commands.\n" + , "Hint (2): You can redirect the standard output of this command to a JSON " + , "file to capture metadata.\n\n" + , "Note: A serialized version of the poll suitable for sharing with " + , "participants has been generated at '" <> outPath <> "'." + ] + +runGovernanceAnswerPoll + :: BabbageEraOnwards era + -> File GovernancePoll In + -> Maybe Word -- ^ Answer index + -> Maybe (File () Out) -- ^ Output file + -> ExceptT GovernanceCmdError IO () +runGovernanceAnswerPoll _ pollFile maybeChoice mOutFile = do + poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ + readFileTextEnvelope AsGovernancePoll pollFile + + choice <- case maybeChoice of + Nothing -> do + askInteractively poll + Just ix -> do + validateChoice poll ix + liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" + [ govPollQuestion poll + , "→ " <> (govPollAnswers poll !! fromIntegral ix) + , "" + ] + pure ix + + let pollAnswer = GovernancePollAnswer + { govAnsPoll = hashGovernancePoll poll + , govAnsChoice = choice + } + let metadata = + metadataToJson TxMetadataJsonDetailedSchema (asTxMetadata pollAnswer) + + liftIO $ BSC.hPutStrLn stderr $ mconcat + [ "Poll answer created successfully.\n" + , "Please submit a transaction using the resulting metadata.\n" + , "To be valid, the transaction must also be signed using a valid key\n" + , "identifying your stake pool (e.g. your cold key).\n" + ] + + lift (writeByteStringOutput mOutFile (prettyPrintJSON metadata)) + & onLeft (left . GovernanceCmdWriteFileError) + + liftIO $ BSC.hPutStrLn stderr $ mconcat + [ "\n" + , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " + , "from the build or build-raw commands.\n" + , "Hint (2): You can redirect the standard output of this command to a JSON " + , "file to capture metadata." + ] + where + validateChoice :: GovernancePoll -> Word -> ExceptT GovernanceCmdError IO () + validateChoice GovernancePoll{govPollAnswers} ix = do + let maxAnswerIndex = length govPollAnswers - 1 + when (fromIntegral ix > maxAnswerIndex) $ left $ + GovernanceCmdPollOutOfBoundAnswer maxAnswerIndex + + askInteractively :: GovernancePoll -> ExceptT GovernanceCmdError IO Word + askInteractively poll@GovernancePoll{govPollQuestion, govPollAnswers} = do + liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" + ( govPollQuestion + : [ "[" <> textShow ix <> "] " <> answer + | (ix :: Int, answer) <- zip [0..] govPollAnswers + ] + ) + liftIO $ BSC.hPutStrLn stderr "" + liftIO $ BSC.hPutStr stderr "Please indicate an answer (by index): " + txt <- liftIO $ Text.hGetLine stdin + liftIO $ BSC.hPutStrLn stderr "" + case Text.decimal txt of + Right (choice, rest) | Text.null rest -> + choice <$ validateChoice poll choice + _ -> + left GovernanceCmdPollInvalidChoice + +runGovernanceVerifyPoll + :: BabbageEraOnwards era + -> File GovernancePoll In + -> File (Api.Tx ()) In + -> Maybe (File () Out) -- ^ Output file + -> ExceptT GovernanceCmdError IO () +runGovernanceVerifyPoll _ pollFile txFile mOutFile = do + poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ + readFileTextEnvelope AsGovernancePoll pollFile + + txFileOrPipe <- liftIO $ fileOrPipe (unFile txFile) + tx <- firstExceptT GovernanceCmdCddlError . newExceptT $ + readFileTx txFileOrPipe + + signatories <- firstExceptT GovernanceCmdVerifyPollError . newExceptT $ pure $ + verifyPollAnswer poll tx + + liftIO $ IO.hPutStrLn stderr $ "Found valid poll answer with " <> show (length signatories) <> " signatories" + + lift (writeByteStringOutput mOutFile (prettyPrintJSON signatories)) + & onLeft (left . GovernanceCmdWriteFileError) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs index cbcd49069d..723f908e63 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs @@ -35,19 +35,6 @@ data LegacyGovernanceCmds [VerificationKeyFile In] ProtocolParametersUpdate (Maybe FilePath) - | GovernanceCreatePoll - Text -- Prompt - [Text] -- Choices - (Maybe Word) -- Nonce - (File GovernancePoll Out) - | GovernanceAnswerPoll - (File GovernancePoll In) -- Poll file - (Maybe Word) -- Answer index - (Maybe (File () Out)) -- Tx file - | GovernanceVerifyPoll - (File GovernancePoll In) -- Poll file - (File (Tx ()) In) -- Tx file - (Maybe (File () Out)) -- Tx file deriving Show renderLegacyGovernanceCmds :: LegacyGovernanceCmds -> Text @@ -57,7 +44,4 @@ renderLegacyGovernanceCmds = \case GovernanceMIRTransfer _ _ _ TransferToTreasury -> "governance create-mir-certificate transfer-to-treasury" GovernanceMIRTransfer _ _ _ TransferToReserves -> "governance create-mir-certificate transfer-to-reserves" GovernanceUpdateProposal {} -> "governance create-update-proposal" - GovernanceCreatePoll{} -> "governance create-poll" - GovernanceAnswerPoll{} -> "governance answer-poll" - GovernanceVerifyPoll{} -> "governance verify-poll" diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index 0413c2b53c..cfb2674f77 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -1028,15 +1028,6 @@ pGovernanceCmds envCli = , subParser "create-update-proposal" $ Opt.info pUpdateProposal $ Opt.progDesc "Create an update proposal" - , subParser "create-poll" - $ Opt.info pGovernanceCreatePoll - $ Opt.progDesc "Create an SPO poll" - , subParser "answer-poll" - $ Opt.info pGovernanceAnswerPoll - $ Opt.progDesc "Answer an SPO poll" - , subParser "verify-poll" - $ Opt.info pGovernanceVerifyPoll - $ Opt.progDesc "Verify an answer to a given SPO poll" ] where mirCertParsers :: Parser LegacyGovernanceCmds @@ -1095,28 +1086,6 @@ pGovernanceCmds envCli = <*> pProtocolParametersUpdate <*> optional pCostModels - pGovernanceCreatePoll :: Parser LegacyGovernanceCmds - pGovernanceCreatePoll = - GovernanceCreatePoll - <$> pPollQuestion - <*> some pPollAnswer - <*> optional pPollNonce - <*> pOutputFile - - pGovernanceAnswerPoll :: Parser LegacyGovernanceCmds - pGovernanceAnswerPoll = - GovernanceAnswerPoll - <$> pPollFile - <*> optional pPollAnswerIndex - <*> optional pOutputFile - - pGovernanceVerifyPoll :: Parser LegacyGovernanceCmds - pGovernanceVerifyPoll = - GovernanceVerifyPoll - <$> pPollFile - <*> pPollTxFile - <*> optional pOutputFile - pGenesisCmds :: EnvCli -> Parser LegacyGenesisCmds pGenesisCmds envCli = asum diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs index fc30ca90ac..5a5799a2b3 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs @@ -1,7 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} module Cardano.CLI.Legacy.Run.Governance @@ -11,32 +10,20 @@ module Cardano.CLI.Legacy.Run.Governance import Cardano.Api import qualified Cardano.Api.Ledger as Ledger import Cardano.Api.Shelley -import qualified Cardano.Api.Shelley as Api import Cardano.CLI.EraBased.Run.Governance import Cardano.CLI.Legacy.Commands.Governance -import Cardano.CLI.Read import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GovernanceCmdError import Cardano.CLI.Types.Key import Control.Monad -import Control.Monad.IO.Class -import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra import Data.Aeson (eitherDecode) -import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Lazy as LB import Data.Function ((&)) -import Data.String (fromString) -import Data.Text (Text) import qualified Data.Text as Text -import qualified Data.Text.Encoding as Text -import qualified Data.Text.IO as Text -import qualified Data.Text.Read as Text -import qualified System.IO as IO -import System.IO (stderr, stdin, stdout) runLegacyGovernanceCmds :: LegacyGovernanceCmds -> ExceptT GovernanceCmdError IO () runLegacyGovernanceCmds = \case @@ -48,12 +35,6 @@ runLegacyGovernanceCmds = \case runLegacyGovernanceGenesisKeyDelegationCertificate sbe genVk genDelegVk vrfVk out GovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp -> runLegacyGovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp - GovernanceCreatePoll prompt choices nonce out -> - runLegacyGovernanceCreatePoll prompt choices nonce out - GovernanceAnswerPoll poll ix mOutFile -> - runLegacyGovernanceAnswerPoll poll ix mOutFile - GovernanceVerifyPoll poll metadata mOutFile -> - runLegacyGovernanceVerifyPoll poll metadata mOutFile runLegacyGovernanceMIRCertificatePayStakeAddrs :: EraInEon ShelleyToBabbageEra @@ -163,128 +144,3 @@ runLegacyGovernanceUpdateProposal upFile eNo genVerKeyFiles upPprams mCostModelF firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ writeLazyByteStringFile upFile $ textEnvelopeToJSON Nothing upProp - -runLegacyGovernanceCreatePoll - :: Text - -> [Text] - -> Maybe Word - -> File GovernancePoll Out - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceCreatePoll govPollQuestion govPollAnswers govPollNonce out = do - let poll = GovernancePoll{ govPollQuestion, govPollAnswers, govPollNonce } - - let description = fromString $ "An on-chain poll for SPOs: " <> Text.unpack govPollQuestion - firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ - writeFileTextEnvelope out (Just description) poll - - let metadata = asTxMetadata poll - & metadataToJson TxMetadataJsonDetailedSchema - - let outPath = unFile out & Text.encodeUtf8 . Text.pack - - liftIO $ do - BSC.hPutStrLn stderr $ mconcat - [ "Poll created successfully.\n" - , "Please submit a transaction using the resulting metadata.\n" - ] - BSC.hPutStrLn stdout (prettyPrintJSON metadata) - BSC.hPutStrLn stderr $ mconcat - [ "\n" - , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " - , "from the build or build-raw commands.\n" - , "Hint (2): You can redirect the standard output of this command to a JSON " - , "file to capture metadata.\n\n" - , "Note: A serialized version of the poll suitable for sharing with " - , "participants has been generated at '" <> outPath <> "'." - ] - -runLegacyGovernanceAnswerPoll - :: File GovernancePoll In - -> Maybe Word -- ^ Answer index - -> Maybe (File () Out) -- ^ Output file - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceAnswerPoll pollFile maybeChoice mOutFile = do - poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ - readFileTextEnvelope AsGovernancePoll pollFile - - choice <- case maybeChoice of - Nothing -> do - askInteractively poll - Just ix -> do - validateChoice poll ix - liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" - [ govPollQuestion poll - , "→ " <> (govPollAnswers poll !! fromIntegral ix) - , "" - ] - pure ix - - let pollAnswer = GovernancePollAnswer - { govAnsPoll = hashGovernancePoll poll - , govAnsChoice = choice - } - let metadata = - metadataToJson TxMetadataJsonDetailedSchema (asTxMetadata pollAnswer) - - liftIO $ BSC.hPutStrLn stderr $ mconcat - [ "Poll answer created successfully.\n" - , "Please submit a transaction using the resulting metadata.\n" - , "To be valid, the transaction must also be signed using a valid key\n" - , "identifying your stake pool (e.g. your cold key).\n" - ] - - lift (writeByteStringOutput mOutFile (prettyPrintJSON metadata)) - & onLeft (left . GovernanceCmdWriteFileError) - - liftIO $ BSC.hPutStrLn stderr $ mconcat - [ "\n" - , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " - , "from the build or build-raw commands.\n" - , "Hint (2): You can redirect the standard output of this command to a JSON " - , "file to capture metadata." - ] - where - validateChoice :: GovernancePoll -> Word -> ExceptT GovernanceCmdError IO () - validateChoice GovernancePoll{govPollAnswers} ix = do - let maxAnswerIndex = length govPollAnswers - 1 - when (fromIntegral ix > maxAnswerIndex) $ left $ - GovernanceCmdPollOutOfBoundAnswer maxAnswerIndex - - askInteractively :: GovernancePoll -> ExceptT GovernanceCmdError IO Word - askInteractively poll@GovernancePoll{govPollQuestion, govPollAnswers} = do - liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" - ( govPollQuestion - : [ "[" <> textShow ix <> "] " <> answer - | (ix :: Int, answer) <- zip [0..] govPollAnswers - ] - ) - liftIO $ BSC.hPutStrLn stderr "" - liftIO $ BSC.hPutStr stderr "Please indicate an answer (by index): " - txt <- liftIO $ Text.hGetLine stdin - liftIO $ BSC.hPutStrLn stderr "" - case Text.decimal txt of - Right (choice, rest) | Text.null rest -> - choice <$ validateChoice poll choice - _ -> - left GovernanceCmdPollInvalidChoice - -runLegacyGovernanceVerifyPoll - :: File GovernancePoll In - -> File (Api.Tx ()) In - -> Maybe (File () Out) -- ^ Output file - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceVerifyPoll pollFile txFile mOutFile = do - poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ - readFileTextEnvelope AsGovernancePoll pollFile - - txFileOrPipe <- liftIO $ fileOrPipe (unFile txFile) - tx <- firstExceptT GovernanceCmdCddlError . newExceptT $ - readFileTx txFileOrPipe - - signatories <- firstExceptT GovernanceCmdVerifyPollError . newExceptT $ pure $ - verifyPollAnswer poll tx - - liftIO $ IO.hPutStrLn stderr $ "Found valid poll answer with " <> show (length signatories) <> " signatories" - - lift (writeByteStringOutput mOutFile (prettyPrintJSON signatories)) - & onLeft (left . GovernanceCmdWriteFileError) From 30729eac9c5417e269b7f86ac447d0a962c50cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 2 Oct 2023 12:18:33 +0200 Subject: [PATCH 2/9] Update global help golden file --- .../cardano-cli-golden/files/golden/help.cli | 98 ++++++++++--------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 83bec9c30c..c4ef0af43c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -4970,7 +4970,13 @@ Usage: cardano-cli babbage genesis hash --genesis FILE Compute the hash of a genesis file -Usage: cardano-cli babbage governance (create-mir-certificate | action) +Usage: cardano-cli babbage governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -5043,6 +5049,25 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update - Create a protocol parameters update. +Usage: cardano-cli babbage governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE + + Create an SPO poll + +Usage: cardano-cli babbage governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] + + Answer an SPO poll + +Usage: cardano-cli babbage governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] + + Verify an answer to a given SPO poll + Usage: cardano-cli babbage node ( key-gen | key-gen-KES @@ -7695,7 +7720,13 @@ Usage: cardano-cli latest genesis hash --genesis FILE Compute the hash of a genesis file -Usage: cardano-cli latest governance (create-mir-certificate | action) +Usage: cardano-cli latest governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -7768,6 +7799,25 @@ Usage: cardano-cli latest governance action create-protocol-parameters-update -- Create a protocol parameters update. +Usage: cardano-cli latest governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE + + Create an SPO poll + +Usage: cardano-cli latest governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] + + Answer an SPO poll + +Usage: cardano-cli latest governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] + + Verify an answer to a given SPO poll + Usage: cardano-cli latest node ( key-gen | key-gen-KES @@ -8648,9 +8698,6 @@ Usage: cardano-cli legacy governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -8777,25 +8824,6 @@ Usage: cardano-cli legacy governance create-update-proposal --out-file FILE Create an update proposal -Usage: cardano-cli legacy governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE - - Create an SPO poll - -Usage: cardano-cli legacy governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] - - Answer an SPO poll - -Usage: cardano-cli legacy governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] - - Verify an answer to a given SPO poll - Usage: cardano-cli legacy genesis ( key-gen-genesis | key-gen-delegate @@ -9959,9 +9987,6 @@ Usage: cardano-cli governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -10088,25 +10113,6 @@ Usage: cardano-cli governance create-update-proposal --out-file FILE Create an update proposal -Usage: cardano-cli governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE - - Create an SPO poll - -Usage: cardano-cli governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] - - Answer an SPO poll - -Usage: cardano-cli governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] - - Verify an answer to a given SPO poll - Usage: cardano-cli genesis ( key-gen-genesis | key-gen-delegate From 56b1fcace895dd88ce4ec69d3adaf380a318468f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 2 Oct 2023 12:19:39 +0200 Subject: [PATCH 3/9] Turn off 'cardano-cli conway governancy poll*' commands. To be reverted once change lands in cardano-api. --- .../src/Cardano/CLI/EraBased/Options/Governance/Poll.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs index 60bcac104a..70210ce971 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs @@ -7,8 +7,9 @@ import Cardano.Api import Cardano.CLI.EraBased.Commands.Governance.Poll (GovernancePollCmds (..)) import Cardano.CLI.EraBased.Options.Common -import Cardano.Prelude (catMaybes) +import Cardano.Prelude (catMaybes, isInfixOf) +import Control.Monad (when) import Data.Foldable import Options.Applicative hiding (help, str) import qualified Options.Applicative as Opt @@ -42,7 +43,8 @@ pGovernancePollCmds era = pGovernanceCreatePoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceCreatePoll era = do - w <- maybeEonInEra era + w <- forEonInEra era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceCreatePoll w <$> pPollQuestion @@ -53,6 +55,7 @@ pGovernanceCreatePoll era = do pGovernanceAnswerPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceAnswerPoll era = do w <- maybeEonInEra era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceAnswerPoll w <$> pPollFile @@ -62,6 +65,7 @@ pGovernanceAnswerPoll era = do pGovernanceVerifyPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceVerifyPoll era = do w <- maybeEonInEra era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceVerifyPoll w <$> pPollFile From dc50e5f3151e66cb1e4e54ab48413d1d7091a38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 2 Oct 2023 16:01:07 +0200 Subject: [PATCH 4/9] Update individual eras golden files --- .../files/golden/help/babbage_governance.cli | 11 ++++++++++- .../files/golden/help/latest_governance.cli | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli index c46b2145a0..1ca4e1eec5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli @@ -1,4 +1,10 @@ -Usage: cardano-cli babbage governance (create-mir-certificate | action) +Usage: cardano-cli babbage governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -9,3 +15,6 @@ Available commands: create-mir-certificate Create an MIR (Move Instantaneous Rewards) certificate action Governance action commands. + create-poll Create an SPO poll + answer-poll Answer an SPO poll + verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli index 4e78e466fa..9833a1a374 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli @@ -1,4 +1,10 @@ -Usage: cardano-cli latest governance (create-mir-certificate | action) +Usage: cardano-cli latest governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -9,3 +15,6 @@ Available commands: create-mir-certificate Create an MIR (Move Instantaneous Rewards) certificate action Governance action commands. + create-poll Create an SPO poll + answer-poll Answer an SPO poll + verify-poll Verify an answer to a given SPO poll From 16cbf442899fdc121908cbfed8c96686623aa4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 2 Oct 2023 20:36:14 +0200 Subject: [PATCH 5/9] Detail: adapt to cardano-api release --- .../src/Cardano/CLI/EraBased/Options/Governance/Poll.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs index 70210ce971..369aea2563 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs @@ -43,7 +43,7 @@ pGovernancePollCmds era = pGovernanceCreatePoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceCreatePoll era = do - w <- forEonInEra era + w <- forEraMaybeEon era when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceCreatePoll w @@ -54,7 +54,7 @@ pGovernanceCreatePoll era = do pGovernanceAnswerPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceAnswerPoll era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceAnswerPoll w @@ -64,7 +64,7 @@ pGovernanceAnswerPoll era = do pGovernanceVerifyPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) pGovernanceVerifyPoll era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced pure $ GovernanceVerifyPoll w From b86b326bf945836ae7ce7a01bbb3140cf7678948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 2 Oct 2023 20:54:22 +0200 Subject: [PATCH 6/9] Adapt tests --- cardano-cli/cardano-cli.cabal | 8 +-- .../Governance/AnswerPoll.hs | 38 ++++++------- .../Governance/CreatePoll.hs | 18 +++---- .../Governance/VerifyPoll.hs | 54 +++++++++---------- .../{shelley => babbage}/governance/cold.vk | 0 .../governance/create/basic.json | 0 .../governance/create/long-text.json | 0 .../governance/polls/basic.answer.0.json | 0 .../governance/polls/basic.answer.1.json | 0 .../governance/polls/basic.json | 0 .../governance/verify/valid | 0 ...cli => babbage_governance_answer-poll.cli} | 6 +-- ...cli => babbage_governance_create-poll.cli} | 8 +-- ...cli => babbage_governance_verify-poll.cli} | 6 +-- .../files/golden/help/governance.cli | 6 --- ....cli => latest_governance_answer-poll.cli} | 2 +- ....cli => latest_governance_create-poll.cli} | 2 +- ....cli => latest_governance_verify-poll.cli} | 2 +- .../files/golden/help/legacy_governance.cli | 6 --- 19 files changed, 72 insertions(+), 84 deletions(-) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Shelley => Babbage}/Governance/AnswerPoll.hs (66%) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Shelley => Babbage}/Governance/CreatePoll.hs (75%) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Shelley => Babbage}/Governance/VerifyPoll.hs (62%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/cold.vk (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/create/basic.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/create/long-text.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/polls/basic.answer.0.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/polls/basic.answer.1.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/polls/basic.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{shelley => babbage}/governance/verify/valid (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{governance_answer-poll.cli => babbage_governance_answer-poll.cli} (61%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{governance_create-poll.cli => babbage_governance_create-poll.cli} (57%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{governance_verify-poll.cli => babbage_governance_verify-poll.cli} (61%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{legacy_governance_answer-poll.cli => latest_governance_answer-poll.cli} (87%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{legacy_governance_create-poll.cli => latest_governance_create-poll.cli} (89%) rename cardano-cli/test/cardano-cli-golden/files/golden/help/{legacy_governance_verify-poll.cli => latest_governance_verify-poll.cli} (87%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 35fd34ad96..cce6c8482b 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -358,7 +358,10 @@ test-suite cardano-cli-golden build-tool-depends: cardano-cli:cardano-cli , tasty-discover:tasty-discover - other-modules: Test.Golden.Byron.SigningKeys + other-modules: Test.Golden.Babbage.Governance.AnswerPoll + Test.Golden.Babbage.Governance.CreatePoll + Test.Golden.Babbage.Governance.VerifyPoll + Test.Golden.Byron.SigningKeys Test.Golden.Byron.Tx Test.Golden.Byron.TxBody Test.Golden.Byron.UpdateProposal @@ -379,9 +382,6 @@ test-suite cardano-cli-golden Test.Golden.Shelley.Genesis.KeyGenGenesis Test.Golden.Shelley.Genesis.KeyGenUtxo Test.Golden.Shelley.Genesis.KeyHash - Test.Golden.Shelley.Governance.AnswerPoll - Test.Golden.Shelley.Governance.CreatePoll - Test.Golden.Shelley.Governance.VerifyPoll Test.Golden.Shelley.Key.ConvertCardanoAddressKey Test.Golden.Shelley.Metadata.StakePoolMetadata Test.Golden.Shelley.MultiSig.Address diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs similarity index 66% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs index fcf4658534..ba0b85a557 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Shelley.Governance.AnswerPoll where +module Test.Golden.Babbage.Governance.AnswerPoll where import Control.Monad (void) @@ -14,13 +14,13 @@ import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} -hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid :: Property -hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" +hprop_golden_babbageGovernanceAnswerPollNeg1Invalid :: Property +hprop_golden_babbageGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI - [ "legacy", "governance", "answer-poll" + [ "babbage", "governance", "answer-poll" , "--poll-file", pollFile , "--answer", "-1" , "--out-file", outFile @@ -30,14 +30,14 @@ hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWor either (const H.success) (const H.failure) result -hprop_golden_shelleyGovernanceAnswerPoll0 :: Property -hprop_golden_shelleyGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json" +hprop_golden_babbageGovernanceAnswerPoll0 :: Property +hprop_golden_babbageGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI - [ "legacy", "governance", "answer-poll" + [ "babbage", "governance", "answer-poll" , "--poll-file", pollFile , "--answer", "0" , "--out-file", outFile @@ -45,14 +45,14 @@ hprop_golden_shelleyGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "go H.diffFileVsGoldenFile outFile expectedAnswerFile -hprop_golden_shelleyGovernanceAnswerPollPos1 :: Property -hprop_golden_shelleyGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json" +hprop_golden_babbageGovernanceAnswerPollPos1 :: Property +hprop_golden_babbageGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI - [ "legacy", "governance", "answer-poll" + [ "babbage", "governance", "answer-poll" , "--poll-file", pollFile , "--answer", "1" , "--out-file", outFile @@ -60,13 +60,13 @@ hprop_golden_shelleyGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace H.diffFileVsGoldenFile outFile expectedAnswerFile -hprop_golden_shelleyGovernanceAnswerPollPos2Invalid :: Property -hprop_golden_shelleyGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" +hprop_golden_babbageGovernanceAnswerPollPos2Invalid :: Property +hprop_golden_babbageGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI - [ "legacy", "governance", "answer-poll" + [ "babbage", "governance", "answer-poll" , "--poll-file", pollFile , "--answer", "2" , "--out-file", outFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs similarity index 75% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs index 96ad904e68..1a50fba4cc 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Shelley.Governance.CreatePoll where +module Test.Golden.Babbage.Governance.CreatePoll where import Control.Monad (void) @@ -13,13 +13,13 @@ import qualified Hedgehog.Extras.Test.File as H {- HLINT ignore "Use camelCase" -} -hprop_golden_shelleyGovernanceCreatePoll :: Property -hprop_golden_shelleyGovernanceCreatePoll = +hprop_golden_babbageGovernanceCreatePoll :: Property +hprop_golden_babbageGovernanceCreatePoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" stdout <- execCardanoCLI - [ "legacy", "governance", "create-poll" + [ "babbage", "governance", "create-poll" , "--question", "Pineapples on pizza?" , "--answer", "yes" , "--answer", "no" @@ -27,19 +27,19 @@ hprop_golden_shelleyGovernanceCreatePoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json" + noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile H.assertEndsWithSingleNewline pollFile -hprop_golden_shelleyGovernanceCreateLongPoll :: Property -hprop_golden_shelleyGovernanceCreateLongPoll = +hprop_golden_babbageGovernanceCreateLongPoll :: Property +hprop_golden_babbageGovernanceCreateLongPoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" stdout <- execCardanoCLI - [ "legacy", "governance", "create-poll" + [ "babbage", "governance", "create-poll" , "--question", "What is the most adequate topping to put on a pizza (please consider all possibilities and take time to answer)?" , "--answer", "pineapples" , "--answer", "only traditional topics should go on a pizza, this isn't room for jokes" @@ -47,7 +47,7 @@ hprop_golden_shelleyGovernanceCreateLongPoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json" + noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs similarity index 62% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs index 488a7e9564..d6d086bd15 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Shelley.Governance.VerifyPoll where +module Test.Golden.Babbage.Governance.VerifyPoll where import Cardano.Api @@ -19,15 +19,15 @@ import qualified Hedgehog.Internal.Property as H {- HLINT ignore "Use camelCase" -} -hprop_golden_shelleyGovernanceVerifyPoll :: Property -hprop_golden_shelleyGovernanceVerifyPoll = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/valid" +hprop_golden_babbageGovernanceVerifyPoll :: Property +hprop_golden_babbageGovernanceVerifyPoll = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/valid" vkFile <- VerificationKeyFilePath . File <$> - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/cold.vk" + noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/cold.vk" stdout <- BSC.pack <$> execCardanoCLI - [ "legacy", "governance", "verify-poll" + [ "babbage", "governance", "verify-poll" , "--poll-file", pollFile , "--tx-file", txFile ] @@ -39,52 +39,52 @@ hprop_golden_shelleyGovernanceVerifyPoll = propertyOnce $ do let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] H.assert $ expected `BSC.isInfixOf` stdout -hprop_golden_shelleyGovernanceVerifyPollMismatch :: Property -hprop_golden_shelleyGovernanceVerifyPollMismatch = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch" +hprop_golden_babbageGovernanceVerifyPollMismatch :: Property +hprop_golden_babbageGovernanceVerifyPollMismatch = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/mismatch" result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" + [ "babbage", "governance", "verify-poll" , "--poll-file", pollFile , "--tx-file", txFile ] either (const H.success) (H.failWith Nothing) result -hprop_golden_shelleyGovernanceVerifyPollNoAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollNoAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/none" +hprop_golden_babbageGovernanceVerifyPollNoAnswer :: Property +hprop_golden_babbageGovernanceVerifyPollNoAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/none" result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" + [ "babbage", "governance", "verify-poll" , "--poll-file", pollFile , "--tx-file", txFile ] either (const H.success) (H.failWith Nothing) result -hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed" +hprop_golden_babbageGovernanceVerifyPollMalformedAnswer :: Property +hprop_golden_babbageGovernanceVerifyPollMalformedAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/malformed" result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" + [ "babbage", "governance", "verify-poll" , "--poll-file", pollFile , "--tx-file", txFile ] either (const H.success) (H.failWith Nothing) result -hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid" +hprop_golden_babbageGovernanceVerifyPollInvalidAnswer :: Property +hprop_golden_babbageGovernanceVerifyPollInvalidAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/invalid" result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" + [ "babbage", "governance", "verify-poll" , "--poll-file", pollFile , "--tx-file", txFile ] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.vk b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/cold.vk similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.vk rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/cold.vk diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/valid b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/verify/valid similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/valid rename to cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/verify/valid diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli similarity index 61% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli index 5b98ca49e6..010c8f307d 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli @@ -1,6 +1,6 @@ -Usage: cardano-cli governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] +Usage: cardano-cli babbage governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] Answer an SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli similarity index 57% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli index 1549cb8231..a2ae7fbd74 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli @@ -1,7 +1,7 @@ -Usage: cardano-cli governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE +Usage: cardano-cli babbage governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE Create an SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli similarity index 61% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli index 30915e6559..1ee21545fd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli @@ -1,6 +1,6 @@ -Usage: cardano-cli governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] +Usage: cardano-cli babbage governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli index d06eba4ede..4d83c87bcb 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli @@ -2,9 +2,6 @@ Usage: cardano-cli governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -18,6 +15,3 @@ Available commands: create-genesis-key-delegation-certificate Create a genesis key delegation certificate create-update-proposal Create an update proposal - create-poll Create an SPO poll - answer-poll Answer an SPO poll - verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli similarity index 87% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli index 0c788de0f2..6f74d1dfff 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance answer-poll --poll-file FILE +Usage: cardano-cli latest governance answer-poll --poll-file FILE [--answer INT] [--out-file FILE] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli similarity index 89% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli index 18a3e7f2b2..aae43025f8 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance create-poll --question STRING +Usage: cardano-cli latest governance create-poll --question STRING (--answer STRING) [--nonce UINT] --out-file FILE diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli similarity index 87% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli index 32671bada3..8fa45ec966 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance verify-poll --poll-file FILE +Usage: cardano-cli latest governance verify-poll --poll-file FILE --tx-file FILE [--out-file FILE] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli index b8aa60f019..1ac6d67f4c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli @@ -2,9 +2,6 @@ Usage: cardano-cli legacy governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -18,6 +15,3 @@ Available commands: create-genesis-key-delegation-certificate Create a genesis key delegation certificate create-update-proposal Create an update proposal - create-poll Create an SPO poll - answer-poll Answer an SPO poll - verify-poll Verify an answer to a given SPO poll From 075c3aa7f02894dc17d28378b4f1ce514b93d6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Oct 2023 16:43:03 +0200 Subject: [PATCH 7/9] Remove babbage directory segment from a handful of locations --- cardano-cli/cardano-cli.cabal | 8 ++-- .../Governance/AnswerPoll.hs | 30 ++++++------- .../Governance/CreatePoll.hs | 14 +++--- .../Governance/VerifyPoll.hs | 44 +++++++++---------- .../golden/{babbage => }/governance/cold.vk | 0 .../governance/create/basic.json | 0 .../governance/create/long-text.json | 0 .../governance/polls/basic.answer.0.json | 0 .../governance/polls/basic.answer.1.json | 0 .../{babbage => }/governance/polls/basic.json | 0 10 files changed, 48 insertions(+), 48 deletions(-) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Babbage => EraBased}/Governance/AnswerPoll.hs (65%) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Babbage => EraBased}/Governance/CreatePoll.hs (76%) rename cardano-cli/test/cardano-cli-golden/Test/Golden/{Babbage => EraBased}/Governance/VerifyPoll.hs (67%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/cold.vk (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/create/basic.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/create/long-text.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/polls/basic.answer.0.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/polls/basic.answer.1.json (100%) rename cardano-cli/test/cardano-cli-golden/files/golden/{babbage => }/governance/polls/basic.json (100%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index cce6c8482b..ee5f7a1a2b 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -358,15 +358,15 @@ test-suite cardano-cli-golden build-tool-depends: cardano-cli:cardano-cli , tasty-discover:tasty-discover - other-modules: Test.Golden.Babbage.Governance.AnswerPoll - Test.Golden.Babbage.Governance.CreatePoll - Test.Golden.Babbage.Governance.VerifyPoll - Test.Golden.Byron.SigningKeys + other-modules: Test.Golden.Byron.SigningKeys Test.Golden.Byron.Tx Test.Golden.Byron.TxBody Test.Golden.Byron.UpdateProposal Test.Golden.Byron.Vote Test.Golden.Byron.Witness + Test.Golden.EraBased.Governance.AnswerPoll + Test.Golden.EraBased.Governance.CreatePoll + Test.Golden.EraBased.Governance.VerifyPoll Test.Golden.ErrorsSpec Test.Golden.Governance.Action Test.Golden.Governance.Committee diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs similarity index 65% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs index ba0b85a557..525604da87 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/AnswerPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Babbage.Governance.AnswerPoll where +module Test.Golden.EraBased.Governance.AnswerPoll where import Control.Monad (void) @@ -14,9 +14,9 @@ import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} -hprop_golden_babbageGovernanceAnswerPollNeg1Invalid :: Property -hprop_golden_babbageGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" +hprop_golden_governanceAnswerPollNeg1Invalid :: Property +hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI @@ -30,10 +30,10 @@ hprop_golden_babbageGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWor either (const H.success) (const H.failure) result -hprop_golden_babbageGovernanceAnswerPoll0 :: Property -hprop_golden_babbageGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json" +hprop_golden_governanceAnswerPoll0 :: Property +hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI @@ -45,10 +45,10 @@ hprop_golden_babbageGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "go H.diffFileVsGoldenFile outFile expectedAnswerFile -hprop_golden_babbageGovernanceAnswerPollPos1 :: Property -hprop_golden_babbageGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json" +hprop_golden_governanceAnswerPollPos1 :: Property +hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI @@ -60,9 +60,9 @@ hprop_golden_babbageGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace H.diffFileVsGoldenFile outFile expectedAnswerFile -hprop_golden_babbageGovernanceAnswerPollPos2Invalid :: Property -hprop_golden_babbageGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" +hprop_golden_governanceAnswerPollPos2Invalid :: Property +hprop_golden_governanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs similarity index 76% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs index 1a50fba4cc..477249704d 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/CreatePoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Babbage.Governance.CreatePoll where +module Test.Golden.EraBased.Governance.CreatePoll where import Control.Monad (void) @@ -13,8 +13,8 @@ import qualified Hedgehog.Extras.Test.File as H {- HLINT ignore "Use camelCase" -} -hprop_golden_babbageGovernanceCreatePoll :: Property -hprop_golden_babbageGovernanceCreatePoll = +hprop_golden_governanceCreatePoll :: Property +hprop_golden_governanceCreatePoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" @@ -27,14 +27,14 @@ hprop_golden_babbageGovernanceCreatePoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json" + noteInputFile "test/cardano-cli-golden/files/golden/governance/create/basic.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile H.assertEndsWithSingleNewline pollFile -hprop_golden_babbageGovernanceCreateLongPoll :: Property -hprop_golden_babbageGovernanceCreateLongPoll = +hprop_golden_governanceCreateLongPoll :: Property +hprop_golden_governanceCreateLongPoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" @@ -47,7 +47,7 @@ hprop_golden_babbageGovernanceCreateLongPoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json" + noteInputFile "test/cardano-cli-golden/files/golden/governance/create/long-text.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs similarity index 67% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs index d6d086bd15..8ecc3abb5a 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Babbage/Governance/VerifyPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Babbage.Governance.VerifyPoll where +module Test.Golden.EraBased.Governance.VerifyPoll where import Cardano.Api @@ -19,12 +19,12 @@ import qualified Hedgehog.Internal.Property as H {- HLINT ignore "Use camelCase" -} -hprop_golden_babbageGovernanceVerifyPoll :: Property -hprop_golden_babbageGovernanceVerifyPoll = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/valid" +hprop_golden_governanceVerifyPoll :: Property +hprop_golden_governanceVerifyPoll = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/valid" vkFile <- VerificationKeyFilePath . File <$> - noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/cold.vk" + noteInputFile "test/cardano-cli-golden/files/golden/governance/cold.vk" stdout <- BSC.pack <$> execCardanoCLI [ "babbage", "governance", "verify-poll" @@ -39,10 +39,10 @@ hprop_golden_babbageGovernanceVerifyPoll = propertyOnce $ do let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] H.assert $ expected `BSC.isInfixOf` stdout -hprop_golden_babbageGovernanceVerifyPollMismatch :: Property -hprop_golden_babbageGovernanceVerifyPollMismatch = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/mismatch" +hprop_golden_governanceVerifyPollMismatch :: Property +hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/mismatch" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -52,10 +52,10 @@ hprop_golden_babbageGovernanceVerifyPollMismatch = propertyOnce $ do either (const H.success) (H.failWith Nothing) result -hprop_golden_babbageGovernanceVerifyPollNoAnswer :: Property -hprop_golden_babbageGovernanceVerifyPollNoAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/none" +hprop_golden_governanceVerifyPollNoAnswer :: Property +hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/none" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -65,10 +65,10 @@ hprop_golden_babbageGovernanceVerifyPollNoAnswer = propertyOnce $ do either (const H.success) (H.failWith Nothing) result -hprop_golden_babbageGovernanceVerifyPollMalformedAnswer :: Property -hprop_golden_babbageGovernanceVerifyPollMalformedAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/malformed" +hprop_golden_governanceVerifyPollMalformedAnswer :: Property +hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/malformed" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -78,10 +78,10 @@ hprop_golden_babbageGovernanceVerifyPollMalformedAnswer = propertyOnce $ do either (const H.success) (H.failWith Nothing) result -hprop_golden_babbageGovernanceVerifyPollInvalidAnswer :: Property -hprop_golden_babbageGovernanceVerifyPollInvalidAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/invalid" +hprop_golden_governanceVerifyPollInvalidAnswer :: Property +hprop_golden_governanceVerifyPollInvalidAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/invalid" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/cold.vk b/cardano-cli/test/cardano-cli-golden/files/golden/governance/cold.vk similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/cold.vk rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/cold.vk diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/create/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/create/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/create/long-text.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/create/long-text.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.json From 20124f5ffec8184e257c984dad0ef43bb6a991d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Oct 2023 17:18:55 +0200 Subject: [PATCH 8/9] Better use of golden/input terms --- .../Golden/EraBased/Governance/AnswerPoll.hs | 16 +++++------ .../Golden/EraBased/Governance/CreatePoll.hs | 4 +-- .../Golden/EraBased/Governance/VerifyPoll.hs | 27 ++++++++++--------- .../governance/create/basic.json | 0 .../governance/create/long-text.json | 0 .../governance/polls/basic.json | 0 6 files changed, 24 insertions(+), 23 deletions(-) rename cardano-cli/test/cardano-cli-golden/files/{golden => input}/governance/create/basic.json (100%) rename cardano-cli/test/cardano-cli-golden/files/{golden => input}/governance/create/long-text.json (100%) rename cardano-cli/test/cardano-cli-golden/files/{golden => input}/governance/polls/basic.json (100%) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs index 525604da87..b4485892b8 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs @@ -16,7 +16,7 @@ import qualified Hedgehog.Extras.Test.Golden as H hprop_golden_governanceAnswerPollNeg1Invalid :: Property hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI @@ -32,8 +32,8 @@ hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace hprop_golden_governanceAnswerPoll0 :: Property hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI @@ -43,12 +43,12 @@ hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governanc , "--out-file", outFile ] - H.diffFileVsGoldenFile outFile expectedAnswerFile + H.diffFileVsGoldenFile outFile goldenAnswerFile hprop_golden_governanceAnswerPollPos1 :: Property hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json" outFile <- H.noteTempFile tempDir "answer-file.json" void $ execCardanoCLI @@ -58,11 +58,11 @@ hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "govern , "--out-file", outFile ] - H.diffFileVsGoldenFile outFile expectedAnswerFile + H.diffFileVsGoldenFile outFile goldenAnswerFile hprop_golden_governanceAnswerPollPos2Invalid :: Property hprop_golden_governanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" outFile <- H.noteTempFile tempDir "answer-file.json" result <- tryExecCardanoCLI diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs index 477249704d..169e27d07e 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs @@ -27,7 +27,7 @@ hprop_golden_governanceCreatePoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/governance/create/basic.json" + noteInputFile "test/cardano-cli-golden/files/input/governance/create/basic.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile @@ -47,7 +47,7 @@ hprop_golden_governanceCreateLongPoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/governance/create/long-text.json" + noteInputFile "test/cardano-cli-golden/files/input/governance/create/long-text.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs index 8ecc3abb5a..c3be9464d9 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs @@ -16,15 +16,16 @@ import Test.Cardano.CLI.Util import Hedgehog (Property) import qualified Hedgehog as H import qualified Hedgehog.Internal.Property as H +import qualified Hedgehog.Extras as H {- HLINT ignore "Use camelCase" -} hprop_golden_governanceVerifyPoll :: Property hprop_golden_governanceVerifyPoll = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/valid" - vkFile <- VerificationKeyFilePath . File <$> - noteInputFile "test/cardano-cli-golden/files/golden/governance/cold.vk" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/valid" + goldenVkFile <- VerificationKeyFilePath . File <$> + H.note "test/cardano-cli-golden/files/golden/governance/cold.vk" stdout <- BSC.pack <$> execCardanoCLI [ "babbage", "governance", "verify-poll" @@ -32,7 +33,7 @@ hprop_golden_governanceVerifyPoll = propertyOnce $ do , "--tx-file", txFile ] - liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey vkFile) >>= \case + liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case Left e -> H.failWith Nothing (displayError e) Right vk -> do @@ -41,8 +42,8 @@ hprop_golden_governanceVerifyPoll = propertyOnce $ do hprop_golden_governanceVerifyPollMismatch :: Property hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/mismatch" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/mismatch" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -54,8 +55,8 @@ hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do hprop_golden_governanceVerifyPollNoAnswer :: Property hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/none" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/none" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -67,8 +68,8 @@ hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do hprop_golden_governanceVerifyPollMalformedAnswer :: Property hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/malformed" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/malformed" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" @@ -80,8 +81,8 @@ hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do hprop_golden_governanceVerifyPollInvalidAnswer :: Property hprop_golden_governanceVerifyPollInvalidAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/invalid" + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/invalid" result <- tryExecCardanoCLI [ "babbage", "governance", "verify-poll" diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/create/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/create/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/governance/create/basic.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/create/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/create/long-text.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/create/long-text.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/governance/create/long-text.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/create/long-text.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/polls/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/polls/basic.json From 834d66e53f4b78bc06a075e835c0c482f31504ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 4 Oct 2023 17:35:53 +0200 Subject: [PATCH 9/9] One missing renaming --- .../files/{golden/babbage => input}/governance/verify/valid | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cardano-cli/test/cardano-cli-golden/files/{golden/babbage => input}/governance/verify/valid (100%) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/verify/valid b/cardano-cli/test/cardano-cli-golden/files/input/governance/verify/valid similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/babbage/governance/verify/valid rename to cardano-cli/test/cardano-cli-golden/files/input/governance/verify/valid