Skip to content

Commit

Permalink
Add CLI test for creating genesis key delegation certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
intricate committed Sep 2, 2020
1 parent 9733b45 commit 8aa273e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 13 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ test-suite cardano-cli-golden
Test.Golden.Shelley.StakeAddress.KeyGen
Test.Golden.Shelley.StakeAddress.RegistrationCertificate
Test.Golden.Shelley.StakePool.RegistrationCertificate
Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegationCertificate
Test.Golden.Shelley.TextEnvelope.Certificates.MIRCertificate
Test.Golden.Shelley.TextEnvelope.Certificates.OperationalCertificate
Test.Golden.Shelley.TextEnvelope.Certificates.StakeAddressCertificates
Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/test/Test/Golden/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import Test.Golden.Shelley.StakeAddress.RegistrationCertificate
(golden_shelleyStakeAddressRegistrationCertificate)
import Test.Golden.Shelley.StakePool.RegistrationCertificate
(golden_shelleyStakePoolRegistrationCertificate)
import Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegationCertificate
(golden_shelleyGenesisKeyDelegationCertificate)
import Test.Golden.Shelley.TextEnvelope.Certificates.MIRCertificate
(golden_shelleyMIRCertificate)
import Test.Golden.Shelley.TextEnvelope.Certificates.OperationalCertificate
Expand Down Expand Up @@ -121,6 +123,7 @@ certificateTests =
, ("golden_shelleyOperationalCertificate", golden_shelleyOperationalCertificate)
, ("golden_shelleyStakePoolCertificates", golden_shelleyStakePoolCertificates)
, ("golden_shelleyMIRCertificate", golden_shelleyMIRCertificate)
, ("golden_shelleyGenesisKeyDelegationCertificate", golden_shelleyGenesisKeyDelegationCertificate)
]

metaDatatests :: IO Bool
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegationCertificate
( golden_shelleyGenesisKeyDelegationCertificate
) where

import Cardano.Prelude

import Hedgehog (Property)

import Cardano.Api.Typed (AsType (..), HasTextEnvelope (..))

import Test.OptParse

{- HLINT ignore "Use camelCase" -}

golden_shelleyGenesisKeyDelegationCertificate :: Property
golden_shelleyGenesisKeyDelegationCertificate =
propertyOnce . moduleWorkspace "tmp" $ \tempDir -> do
-- Reference certificate
referenceCertificateFilePath <-
noteInputFile $
"test/data/golden/shelley/certificates/"
<> "genesis_key_delegation_certificate"

-- Verification key and certificate filepaths
genesisVerKeyFilePath <-
noteTempFile tempDir "genesis-verification-key-file"
genesisDelegVerKeyFilePath <-
noteTempFile tempDir "genesis-delegate-verification-key-file"
vrfVerKeyFilePath <- noteTempFile tempDir "vrf-verification-key-file"
genesisKeyDelegCertFilePath <-
noteTempFile tempDir "genesis-key-delegation-certificate-file"

-- Generate genesis key pair
void $ execCardanoCLI
[ "shelley","genesis","key-gen-genesis"
, "--verification-key-file", genesisVerKeyFilePath
, "--signing-key-file", "/dev/null"
]

-- Generate genesis delegate key pair
void $ execCardanoCLI
[ "shelley","genesis","key-gen-delegate"
, "--verification-key-file", genesisDelegVerKeyFilePath
, "--signing-key-file", "/dev/null"
, "--operational-certificate-issue-counter-file", "/dev/null"
]

-- Generate VRF key pair
void $ execCardanoCLI
[ "shelley","node","key-gen-VRF"
, "--verification-key-file", vrfVerKeyFilePath
, "--signing-key-file", "/dev/null"
]

assertFilesExist
[ genesisVerKeyFilePath
, genesisDelegVerKeyFilePath
, vrfVerKeyFilePath
]

-- Create genesis key delegation certificate
void $ execCardanoCLI
[ "shelley","governance","create-genesis-key-delegation-certificate"
, "--genesis-verification-key-file", genesisVerKeyFilePath
, "--genesis-delegate-verification-key-file", genesisDelegVerKeyFilePath
, "--vrf-verification-key-file", vrfVerKeyFilePath
, "--out-file", genesisKeyDelegCertFilePath
]

assertFilesExist [genesisKeyDelegCertFilePath]

let certificateType = textEnvelopeType AsCertificate

checkTextEnvelopeFormat
certificateType
referenceCertificateFilePath
genesisKeyDelegCertFilePath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "CertificateShelley",
"description": "Genesis Key Delegation Certificate",
"cborHex": "8405581cc3db461200fa59c81a4ecc8495446d9e42de27483ff6ee4339c9ab94581cd52ac434259f2af7fd2a538ece5ef8d80386527aa93e207473acb31c58201b9de69baec0dff8dde6e81d71f40f8b65fb3df55bb6ece5783aade88b17354d"
}

0 comments on commit 8aa273e

Please sign in to comment.