From 90c8a3a5515e060b328d1fc78c75f9eccd292f2d Mon Sep 17 00:00:00 2001 From: Carlos LopezDeLara <64222734+CarlosLopezDeLara@users.noreply.github.com> Date: Wed, 25 Oct 2023 02:11:44 -0600 Subject: [PATCH] golden tests for stake address delegation certificates --- cardano-cli/cardano-cli.cabal | 1 + .../Test/Golden/Governance/StakeAddress.hs | 98 +++++++++++++++++++ .../stakeaddress/alwaysAbstainDeleg.cert | 5 + .../stakeaddress/noConfidenceDeleg.cert | 5 + .../poolAndAlwaysAbstainDeleg.cert | 5 + .../stakeaddress/poolAndDrepVkeyDeleg.cert | 5 + .../poolAndNoConfidenceDeleg.cert | 5 + .../files/input/conway/poolCold.vkey | 5 + .../files/input/conway/stake.vkey | 5 + 9 files changed, 134 insertions(+) create mode 100644 cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/StakeAddress.hs create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/conway/poolCold.vkey create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/conway/stake.vkey diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 615542140d..718b466cd0 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -374,6 +374,7 @@ test-suite cardano-cli-golden Test.Golden.Governance.Action Test.Golden.Governance.Committee Test.Golden.Governance.DRep + Test.Golden.Governance.StakeAddress Test.Golden.Governance.Vote Test.Golden.Help Test.Golden.Key.NonExtendedKey diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/StakeAddress.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/StakeAddress.hs new file mode 100644 index 0000000000..3b51f7b499 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/StakeAddress.hs @@ -0,0 +1,98 @@ +{- HLINT ignore "Use camelCase" -} + +module Test.Golden.Governance.StakeAddress where + +import Control.Monad (void) + +import Test.Cardano.CLI.Util (execCardanoCLI, noteInputFile, propertyOnce) + +import Hedgehog +import qualified Hedgehog.Extras.Test.Base as H +import qualified Hedgehog.Extras.Test.Golden as H + +hprop_golden_conway_stakeaddress_delegate_no_confidence :: Property +hprop_golden_conway_stakeaddress_delegate_no_confidence = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + vkeyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/stake.vkey" + delegFile <- H.noteTempFile tempDir "deleg" + delegGold <- H.note "test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert" + + void $ execCardanoCLI + [ "conway", "stake-address", "vote-delegation-certificate" + , "--stake-verification-key-file", vkeyFile + , "--always-no-confidence" + , "--out-file", delegFile + ] + + H.diffFileVsGoldenFile delegFile delegGold + +hprop_golden_conway_stakeaddress_delegate_always_abstain :: Property +hprop_golden_conway_stakeaddress_delegate_always_abstain = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + vkeyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/stake.vkey" + delegFile <- H.noteTempFile tempDir "deleg" + delegGold <- H.note "test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert" + + void $ execCardanoCLI + [ "conway", "stake-address", "vote-delegation-certificate" + , "--stake-verification-key-file", vkeyFile + , "--always-abstain" + , "--out-file", delegFile + ] + + H.diffFileVsGoldenFile delegFile delegGold + +hprop_golden_conway_stakeaddress_delegate_pool_and_no_confidence :: Property +hprop_golden_conway_stakeaddress_delegate_pool_and_no_confidence = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + vkeyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/stake.vkey" + vkeyPool <- noteInputFile "test/cardano-cli-golden/files/input/conway/poolCold.vkey" + delegFile <- H.noteTempFile tempDir "deleg" + delegGold <- H.note "test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert" + + void $ execCardanoCLI + [ "conway", "stake-address", "stake-and-vote-delegation-certificate" + , "--stake-verification-key-file", vkeyFile + , "--cold-verification-key-file", vkeyPool + , "--always-no-confidence" + , "--out-file", delegFile + ] + + H.diffFileVsGoldenFile delegFile delegGold + +hprop_golden_conway_stakeaddress_delegate_pool_and_always_abstain :: Property +hprop_golden_conway_stakeaddress_delegate_pool_and_always_abstain = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + vkeyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/stake.vkey" + vkeyPool <- noteInputFile "test/cardano-cli-golden/files/input/conway/poolCold.vkey" + delegFile <- H.noteTempFile tempDir "deleg" + delegGold <- H.note "test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert" + + void $ execCardanoCLI + [ "conway", "stake-address", "stake-and-vote-delegation-certificate" + , "--stake-verification-key-file", vkeyFile + , "--cold-verification-key-file", vkeyPool + , "--always-abstain" + , "--out-file", delegFile + ] + + H.diffFileVsGoldenFile delegFile delegGold + +hprop_golden_conway_stakeaddress_delegate_pool_and_drep :: Property +hprop_golden_conway_stakeaddress_delegate_pool_and_drep = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + vkeyFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/stake.vkey" + vkeyPool <- noteInputFile "test/cardano-cli-golden/files/input/conway/poolCold.vkey" + vkeyDrep <- noteInputFile "test/cardano-cli-golden/files/golden/governance/drep/drep.vkey" + delegFile <- H.noteTempFile tempDir "deleg" + delegGold <- H.note "test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert" + + void $ execCardanoCLI + [ "conway", "stake-address", "stake-and-vote-delegation-certificate" + , "--stake-verification-key-file", vkeyFile + , "--cold-verification-key-file", vkeyPool + , "--drep-verification-key-file", vkeyDrep + , "--out-file", delegFile + ] + + H.diffFileVsGoldenFile delegFile delegGold \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert new file mode 100644 index 0000000000..b2e7d36a9e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018102" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert new file mode 100644 index 0000000000..70884adee7 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018103" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert new file mode 100644 index 0000000000..fcf4bb3f0d --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888102" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert new file mode 100644 index 0000000000..11f95ef09a --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a5" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert new file mode 100644 index 0000000000..100cdf4f9e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888103" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/poolCold.vkey b/cardano-cli/test/cardano-cli-golden/files/input/conway/poolCold.vkey new file mode 100644 index 0000000000..e218864ad0 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/poolCold.vkey @@ -0,0 +1,5 @@ +{ + "type": "StakePoolVerificationKey_ed25519", + "description": "Stake Pool Operator Verification Key", + "cborHex": "58208b2c01cec2081e1f6464b051fd6327a8fc9ed8dabeb4f4db77ea3acad8c4d396" +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/stake.vkey b/cardano-cli/test/cardano-cli-golden/files/input/conway/stake.vkey new file mode 100644 index 0000000000..06fb1bb3a5 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/stake.vkey @@ -0,0 +1,5 @@ +{ + "type": "StakeVerificationKeyShelley_ed25519", + "description": "Stake Verification Key", + "cborHex": "58206562dcf0c258273a2d437d07cdf68492dc961b7277c4a5b50132b05898215778" +} \ No newline at end of file