Skip to content

Commit

Permalink
Merge pull request #453 from input-output-hk/drep_key_hash_golden
Browse files Browse the repository at this point in the history
Add golden tests for `--drep-key-hash` in `governance drep`
  • Loading branch information
mkoura authored Nov 14, 2023
2 parents 02d1f4b + 86337a6 commit 7082071
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
90 changes: 80 additions & 10 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ hprop_golden_governance_drep_id_hex =

H.diffFileVsGoldenFile idFile idGold

hprop_golden_governance_drep_retirement_certificate :: Property
hprop_golden_governance_drep_retirement_certificate =
hprop_golden_governance_drep_retirement_certificate_vkey_file :: Property
hprop_golden_governance_drep_retirement_certificate_vkey_file =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
drepVKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/drep.vkey"
certFile <- H.noteTempFile tempDir "drep.retirement.cert"
Expand All @@ -102,9 +102,43 @@ hprop_golden_governance_drep_retirement_certificate =

H.diffFileVsGoldenFile certFile goldenDRepRetirementCertFile

hprop_golden_governance_drep_retirement_certificate_id_hex :: Property
hprop_golden_governance_drep_retirement_certificate_id_hex =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
certFile <- H.noteTempFile tempDir "drep.retirement.cert"
goldenDRepRetirementCertFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert"

idFile <- H.readFile "test/cardano-cli-golden/files/input/drep.id.hex"

void $ execCardanoCLI
[ "conway", "governance", "drep", "retirement-certificate"
, "--drep-key-hash", idFile
, "--deposit-amt", "1000000"
, "--out-file", certFile
]

H.diffFileVsGoldenFile certFile goldenDRepRetirementCertFile

hprop_golden_governance_drep_retirement_certificate_id_bech32 :: Property
hprop_golden_governance_drep_retirement_certificate_id_bech32 =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
certFile <- H.noteTempFile tempDir "drep.retirement.cert"
goldenDRepRetirementCertFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert"

idFile <- H.readFile "test/cardano-cli-golden/files/input/drep.id.bech32"

void $ execCardanoCLI
[ "conway", "governance", "drep", "retirement-certificate"
, "--drep-key-hash", idFile
, "--deposit-amt", "1000000"
, "--out-file", certFile
]

H.diffFileVsGoldenFile certFile goldenDRepRetirementCertFile

hprop_golden_governance_drep_metadata_hash :: Property
hprop_golden_governance_drep_metadata_hash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
goldenDRepMetadataHash <- noteInputFile "test/cardano-cli-golden/files/golden/governance/drep/drep_metadata_hash"
goldenDRepMetadataHash <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_metadata_hash"

drepMetadataFile <- noteTempFile tempDir "drep-metadata.json"
H.evalIO $ writeFile drepMetadataFile "{ \"Lorem\": \"ipsum\", \"dolor\": \"sit\", \"amet\": \"consectetur\" }"
Expand All @@ -117,22 +151,58 @@ hprop_golden_governance_drep_metadata_hash = propertyOnce . H.moduleWorkspace "t
, "--out-file", outputDRepMetadataHash
]

H.diffFileVsGoldenFile goldenDRepMetadataHash outputDRepMetadataHash
H.diffFileVsGoldenFile outputDRepMetadataHash goldenDRepMetadataHash

hprop_golden_governance_drep_registration_certificate_vkey_file :: Property
hprop_golden_governance_drep_registration_certificate_vkey_file = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
drepVKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/drep.vkey"
goldenFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json"

outFile <- H.noteTempFile tempDir "drep-reg-cert.txt"

void $ execCardanoCLI
[ "conway", "governance", "drep", "registration-certificate"
, "--drep-verification-key-file", drepVKeyFile
, "--key-reg-deposit-amt", "0"
, "--drep-metadata-url", "dummy-url"
, "--drep-metadata-hash", "52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile goldenFile

hprop_golden_governance_drep_registration_certificate_id_hex :: Property
hprop_golden_governance_drep_registration_certificate_id_hex = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
goldenFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json"
idFile <- H.readFile "test/cardano-cli-golden/files/input/drep.id.hex"

outFile <- H.noteTempFile tempDir "drep-reg-cert.txt"

void $ execCardanoCLI
[ "conway", "governance", "drep", "registration-certificate"
, "--drep-key-hash", idFile
, "--key-reg-deposit-amt", "0"
, "--drep-metadata-url", "dummy-url"
, "--drep-metadata-hash", "52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile goldenFile

hprop_golden_governance_drep_registration_certificate :: Property
hprop_golden_governance_drep_registration_certificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
drepKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/drep/drep.vkey"
goldenFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json"
hprop_golden_governance_drep_registration_certificate_id_bech32 :: Property
hprop_golden_governance_drep_registration_certificate_id_bech32 = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
goldenFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json"
idFile <- H.readFile "test/cardano-cli-golden/files/input/drep.id.bech32"

outFile <- H.noteTempFile tempDir "drep-reg-cert.txt"

void $ execCardanoCLI
[ "conway", "governance", "drep", "registration-certificate"
, "--drep-verification-key-file", drepKeyFile
, "--drep-key-hash", idFile
, "--key-reg-deposit-amt", "0"
, "--drep-metadata-url", "dummy-url"
, "--drep-metadata-hash", "52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
, "--out-file", outFile
]

H.diffFileVsGoldenFile goldenFile outFile
H.diffFileVsGoldenFile outFile goldenFile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateShelley",
"description": "DRep Key Registration Certificate",
"cborHex": "84108200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a500826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
"cborHex": "84108200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d00826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drep1avya24t2308yyyr5uw2dqtreemvkwst90dx00j5fj5556meyztm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d

0 comments on commit 7082071

Please sign in to comment.