Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1369: More typed api golden tests for certificates and tx r=Jimbo4350 a=Jimbo4350 Depends on #1360 Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
- Loading branch information
Showing
52 changed files
with
726 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Byron.TextEnvelope.Golden.Tx | ||
( golden_byronTx | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Hedgehog (Property) | ||
|
||
|
||
golden_byronTx :: Property | ||
golden_byronTx = panic "TODO" |
13 changes: 13 additions & 0 deletions
13
cardano-cli/test/Test/CLI/Byron/TextEnvelope/Golden/TxBody.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Byron.TextEnvelope.Golden.TxBody | ||
( golden_byronTxBody | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Hedgehog (Property) | ||
|
||
|
||
golden_byronTxBody :: Property | ||
golden_byronTxBody = panic "TODO" |
13 changes: 13 additions & 0 deletions
13
cardano-cli/test/Test/CLI/Byron/TextEnvelope/Golden/Witness.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Byron.TextEnvelope.Golden.Witness | ||
( golden_byronWitness | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Hedgehog (Property) | ||
|
||
|
||
golden_byronWitness :: Property | ||
golden_byronWitness = panic "TODO" |
17 changes: 17 additions & 0 deletions
17
...li/test/Test/CLI/Shelley/TextEnvelope/Golden/Certificates/GenesisDelegationCertificate.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Shelley.TextEnvelope.Golden.Certificates.GenesisDelegation | ||
( golden_shelleyGenesisDelegationCertificate | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
--import Cardano.Api.Typed (AsType(..), HasTextEnvelope (..)) | ||
|
||
import Hedgehog (Property) | ||
--import qualified Hedgehog as H | ||
|
||
--import Test.OptParse | ||
|
||
golden_shelleyGenesisDelegationCertificate :: Property | ||
golden_shelleyGenesisDelegationCertificate = panic "TODO" |
58 changes: 58 additions & 0 deletions
58
cardano-cli/test/Test/CLI/Shelley/TextEnvelope/Golden/Certificates/MIRCertificate.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Shelley.TextEnvelope.Golden.Certificates.MIRCertificate | ||
( golden_shelleyMIRCertificate | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Cardano.Api.Typed (AsType(..), HasTextEnvelope (..)) | ||
|
||
import Hedgehog (Property) | ||
import qualified Hedgehog as H | ||
|
||
import Test.OptParse | ||
|
||
-- | 1. Generate stake key pair | ||
-- 2. Create MIR certificate | ||
-- s. Check the TextEnvelope serialization format has not changed. | ||
golden_shelleyMIRCertificate :: Property | ||
golden_shelleyMIRCertificate = | ||
propertyOnce $ do | ||
-- Reference keys | ||
let referenceMIRCertificate = "test/Test/golden/shelley/certificates/mir_certificate" | ||
|
||
-- Key filepaths | ||
let verKey = "stake-verification-key-file" | ||
signKey = "stake-signing-key-file" | ||
mirCertificate = "mir-certificate-file" | ||
createdFiles = [verKey, signKey, mirCertificate] | ||
|
||
-- Generate stake key pair | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-address","key-gen" | ||
, "--verification-key-file", verKey | ||
, "--signing-key-file", signKey | ||
] | ||
|
||
assertFilesExist [verKey, signKey] | ||
|
||
-- Create MIR certificate | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","governance","create-mir-certificate" | ||
, "--reserves" --TODO: Should also do "--reserves" | ||
, "--stake-verification-key-file", verKey | ||
, "--reward", "1000" | ||
, "--out-file", mirCertificate | ||
] | ||
|
||
assertFilesExist [mirCertificate] | ||
|
||
let registrationCertificateType = textEnvelopeType AsCertificate | ||
|
||
checkTextEnvelopeFormat createdFiles registrationCertificateType referenceMIRCertificate mirCertificate | ||
|
||
liftIO $ fileCleanup createdFiles | ||
H.success |
76 changes: 76 additions & 0 deletions
76
cardano-cli/test/Test/CLI/Shelley/TextEnvelope/Golden/Certificates/OperationalCertificate.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Shelley.TextEnvelope.Golden.Certificates.OperationalCertificate | ||
( golden_shelleyOperationalCertificate | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Cardano.Api.Typed (AsType(..), HasTextEnvelope (..)) | ||
|
||
import Hedgehog (Property) | ||
import qualified Hedgehog as H | ||
|
||
import Test.OptParse | ||
|
||
-- | 1. Create KES key pair. | ||
-- 2. Create cold keys. | ||
-- 3. Create operational certificate. | ||
-- 4. Check the TextEnvelope serialization format has not changed. | ||
golden_shelleyOperationalCertificate :: Property | ||
golden_shelleyOperationalCertificate = | ||
propertyOnce $ do | ||
|
||
-- Reference keys | ||
let referenceOperationalCertificate = "test/Test/golden/shelley/certificates/operational_certificate" | ||
|
||
-- Key filepaths | ||
let kesVerKey = "KES-verification-key-file" | ||
kesSignKey = "KES-signing-key-file" | ||
coldVerKey = "cold-verification-key-file" | ||
coldSignKey = "cold-signing-key-file" | ||
operationalCertCounter = "operational-certificate-counter-file" | ||
operationalCert = "operational-certificate-file" | ||
createdFiles = [kesVerKey, kesSignKey, coldVerKey, coldSignKey, operationalCertCounter, operationalCert] | ||
|
||
-- Create KES key pair | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","node","key-gen-KES" | ||
, "--verification-key-file", kesVerKey | ||
, "--signing-key-file", kesSignKey | ||
] | ||
|
||
assertFilesExist [kesSignKey, kesVerKey] | ||
|
||
-- Create cold key pair | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","node","key-gen" | ||
, "--cold-verification-key-file", coldVerKey | ||
, "--cold-signing-key-file", coldSignKey | ||
, "--operational-certificate-issue-counter", operationalCertCounter | ||
] | ||
|
||
assertFilesExist [coldVerKey, coldSignKey, operationalCertCounter] | ||
|
||
-- Create operational certificate | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","node","issue-op-cert" | ||
, "--kes-verification-key-file", kesVerKey | ||
, "--cold-signing-key-file", coldSignKey | ||
, "--operational-certificate-issue-counter", operationalCertCounter | ||
, "--kes-period", "1000" | ||
, "--out-file", operationalCert | ||
] | ||
|
||
assertFilesExist createdFiles | ||
let operationalCertificateType = textEnvelopeType AsOperationalCertificate | ||
|
||
-- Check the newly created files have not deviated from the | ||
-- golden files | ||
checkTextEnvelopeFormat createdFiles operationalCertificateType referenceOperationalCertificate operationalCert | ||
|
||
liftIO $ fileCleanup createdFiles | ||
H.success |
88 changes: 88 additions & 0 deletions
88
...no-cli/test/Test/CLI/Shelley/TextEnvelope/Golden/Certificates/StakeAddressCertificates.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.CLI.Shelley.TextEnvelope.Golden.Certificates.StakeAddressCertificates | ||
( golden_shelleyStakeAddressCertificates | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Cardano.Api.Typed (AsType(..), HasTextEnvelope (..)) | ||
|
||
import Hedgehog (Property) | ||
import qualified Hedgehog as H | ||
|
||
import Test.OptParse | ||
|
||
-- | 1. Generate a stake verification key | ||
-- 2. Create a stake address registration certificate | ||
-- 3. Check the TextEnvelope serialization format has not changed. | ||
golden_shelleyStakeAddressCertificates :: Property | ||
golden_shelleyStakeAddressCertificates = | ||
propertyOnce $ do | ||
|
||
-- Reference files | ||
let referenceRegistrationCertificate = "test/Test/golden/shelley/certificates/stake_address_registration_certificate" | ||
referenceDeregistrationCertificate = "test/Test/golden/shelley/certificates/stake_address_deregistration_certificate" | ||
|
||
-- Key filepaths | ||
let verKey = "stake-verification-key-file" | ||
signKey = "stake-signing-key-file" | ||
deregistrationCertificate = "stake-address-deregistration-certificate" | ||
registrationCertificate = "stake-address-registration-certificate" | ||
createdFiles = [verKey, signKey, deregistrationCertificate, registrationCertificate] | ||
|
||
-- Generate stake verification key | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-address","key-gen" | ||
, "--verification-key-file", verKey | ||
, "--signing-key-file", signKey | ||
] | ||
assertFilesExist [verKey, signKey] | ||
|
||
-- Create stake address registration certificate | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-address","registration-certificate" | ||
, "--stake-verification-key-file", verKey | ||
, "--out-file", registrationCertificate | ||
] | ||
|
||
let registrationCertificateType = textEnvelopeType AsCertificate | ||
|
||
-- Check the newly created files have not deviated from the | ||
-- golden files | ||
checkTextEnvelopeFormat createdFiles registrationCertificateType referenceRegistrationCertificate registrationCertificate | ||
|
||
|
||
-- Create stake address deregistration certificate | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-address","deregistration-certificate" | ||
, "--stake-verification-key-file", verKey | ||
, "--out-file", deregistrationCertificate | ||
] | ||
|
||
-- Check the newly created files have not deviated from the | ||
-- golden files | ||
checkTextEnvelopeFormat createdFiles registrationCertificateType referenceDeregistrationCertificate deregistrationCertificate | ||
|
||
-- TODO: After delegation-certificate command is fixed to take a hash instead of a verfication key | ||
{- | ||
-- Create stake address delegation certificate | ||
execCardanoCLIParser | ||
createdFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-address","delegation-certificate" | ||
, "--stake-verification-key-file", verKey | ||
, "--cold-verification-key-file", verKey --TODO: Should be stake pool's hash | ||
, "--out-file", deregistrationCertificate | ||
] | ||
-- Check the newly created files have not deviated from the | ||
-- golden files | ||
checkTextEnvelopeFormat createdFiles registrationCertificateType referenceDeregistrationCertificate deregistrationCertificate | ||
-} | ||
|
||
liftIO $ fileCleanup createdFiles | ||
H.success |
Oops, something went wrong.