Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2025-06-22T20:18:27Z
, hackage.haskell.org 2025-06-27T07:48:39Z
, cardano-haskell-packages 2025-06-22T22:27:17Z

packages:
Expand Down
9 changes: 6 additions & 3 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ library cardano-cli-test-lib
exceptions,
filepath,
hedgehog,
hedgehog-extras >=0.7.1,
hedgehog-extras >=0.9,
http-types,
lifted-base,
mmorph,
Expand Down Expand Up @@ -366,7 +366,7 @@ test-suite cardano-cli-test
exceptions,
filepath,
hedgehog,
hedgehog-extras,
hedgehog-extras >=0.8,
microlens,
microlens-aeson,
mmorph,
Expand Down Expand Up @@ -439,17 +439,19 @@ test-suite cardano-cli-golden
cardano-crypto-wrapper,
cardano-strict-containers ^>=0.1,
cborg,
containers,
directory,
exceptions,
extra,
filepath,
hedgehog >=1.4,
hedgehog-extras,
hedgehog-extras >=0.8,
monad-control,
regex-compat,
regex-tdfa,
rio,
tasty,
tasty-discover,
tasty-hedgehog,
text,

Expand Down Expand Up @@ -518,6 +520,7 @@ test-suite cardano-cli-golden
Test.Golden.Shelley.Transaction.Id
Test.Golden.Shelley.Transaction.Sign
Test.Golden.TxView
Test.Golden.Util
Test.Golden.Version

ghc-options:
Expand Down
208 changes: 101 additions & 107 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/SigningKeys.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Byron.SigningKeys
( hprop_deserialise_legacy_signing_Key
, hprop_deserialise_nonLegacy_signing_Key
, hprop_deserialise_NonLegacy_Signing_Key_API
, hprop_deserialiseLegacy_Signing_Key_API
, hprop_generate_and_read_nonlegacy_signingkeys
, hprop_migrate_legacy_to_nonlegacy_signingkeys
, hprop_print_legacy_signing_key_address
, hprop_print_nonLegacy_signing_key_address
( tasty_deserialise_legacy_signing_Key
, tasty_deserialise_nonLegacy_signing_Key
, tasty_deserialise_NonLegacy_Signing_Key_API
, tasty_deserialiseLegacy_Signing_Key_API
, tasty_generate_and_read_nonlegacy_signingkeys
, tasty_migrate_legacy_to_nonlegacy_signingkeys
, tasty_print_legacy_signing_key_address
, tasty_print_nonLegacy_signing_key_address
)
where

Expand All @@ -28,86 +28,82 @@ import Data.ByteString.Lazy qualified as LB

import Test.Cardano.CLI.Util

import Hedgehog (Property, property, success)
import Hedgehog (success)
import Hedgehog qualified as H
import Hedgehog.Extras (UnitIO)
import Hedgehog.Extras.Test.Base qualified as H
import Hedgehog.Internal.Property (failWith)

hprop_deserialise_legacy_signing_Key :: Property
hprop_deserialise_legacy_signing_Key =
watchdogProp . propertyOnce $ do
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 =
watchdogProp . propertyOnce $ do
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 =
watchdogProp . propertyOnce $ do
let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-legacy-formats"
, "--testnet-magic"
, "42"
, "--secret"
, legKeyFp
]

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-legacy-formats"
, "--mainnet"
, "--secret"
, legKeyFp
]

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

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-formats"
, "--testnet-magic"
, "42"
, "--secret"
, nonLegKeyFp
]

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-formats"
, "--mainnet"
, "--secret"
, nonLegKeyFp
]

hprop_generate_and_read_nonlegacy_signingkeys :: Property
hprop_generate_and_read_nonlegacy_signingkeys =
watchdogProp . property $ do
byronSkey <- H.evalIO $ generateSigningKey AsByronKey
case deserialiseFromRawBytes (AsSigningKey AsByronKey) (serialiseToRawBytes byronSkey) of
Left _ -> failWith Nothing "Failed to deserialise non-legacy Byron signing key. "
Right _ -> success

hprop_migrate_legacy_to_nonlegacy_signingkeys :: Property
hprop_migrate_legacy_to_nonlegacy_signingkeys =
watchdogProp . propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_deserialise_legacy_signing_Key :: UnitIO ()
tasty_deserialise_legacy_signing_Key = do
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

tasty_deserialise_nonLegacy_signing_Key :: UnitIO ()
tasty_deserialise_nonLegacy_signing_Key = do
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

tasty_print_legacy_signing_key_address :: UnitIO ()
tasty_print_legacy_signing_key_address = do
let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-legacy-formats"
, "--testnet-magic"
, "42"
, "--secret"
, legKeyFp
]

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-legacy-formats"
, "--mainnet"
, "--secret"
, legKeyFp
]

tasty_print_nonLegacy_signing_key_address :: UnitIO ()
tasty_print_nonLegacy_signing_key_address = do
let nonLegKeyFp = "test/cardano-cli-golden/files/input/byron/keys/byron.skey"

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-formats"
, "--testnet-magic"
, "42"
, "--secret"
, nonLegKeyFp
]

void $
execCardanoCLI
[ "signing-key-address"
, "--byron-formats"
, "--mainnet"
, "--secret"
, nonLegKeyFp
]

tasty_generate_and_read_nonlegacy_signingkeys :: UnitIO ()
tasty_generate_and_read_nonlegacy_signingkeys = do
byronSkey <- H.evalIO $ generateSigningKey AsByronKey
case deserialiseFromRawBytes (AsSigningKey AsByronKey) (serialiseToRawBytes byronSkey) of
Left _ -> failWith Nothing "Failed to deserialise non-legacy Byron signing key. "
Right _ -> success

tasty_migrate_legacy_to_nonlegacy_signingkeys :: UnitIO ()
tasty_migrate_legacy_to_nonlegacy_signingkeys =
H.moduleWorkspace "tmp" $ \tempDir -> do
let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey"
nonLegacyKeyFp <- noteTempFile tempDir "nonlegacy.skey"

Expand All @@ -128,26 +124,24 @@ hprop_migrate_legacy_to_nonlegacy_signingkeys =
Left err -> failWith Nothing $ show err
Right _ -> success

hprop_deserialise_NonLegacy_Signing_Key_API :: Property
hprop_deserialise_NonLegacy_Signing_Key_API =
watchdogProp . propertyOnce $ do
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 =
watchdogProp . propertyOnce $ do
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
tasty_deserialise_NonLegacy_Signing_Key_API :: UnitIO ()
tasty_deserialise_NonLegacy_Signing_Key_API = do
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

tasty_deserialiseLegacy_Signing_Key_API :: UnitIO ()
tasty_deserialiseLegacy_Signing_Key_API = do
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
15 changes: 8 additions & 7 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import GHC.Stack

import Test.Cardano.CLI.Util

import Hedgehog (MonadTest, Property, (===))
import Hedgehog (MonadTest, (===))
import Hedgehog.Extras (UnitIO)
import Hedgehog.Extras.Test.Base qualified as H
import Hedgehog.Internal.Property (failWith)

{- HLINT ignore "Use camelCase" -}

hprop_byronTx_legacy :: Property
hprop_byronTx_legacy =
watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_byronTx_legacy :: UnitIO ()
tasty_byronTx_legacy =
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"
Expand All @@ -43,9 +44,9 @@ hprop_byronTx_legacy =

compareByronTxs createdTx expectedTx

hprop_byronTx :: Property
hprop_byronTx =
watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_byronTx :: UnitIO ()
tasty_byronTx =
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module Test.Golden.Byron.TxBody where

import Test.Cardano.CLI.Util (propertyOnce, watchdogProp)

import Hedgehog (Property, success)
import Hedgehog (success)
import Hedgehog.Extras (UnitIO)

{- HLINT ignore "Use camelCase" -}

hprop_golden_byronTxBody :: Property
hprop_golden_byronTxBody =
watchdogProp . propertyOnce $ success -- TODO
tasty_golden_byronTxBody :: UnitIO ()
tasty_golden_byronTxBody =
success -- TODO
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import RIO

import Test.Cardano.CLI.Util

import Hedgehog (Property, (===))
import Hedgehog ((===))
import Hedgehog.Extras (UnitIO)
import Hedgehog.Extras.Test.Base qualified as H

{- HLINT ignore "Use camelCase" -}

hprop_byron_update_proposal :: Property
hprop_byron_update_proposal =
watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_byron_update_proposal :: UnitIO ()
tasty_byron_update_proposal =
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"
Expand Down
15 changes: 8 additions & 7 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import Control.Monad (void)

import Test.Cardano.CLI.Util

import Hedgehog (Property, (===))
import Hedgehog ((===))
import Hedgehog.Extras (UnitIO)
import Hedgehog.Extras.Test.Base qualified as H
import Hedgehog.Internal.Property (failWith)

{- HLINT ignore "Use camelCase" -}

hprop_byron_yes_vote :: Property
hprop_byron_yes_vote =
watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_byron_yes_vote :: UnitIO ()
tasty_byron_yes_vote =
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"
Expand Down Expand Up @@ -50,9 +51,9 @@ hprop_byron_yes_vote =

expected === created

hprop_byron_no_vote :: Property
hprop_byron_no_vote =
watchdogProp . propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do
tasty_byron_no_vote :: UnitIO ()
tasty_byron_no_vote =
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"
Expand Down
Loading
Loading