Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated textEnvelope type on registering a Stake Address Registration Certificate - Tests #499

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Test.Golden.Governance.Committee where
import Control.Monad (void)
import Text.Regex.TDFA ((=~))

import Test.Cardano.CLI.Aeson (assertHasMappings)
import Test.Cardano.CLI.Util

import Hedgehog (Property)
Expand Down Expand Up @@ -121,8 +122,9 @@ hprop_golden_governanceCommitteeCreateHotKeyAuthorizationCertificate =
, "--out-file", certFile
]

H.assertFileOccurences 1 "CertificateShelley" certFile
H.assertFileOccurences 1 "Constitutional Committee Hot Key Registration Certificate" certFile
assertHasMappings [("type", "CertificateConway"),
("description", "Constitutional Committee Hot Key Registration Certificate")]
certFile

hprop_golden_governanceCommitteeCreateColdKeyResignationCertificate :: Property
hprop_golden_governanceCommitteeCreateColdKeyResignationCertificate =
Expand All @@ -144,8 +146,9 @@ hprop_golden_governanceCommitteeCreateColdKeyResignationCertificate =
, "--out-file", certFile
]

H.assertFileOccurences 1 "CertificateShelley" certFile
H.assertFileOccurences 1 "Constitutional Committee Cold Key Resignation Certificate" certFile
assertHasMappings [("type", "CertificateConway"),
("description", "Constitutional Committee Cold Key Resignation Certificate")]
certFile

hprop_golden_governanceUpdateCommittee :: Property
hprop_golden_governanceUpdateCommittee =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import System.FilePath ((</>))

import Test.Cardano.CLI.Util

import Hedgehog (Property)
import Hedgehog (Property, forAll)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Process as H
import qualified Hedgehog.Extras.Test.Golden as H
import Hedgehog.Gen as Gen

{- HLINT ignore "Use camelCase" -}

hprop_golden_shelley_stake_address_deregistration_certificate :: Property
hprop_golden_shelley_stake_address_deregistration_certificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
hprop_golden_shelley_stake_address_deregistration_certificate_shelley_to_babbage :: Property
hprop_golden_shelley_stake_address_deregistration_certificate_shelley_to_babbage = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
-- The certificate type will be CertificateShelley for every era from Shelley to Babbage
eraName <- forAll $ Gen.element ["shelley", "allegra", "mary", "alonzo", "babbage"]
felix-lipski marked this conversation as resolved.
Show resolved Hide resolved
base <- H.getProjectBase

verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key"
Expand All @@ -24,19 +27,48 @@ hprop_golden_shelley_stake_address_deregistration_certificate = propertyOnce . H
exampleScript <- noteInputFile $ base </> "scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus"

void $ execCardanoCLI
[ "babbage", "stake-address","deregistration-certificate"
[ eraName, "stake-address","deregistration-certificate"
, "--staking-verification-key-file", verificationKeyFile
, "--out-file", deregistrationCertFile
]

goldenFile1 <- H.note "test/cardano-cli-golden/files/golden/shelley/dereg-cert-1.json"
goldenFile1 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/dereg-certificate-1.json"
H.diffFileVsGoldenFile deregistrationCertFile goldenFile1

void $ execCardanoCLI
[ "babbage", "stake-address","deregistration-certificate"
[ eraName, "stake-address","deregistration-certificate"
, "--stake-script-file", exampleScript
, "--out-file", scriptDeregistrationCertFile
]

goldenFile2 <- H.note "test/cardano-cli-golden/files/golden/shelley/dereg-cert-2.json"
goldenFile2 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/script-dereg-certificate-1.json"
H.diffFileVsGoldenFile scriptDeregistrationCertFile goldenFile2

hprop_golden_shelley_stake_address_deregistration_certificate_conway :: Property
hprop_golden_shelley_stake_address_deregistration_certificate_conway = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
base <- H.getProjectBase

verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key"
deregistrationCertFile <- noteTempFile tempDir "deregistrationCertFile"
scriptDeregistrationCertFile <- noteTempFile tempDir "scripDeregistrationCertFile"
exampleScript <- noteInputFile $ base </> "scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus"

void $ execCardanoCLI
[ "conway", "stake-address","deregistration-certificate"
, "--staking-verification-key-file", verificationKeyFile
, "--key-reg-deposit-amt", "2000000"
, "--out-file", deregistrationCertFile
]

goldenFile1 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/dereg-certificate-2.json"
H.diffFileVsGoldenFile deregistrationCertFile goldenFile1

void $ execCardanoCLI
[ "conway", "stake-address","deregistration-certificate"
, "--stake-script-file", exampleScript
, "--key-reg-deposit-amt", "2000000"
, "--out-file", scriptDeregistrationCertFile
]

goldenFile2 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/script-dereg-certificate-2.json"
H.diffFileVsGoldenFile scriptDeregistrationCertFile goldenFile2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Hedgehog
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Golden as H
import qualified Hedgehog.Extras.Test.Process as H
import Hedgehog.Gen as Gen

{- HLINT ignore "Use camelCase" -}

Expand Down Expand Up @@ -79,3 +80,33 @@ hprop_golden_shelley_stake_address_registration_certificate_missing_reg_deposit
-- , "--key-reg-deposit-amt", "2000000" This argument being mandatory in conway, the call should fail
, "--out-file", registrationCertFile
]


hprop_golden_shelley_stake_address_registration_certificate_every_shelley_to_babbage_era :: Property
hprop_golden_shelley_stake_address_registration_certificate_every_shelley_to_babbage_era = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
-- The certificate type will be CertificateShelley for every era from Shelley to Babbage
eraName <- forAll $ Gen.element ["shelley", "allegra", "mary", "alonzo", "babbage"]
base <- H.getProjectBase

keyGenStakingVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key"
registrationCertFile <- noteTempFile tempDir "registration.cert"
scriptRegistrationCertFile <- noteTempFile tempDir "script-registration.cert"
exampleScript <- noteInputFile $ base </> "scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus"

void $ execCardanoCLI
[ eraName, "stake-address", "registration-certificate"
, "--staking-verification-key-file", keyGenStakingVerificationKeyFile
, "--out-file", registrationCertFile
]

goldenFile1 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-1.json"
H.diffFileVsGoldenFile registrationCertFile goldenFile1

void $ execCardanoCLI
[ eraName, "stake-address", "registration-certificate"
, "--stake-script-file", exampleScript
, "--out-file", scriptRegistrationCertFile
]

goldenFile2 <- H.note "test/cardano-cli-golden/files/golden/shelley/stake-address/script-reg-certificate.json"
H.diffFileVsGoldenFile scriptRegistrationCertFile goldenFile2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "DRep Key Registration Certificate",
"cborHex": "84108200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d00826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "DRep Retirement Certificate",
"cborHex": "83118200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d1a000f4240"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Vote Delegation Certificate",
"cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018102"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Vote Delegation Certificate",
"cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018103"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888102"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a5"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Stake and Vote Delegation Certificate",
"cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888103"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateConway",
"description": "Stake Address Deregistration Certificate",
"cborHex": "83088200581c81b4245f84593f63c0ff2296930254f77a0690fa9de5f969cac27cb01a001e8480"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"type": "CertificateConway",
"description": "Stake Address Registration Certificate",
"cborHex": "83078200581c81b4245f84593f63c0ff2296930254f77a0690fa9de5f969cac27cb01a001e8480"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateConway",
"description": "Stake Address Deregistration Certificate",
"cborHex": "83088201581cb9ff787a6dedf9ebe602a26352803778805428c7521b99ec7542aa011a001e8480"
}
Loading