diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs index 5297b3e1ba..3ec4298fb3 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs @@ -9,6 +9,8 @@ import Cardano.Api (MonadIO) import Control.Monad (void) import Control.Monad.Catch (MonadCatch) import Control.Monad.Trans.Control (MonadBaseControl) +import Data.List (isInfixOf) +import System.Exit (ExitCode (ExitSuccess)) import Test.Cardano.CLI.Hash (exampleAnchorDataHash, exampleAnchorDataHash2, exampleAnchorDataIpfsHash, exampleAnchorDataIpfsHash2, @@ -497,6 +499,50 @@ hprop_golden_conway_governance_action_create_protocol_parameters_update_partial_ "test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action" H.diffFileVsGoldenFile actionFile goldenActionFile +-- | Execute me with: +-- @cabal test cardano-cli-golden --test-options '-p "/golden conway governance action create protocol parameters bad costmodel size/"'@ +hprop_golden_conway_governance_action_create_protocol_parameters_bad_costmodel_size + :: Property +hprop_golden_conway_governance_action_create_protocol_parameters_bad_costmodel_size = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + -- This file has 184 entries, whereas PV1 requires 166 + -- TODO @smelc this test does not pass: the command succeeds, whereas it should fail! + -- runOnCostModelFile tempDir "test/cardano-cli-golden/files/input/governance/costmodels-v1-wrong.json" + -- This file has 184 entries, whereas PV2 requires 185 + runOnCostModelFile tempDir "test/cardano-cli-golden/files/input/governance/costmodels-v2-wrong.json" + -- This file has 184 entries, whereas PV3 requires 297 + runOnCostModelFile tempDir "test/cardano-cli-golden/files/input/governance/costmodels-v3-wrong.json" + where + runOnCostModelFile tempDir costModelsFile = do + stakeAddressVKeyFile <- H.note "test/cardano-cli-golden/files/input/governance/stake-address.vkey" + + actionFile <- noteTempFile tempDir "action" + + (exitCode, _stdout, stderr) <- + H.noteShowM $ + H.execDetailCardanoCLI + [ "conway" + , "governance" + , "action" + , "create-protocol-parameters-update" + , "--anchor-url" + , "example.com" + , "--anchor-data-hash" + , "c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" + , "--mainnet" + , "--deposit-return-stake-verification-key-file" + , stakeAddressVKeyFile + , "--governance-action-deposit" + , "12345" + , "--cost-model-file" + , costModelsFile + , "--out-file" + , actionFile + ] + + H.assert (exitCode /= ExitSuccess) + H.assertWith stderr $ \msg -> "The decoded cost model has the wrong size" `isInfixOf` msg + hprop_golden_conway_governance_action_create_hardfork_wrong_hash_fails :: Property hprop_golden_conway_governance_action_create_hardfork_wrong_hash_fails = propertyOnce . expectFailure . H.moduleWorkspace "tmp" $ \tempDir -> do diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v1-wrong.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v1-wrong.json new file mode 100644 index 0000000000..87bfe9b2f6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v1-wrong.json @@ -0,0 +1,187 @@ +{ "PlutusV1": [ + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v2-wrong.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v2-wrong.json new file mode 100644 index 0000000000..a953433332 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v2-wrong.json @@ -0,0 +1,187 @@ +{ "PlutusV2": [ + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v3-wrong.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v3-wrong.json new file mode 100644 index 0000000000..fc000abaac --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-v3-wrong.json @@ -0,0 +1,187 @@ +{ "PlutusV3": [ + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] +}