Skip to content

Commit

Permalink
Merge pull request #327 from input-output-hk/newhoggy/move-files-that…
Browse files Browse the repository at this point in the history
…-are-not-golden-files-to-input-directory

Move files that are not golden files into `input` directory
  • Loading branch information
newhoggy authored Oct 5, 2023
2 parents 4c615c9 + d52b178 commit e86c152
Show file tree
Hide file tree
Showing 113 changed files with 361 additions and 210 deletions.
2 changes: 2 additions & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ library cardano-cli-test-lib
, bytestring
, cardano-api
, cardano-cli
, directory
, exceptions
, filepath
, hedgehog
, hedgehog-extras ^>= 0.4.7.0
, process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ import Hedgehog.Internal.Property (failWith)

hprop_deserialise_legacy_signing_Key :: Property
hprop_deserialise_legacy_signing_Key = propertyOnce $ do
legSkeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey"
legSkeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"
case deserialiseFromBytes decodeLegacyDelegateKey legSkeyBs of
Left deSerFail -> failWith Nothing $ show deSerFail
Right _ -> success

hprop_deserialise_nonLegacy_signing_Key :: Property
hprop_deserialise_nonLegacy_signing_Key = propertyOnce $ do
skeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
skeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
case deserialiseFromBytes Crypto.fromCBORXPrv skeyBs of
Left deSerFail -> failWith Nothing $ show deSerFail
Right _ -> success

hprop_print_legacy_signing_key_address :: Property
hprop_print_legacy_signing_key_address = propertyOnce $ do
let legKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey"
let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"

void $ execCardanoCLI
[ "signing-key-address", "--byron-legacy-formats"
Expand All @@ -62,7 +62,7 @@ hprop_print_legacy_signing_key_address = propertyOnce $ do

hprop_print_nonLegacy_signing_key_address :: Property
hprop_print_nonLegacy_signing_key_address = propertyOnce $ do
let nonLegKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
let nonLegKeyFp = "test/cardano-cli-golden/files/input/byron/keys/byron.skey"

void $ execCardanoCLI
[ "signing-key-address", "--byron-formats"
Expand All @@ -86,7 +86,7 @@ hprop_generate_and_read_nonlegacy_signingkeys = property $ do
hprop_migrate_legacy_to_nonlegacy_signingkeys :: Property
hprop_migrate_legacy_to_nonlegacy_signingkeys =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
let legKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey"
let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"
nonLegacyKeyFp <- noteTempFile tempDir "nonlegacy.skey"

void $ execCardanoCLI
Expand All @@ -104,14 +104,14 @@ hprop_migrate_legacy_to_nonlegacy_signingkeys =

hprop_deserialise_NonLegacy_Signing_Key_API :: Property
hprop_deserialise_NonLegacy_Signing_Key_API = propertyOnce $ do
eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey NonLegacyByronKeyFormat "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey NonLegacyByronKeyFormat "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
case eFailOrWit of
Left keyFailure -> failWith Nothing $ show keyFailure
Right _ -> success

hprop_deserialiseLegacy_Signing_Key_API :: Property
hprop_deserialiseLegacy_Signing_Key_API = propertyOnce $ do
eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey LegacyByronKeyFormat "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey"
eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey LegacyByronKeyFormat "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"
case eFailOrWit of
Left keyFailure -> failWith Nothing $ show keyFailure
Right _ -> success
26 changes: 13 additions & 13 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import Hedgehog.Internal.Property (failWith)

{- HLINT ignore "Use camelCase" -}

hprop_golden_byronTx_legacy :: Property
hprop_golden_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey"
goldenTx <- noteInputFile "test/cardano-cli-golden/files/golden/byron/tx/legacy.tx"
hprop_byronTx_legacy :: Property
hprop_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"
expectedTx <- noteInputFile "test/cardano-cli-golden/files/input/byron/tx/legacy.tx"
createdTx <- noteTempFile tempDir "tx"
void $ execCardanoCLI
[ "byron", "transaction", "issue-utxo-expenditure"
Expand All @@ -37,12 +37,12 @@ hprop_golden_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir
, "--txout", "(\"2657WMsDfac6eFirdvKVPVMxNVYuACd1RGM2arH3g1y1yaQCr1yYpb2jr2b2aSiDZ\",999)"
]

compareByronTxs createdTx goldenTx
compareByronTxs createdTx expectedTx

hprop_golden_byronTx :: Property
hprop_golden_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
goldenTx <- noteInputFile "test/cardano-cli-golden/files/golden/byron/tx/normal.tx"
hprop_byronTx :: Property
hprop_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
expectedTx <- noteInputFile "test/cardano-cli-golden/files/input/byron/tx/normal.tx"
createdTx <- noteTempFile tempDir "tx"
void $ execCardanoCLI
[ "byron", "transaction", "issue-utxo-expenditure"
Expand All @@ -54,7 +54,7 @@ hprop_golden_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
, "--txout", "(\"2657WMsDfac6eFirdvKVPVMxNVYuACd1RGM2arH3g1y1yaQCr1yYpb2jr2b2aSiDZ\",999)"
]

compareByronTxs createdTx goldenTx
compareByronTxs createdTx expectedTx

getTxByteString :: FilePath -> H.PropertyT IO (ATxAux ByteString)
getTxByteString txFp = do
Expand All @@ -64,8 +64,8 @@ getTxByteString txFp = do
Right aTxAuxBS -> return aTxAuxBS

compareByronTxs :: FilePath -> FilePath -> H.PropertyT IO ()
compareByronTxs createdTx goldenTx = do
compareByronTxs createdTx expectedTx = do
createdATxAuxBS <- getTxByteString createdTx
goldenATxAuxBS <- getTxByteString goldenTx
expectedATxAuxBS <- getTxByteString expectedTx

normalByronTxToGenTx goldenATxAuxBS === normalByronTxToGenTx createdATxAuxBS
normalByronTxToGenTx expectedATxAuxBS === normalByronTxToGenTx createdATxAuxBS
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import Hedgehog.Internal.Property (failWith)

{- HLINT ignore "Use camelCase" -}

hprop_golden_byron_update_proposal :: Property
hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
goldenUpdateProposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
hprop_byron_update_proposal :: Property
hprop_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
expectedUpdateProposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
createdUpdateProposal <- noteTempFile tempDir "byron-update-proposal"
void $ execCardanoCLI
[ "byron", "governance", "create-update-proposal"
Expand All @@ -36,8 +36,8 @@ hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \t
, "--filepath", createdUpdateProposal
]

eGolden <- liftIO . runExceptT $ readByronUpdateProposal goldenUpdateProposal
golden <- case eGolden of
eExpected <- liftIO . runExceptT $ readByronUpdateProposal expectedUpdateProposal
expected <- case eExpected of
Left err -> failWith Nothing . Text.unpack $ renderByronUpdateProposalError err
Right prop -> return prop

Expand All @@ -46,4 +46,4 @@ hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \t
Left err -> failWith Nothing . Text.unpack $ renderByronUpdateProposalError err
Right prop -> return prop

golden === created
expected === created
32 changes: 16 additions & 16 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import Hedgehog.Internal.Property (failWith)

{- HLINT ignore "Use camelCase" -}

hprop_golden_byron_yes_vote :: Property
hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
goldenYesVote <- noteInputFile "test/cardano-cli-golden/files/golden/byron/votes/vote-yes"
proposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
hprop_byron_yes_vote :: Property
hprop_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
expectedYesVote <- noteInputFile "test/cardano-cli-golden/files/input/byron/votes/vote-yes"
proposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
createdYesVote <- noteTempFile tempDir "byron-yes-vote"
void $ execCardanoCLI
[ "byron", "governance", "create-proposal-vote"
Expand All @@ -32,8 +32,8 @@ hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir
, "--output-filepath", createdYesVote
]

eGolden <- liftIO . runExceptT $ readByronVote goldenYesVote
golden <- case eGolden of
eExpected <- liftIO . runExceptT $ readByronVote expectedYesVote
expected <- case eExpected of
Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err
Right prop -> return prop

Expand All @@ -42,13 +42,13 @@ hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir
Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err
Right prop -> return prop

golden === created
expected === created

hprop_golden_byron_no_vote :: Property
hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
goldenNoVote <- noteInputFile "test/cardano-cli-golden/files/golden/byron/votes/vote-no"
proposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey"
hprop_byron_no_vote :: Property
hprop_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
expectedNoVote <- noteInputFile "test/cardano-cli-golden/files/input/byron/votes/vote-no"
proposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal"
signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey"
createdNoVote <- noteTempFile tempDir "byron-no-vote"
void $ execCardanoCLI
[ "byron", "governance", "create-proposal-vote"
Expand All @@ -59,8 +59,8 @@ hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -
, "--output-filepath", createdNoVote
]

eGolden <- liftIO . runExceptT $ readByronVote goldenNoVote
golden <- case eGolden of
eExpected <- liftIO . runExceptT $ readByronVote expectedNoVote
expected <- case eExpected of
Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err
Right prop -> return prop

Expand All @@ -69,4 +69,4 @@ hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -
Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err
Right prop -> return prop

golden === created
expected === created
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Test.Golden.Key.NonExtendedKey where
import Control.Monad (void)
import System.FilePath ((</>))

import qualified Test.Cardano.CLI.Util as H
import Test.Cardano.CLI.Util (execCardanoCLI, propertyOnce)

import Hedgehog (Property)
Expand All @@ -19,7 +20,7 @@ import qualified Hedgehog.Extras.Test.Golden as H
hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey :: Property
hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
genesisVKeyFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/shelley.000.vkey"
genesisVKeyFp <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/shelley.000.vkey"
nonExtendedFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-shelley.000.vkey"
outFp <- H.note $ tempDir </> "non-extended-shelley.000.vkey"

Expand All @@ -42,7 +43,7 @@ hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey =
hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley :: Property
hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
genesisVKeyFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/stake.000.vkey"
genesisVKeyFp <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/stake.000.vkey"
nonExtendedFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-stake.000.vkey"
outFp <- H.note $ tempDir </> "non-extended-stake.000.vkey"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import qualified Hedgehog.Extras.Test.File as H

hprop_golden_shelleyAddressBuild :: Property
hprop_golden_shelleyAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
addressVKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key"
addressSKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key"
goldenStakingAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/addresses/staking-address.hex"
goldenEnterpriseAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/addresses/enterprise-address.hex"
addressVKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key"
addressSKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key"
goldenStakingAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/addresses/staking-address.hex"
goldenEnterpriseAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/addresses/enterprise-address.hex"
stakingAddressHexFile <- noteTempFile tempDir "staking-address.hex"
enterpriseAddressHexFile <- noteTempFile tempDir "enterprise-address.hex"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ parseTotalSupply = J.withObject "Object" $ \ o -> do
hprop_golden_shelleyGenesisCreate :: Property
hprop_golden_shelleyGenesisCreate = propertyOnce $ do
H.moduleWorkspace "tmp" $ \tempDir -> do
sourceGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/genesis/genesis.spec.json"
sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json"
sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json"
sourceGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/genesis/genesis.spec.json"
sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json"
sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json"

genesisSpecFile <- noteTempFile tempDir "genesis.spec.json"
alonzoSpecFile <- noteTempFile tempDir "genesis.alonzo.spec.json"
Expand Down Expand Up @@ -160,11 +160,11 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do
(delegateCount, fmtDelegateCount) <- fmap (OP.withSnd show) $ forAll $ G.int (R.linear 4 19)
(utxoCount, fmtUtxoCount) <- fmap (OP.withSnd show) $ forAll $ G.int (R.linear 4 19)

sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json"
sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json"
alonzoSpecFile <- noteTempFile tempDir "genesis.alonzo.spec.json"
H.copyFile sourceAlonzoGenesisSpecFile alonzoSpecFile

sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json"
sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json"
conwaySpecFile <- noteTempFile tempDir "genesis.conway.spec.json"
H.copyFile sourceConwayGenesisSpecFile conwaySpecFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@ module Test.Golden.Shelley.Genesis.InitialTxIn where
import Test.Cardano.CLI.Util

import Hedgehog (Property)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Golden as H

{- HLINT ignore "Use camelCase" -}

hprop_golden_shelleyGenesisInitialTxIn :: Property
hprop_golden_shelleyGenesisInitialTxIn = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_verification_keys/genesis-utxo.vkey"
hprop_golden_shelleyGenesisInitialTxIn = propertyOnce $ do
verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_verification_keys/genesis-utxo.vkey"
goldenUtxoHashFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_hashes/utxo_hash"
utxoHashFile <- noteTempFile tempDir "utxo_hash"

utxoHash <- execCardanoCLI
[ "genesis","initial-txin"
, "--testnet-magic", "16"
, "--verification-key-file", verificationKeyFile
]

H.writeFile utxoHashFile utxoHash

goldenUtxoHash <- H.readFile goldenUtxoHashFile

equivalence utxoHash goldenUtxoHash
H.diffVsGoldenFile utxoHash goldenUtxoHashFile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import qualified Hedgehog.Extras.Test.File as H

hprop_golden_shelleyGenesisKeyHash :: Property
hprop_golden_shelleyGenesisKeyHash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
referenceVerificationKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key"
goldenGenesisVerificationKeyHashFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key.key-hash"
referenceVerificationKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key"
goldenGenesisVerificationKeyHashFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key.key-hash"
genesisVerificationKeyHashFile <- noteTempFile tempDir "key-hash.hex"

genesisVerificationKeyHash <- execCardanoCLI
Expand Down
Loading

0 comments on commit e86c152

Please sign in to comment.