From f7d782dbf91360a899db8f7230f24d809a3feca5 Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Fri, 12 Jan 2024 15:48:07 +0100 Subject: [PATCH] Add golden test: `conway governance hash script` --- cardano-cli/cardano-cli.cabal | 1 + .../Test/Golden/Governance/Hash.hs | 26 +++++++++++++++++++ .../golden/governance/hash/foo.script.hash | 1 + .../files/input/governance/hash/foo.script | 5 ++++ 4 files changed, 33 insertions(+) create mode 100644 cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Hash.hs create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/hash/foo.script.hash create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/governance/hash/foo.script diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 725e005bbb..0f5dc594e2 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -373,6 +373,7 @@ test-suite cardano-cli-golden Test.Golden.Governance.Action Test.Golden.Governance.Committee Test.Golden.Governance.DRep + Test.Golden.Governance.Hash Test.Golden.Governance.StakeAddress Test.Golden.Governance.Vote Test.Golden.Help diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Hash.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Hash.hs new file mode 100644 index 0000000000..d8ca07a41a --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Hash.hs @@ -0,0 +1,26 @@ +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} +{-# HLINT ignore "Use camelCase" #-} +module Test.Golden.Governance.Hash where +import Control.Monad + +import Test.Cardano.CLI.Util + +import Hedgehog (Property) +import qualified Hedgehog.Extras as H +import qualified Hedgehog.Extras.Test.Golden as H + + +hprop_golden_governance_hash_script :: Property +hprop_golden_governance_hash_script = + H.propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + scriptFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/hash/foo.script" + hashFile <- H.noteTempFile tempDir "foo.script.hash" + hashGold <- H.note "test/cardano-cli-golden/files/golden/governance/hash/foo.script.hash" + + void $ execCardanoCLI + [ "conway", "governance", "hash", "script" + , "--script-file", scriptFile + , "--out-file", hashFile + ] + + H.diffFileVsGoldenFile hashFile hashGold diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/hash/foo.script.hash b/cardano-cli/test/cardano-cli-golden/files/golden/governance/hash/foo.script.hash new file mode 100644 index 0000000000..67040a92f1 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/hash/foo.script.hash @@ -0,0 +1 @@ +7dde1be4d1a2f617ac343dd7ef0388cf497c19ba8dab653a5b9eb1e2 \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/hash/foo.script b/cardano-cli/test/cardano-cli-golden/files/input/governance/hash/foo.script new file mode 100644 index 0000000000..9511b2d5a0 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/hash/foo.script @@ -0,0 +1,5 @@ +{ + "type": "PlutusScriptV3", + "description": "", + "cborHex": "587458720101003232232322230033006900191480148888888888888888040300422590018c00a442b2600a005180044c010004300322590018c00a4432005225333573466e3c00801c60002600c0061800912c800c6001221801c80148a400644440064c0100042323001001223300330020020011" +}