From 86337a61f08b3065137ac81aa1ad159ed1572ae5 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Tue, 14 Nov 2023 12:26:13 +0100 Subject: [PATCH] Add golden tests for `--drep-key-hash` in `governance drep` --- .../Test/Golden/Governance/DRep.hs | 90 ++++++++++++++++--- .../drep/drep_registration_certificate.json | 2 +- .../files/input/drep.id.bech32 | 1 + .../files/input/drep.id.hex | 1 + 4 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/drep.id.bech32 create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/drep.id.hex diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs index 3da370227c..6917916d7b 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs @@ -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" @@ -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\" }" @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json index c1cc305cb9..9d06ef4021 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json @@ -1,5 +1,5 @@ { "type": "CertificateShelley", "description": "DRep Key Registration Certificate", - "cborHex": "84108200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a500826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2" + "cborHex": "84108200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d00826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2" } diff --git a/cardano-cli/test/cardano-cli-golden/files/input/drep.id.bech32 b/cardano-cli/test/cardano-cli-golden/files/input/drep.id.bech32 new file mode 100644 index 0000000000..524c084e68 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/drep.id.bech32 @@ -0,0 +1 @@ +drep1avya24t2308yyyr5uw2dqtreemvkwst90dx00j5fj5556meyztm \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/drep.id.hex b/cardano-cli/test/cardano-cli-golden/files/input/drep.id.hex new file mode 100644 index 0000000000..c407dd0ee8 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/drep.id.hex @@ -0,0 +1 @@ +eb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d \ No newline at end of file