Skip to content

Commit

Permalink
Merge pull request #403 from input-output-hk/cl/always-no-confidence
Browse files Browse the repository at this point in the history
Fix delegating to always-no-confidence
  • Loading branch information
CarlosLopezDeLara authored Oct 25, 2023
2 parents 3c51146 + adce798 commit 0eeb3d8
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 5 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3035,7 +3035,7 @@ pVoteDelegationTarget =
asum
[ VoteDelegationTargetOfDRep <$> pDRepHashSource
, VoteDelegationTargetOfAbstain <$ pAlwaysAbstain
, VoteDelegationTargetOfAbstain <$ pAlwaysNoConfidence
, VoteDelegationTargetOfNoConfidence <$ pAlwaysNoConfidence
]

pAlwaysAbstain :: Parser ()
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/StakeAddress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ runStakeAddressStakeDelegationCertificateCmd sbe stakeVerifier poolVKeyOrHashOrF
firstExceptT StakeAddressCmdWriteFileError
. newExceptT
$ writeLazyByteStringFile outFp
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake Address Delegation Certificate") certificate
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake Delegation Certificate") certificate

runStakeAddressStakeAndVoteDelegationCertificateCmd :: ()
=> ConwayEraOnwards era
Expand Down Expand Up @@ -226,7 +226,7 @@ runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeVerifier poolVKeyOrHa
firstExceptT StakeAddressCmdWriteFileError
. newExceptT
$ writeLazyByteStringFile outFp
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake Address Delegation Certificate") certificate
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake and Vote Delegation Certificate") certificate

runStakeAddressVoteDelegationCertificateCmd :: ()
=> ConwayEraOnwards era
Expand Down Expand Up @@ -255,7 +255,7 @@ runStakeAddressVoteDelegationCertificateCmd w stakeVerifier voteDelegationTarget
firstExceptT StakeAddressCmdWriteFileError
. newExceptT
$ writeLazyByteStringFile outFp
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake Address Delegation Certificate") certificate
$ textEnvelopeToJSON (Just @TextEnvelopeDescr "Vote Delegation Certificate") certificate

createStakeDelegationCertificate :: forall era. ()
=> StakeCredential
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Vote Delegation Certificate",
"cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018102"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Vote Delegation Certificate",
"cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018103"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888102"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a5"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888103"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "StakePoolVerificationKey_ed25519",
"description": "Stake Pool Operator Verification Key",
"cborHex": "58208b2c01cec2081e1f6464b051fd6327a8fc9ed8dabeb4f4db77ea3acad8c4d396"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "StakeVerificationKeyShelley_ed25519",
"description": "Stake Verification Key",
"cborHex": "58206562dcf0c258273a2d437d07cdf68492dc961b7277c4a5b50132b05898215778"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"description": "Stake Address Delegation Certificate",
"description": "Stake Delegation Certificate",
"cborHex": "83028200581c6b69790498faca4908e4b44a1005d6dbec9a3d511fa62d4636355ff1581c4124a0c2ba8a7ba05824b3df23f706a1c8b3239446ab16709ae85aa1"
}

0 comments on commit 0eeb3d8

Please sign in to comment.