diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 4f66429114..154aa3e74d 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -129,6 +129,11 @@ jobs: - name: Build all run: cabal build all --enable-tests + # This step is temporary. We'll soon remove it and check instead + # that golden files have not been modified when creating them below. + - name: Test all + run: cabal test all --enable-tests --test-show-details=direct -j1 + - # Delete golden files and regenerate them in the next step to ensure # files that tests designate as golden files are actually golden files # and can be generated. diff --git a/cabal.project b/cabal.project index 496784ccf6..d24d470001 100644 --- a/cabal.project +++ b/cabal.project @@ -13,8 +13,8 @@ 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 2024-03-24T23:16:24Z - , cardano-haskell-packages 2024-04-04T15:00:00Z + , hackage.haskell.org 2024-04-15T08:36:34Z + , cardano-haskell-packages 2024-04-15T08:36:34Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 2bdc9d2213..6bbe24b5e6 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -196,7 +196,7 @@ library , binary , bytestring , canonical-json - , cardano-api ^>= 8.44.0.0 + , cardano-api ^>= 8.45.0.0 , cardano-binary , cardano-crypto , cardano-crypto-class ^>= 2.1.2 diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs index 04f95b00ad..cd7f8cac88 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs @@ -163,6 +163,10 @@ runNonExtendedKeyCmd writeToDisk vkf (Just paymentVkeyDesc) (castVerificationKey vk :: VerificationKey PaymentKey) ADRepExtendedVerificationKey vk -> writeToDisk vkf (Just drepVkeyDesc) (castVerificationKey vk :: VerificationKey DRepKey) + ACommitteeColdExtendedVerificationKey vk -> + writeToDisk vkf (Just ccColdVkeyDesc) (castVerificationKey vk :: VerificationKey CommitteeColdKey) + ACommitteeHotExtendedVerificationKey vk -> + writeToDisk vkf (Just ccHotVkeyDesc) (castVerificationKey vk :: VerificationKey CommitteeHotKey) AStakeExtendedVerificationKey vk -> writeToDisk vkf (Just stakeVkeyDesc) (castVerificationKey vk :: VerificationKey StakeKey) AGenesisExtendedVerificationKey vk -> @@ -177,6 +181,8 @@ runNonExtendedKeyCmd vk@AVrfVerificationKey {} -> goFail vk vk@AStakeVerificationKey {} -> goFail vk vk@ADRepVerificationKey {} -> goFail vk + vk@ACommitteeColdVerificationKey{} -> goFail vk + vk@ACommitteeHotVerificationKey{} -> goFail vk where goFail nonExtendedKey = left $ KeyCmdExpectedExtendedVerificationKey nonExtendedKey @@ -202,6 +208,8 @@ readExtendedVerificationKeyFile evkfile = do case vKey of k@APaymentExtendedVerificationKey{} -> return k k@ADRepExtendedVerificationKey{} -> return k + k@ACommitteeColdExtendedVerificationKey{} -> return k + k@ACommitteeHotExtendedVerificationKey{} -> return k k@AStakeExtendedVerificationKey{} -> return k k@AGenesisExtendedVerificationKey{} -> return k k@AGenesisDelegateExtendedVerificationKey{} -> return k @@ -213,6 +221,8 @@ readExtendedVerificationKeyFile evkfile = do k@AVrfVerificationKey{} -> goFail k k@AStakeVerificationKey{} -> goFail k k@ADRepVerificationKey{} -> goFail k + k@ACommitteeColdVerificationKey{} -> goFail k + k@ACommitteeHotVerificationKey{} -> goFail k where goFail k = left $ KeyCmdExpectedExtendedVerificationKey k diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs index 2c899ba33e..cf1b255e27 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs @@ -3,6 +3,7 @@ module Test.Golden.Key.NonExtendedKey where import Control.Monad (void) +import Control.Monad.Extra (forM_) import System.FilePath (()) import qualified Test.Cardano.CLI.Util as H @@ -10,7 +11,6 @@ import Test.Cardano.CLI.Util (execCardanoCLI, propertyOnce) 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" -} @@ -24,8 +24,6 @@ hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey = 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" - H.assertFilesExist [genesisVKeyFp] - -- Convert the `cardano-address` signing key void $ execCardanoCLI [ "key", "non-extended-key" @@ -44,8 +42,6 @@ hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley = 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" - H.assertFilesExist [genesisVKeyFp] - -- Convert the `cardano-address` signing key void $ execCardanoCLI [ "key", "non-extended-key" @@ -64,8 +60,6 @@ hprop_golden_KeyNonExtendedKey_DRepExtendedVerificationKey = goldenFile <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-drep.vkey" outFp <- H.note $ tempDir "non-extended-drep.vkey" - H.assertFilesExist [extendedKeyFile] - void $ execCardanoCLI [ "conway", "key", "non-extended-key" , "--extended-verification-key-file", extendedKeyFile @@ -83,8 +77,6 @@ hprop_golden_extended_payment_vkey_to_non_extended_vkey = goldenFile <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-payment.vkey" outFp <- H.note $ tempDir "non-extended-payment.vkey" - H.assertFilesExist [extendedKeyFile] - void $ execCardanoCLI [ "conway", "key", "non-extended-key" , "--extended-verification-key-file", extendedKeyFile @@ -92,3 +84,23 @@ hprop_golden_extended_payment_vkey_to_non_extended_vkey = ] H.diffFileVsGoldenFile outFp goldenFile + +-- | Test that converting a CC extended verification key yields the expected result. +-- | Execute me with: +-- @cabal test cardano-cli-golden --test-options '-p "/golden extended cc vkey to non extended vkey/"'@ +hprop_golden_extended_cc_vkey_to_non_extended_vkey :: Property +hprop_golden_extended_cc_vkey_to_non_extended_vkey = + let supplyValues = [ "cc-cold.vkey", "cc-hot.vkey" ] in + propertyOnce $ forM_ supplyValues $ \suffix-> + H.moduleWorkspace "tmp" $ \tempDir -> do + extendedKeyFile <- H.noteInputFile $ "test/cardano-cli-golden/files/input/key/non-extended-keys/extended-" <> suffix + goldenFile <- H.note $ "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-" <> suffix + outFp <- H.note $ tempDir "non-extended-" <> suffix + + void $ execCardanoCLI + [ "conway", "key", "non-extended-key" + , "--extended-verification-key-file", extendedKeyFile + , "--verification-key-file", outFp + ] + + H.diffFileVsGoldenFile outFp goldenFile diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out index 6f2fec15cc..63cb905c45 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out +++ b/cardano-cli/test/cardano-cli-golden/files/golden/babbage/transaction-view-metadata-noschema.out @@ -7,47 +7,47 @@ inputs: - ed7c8f68c194cc763ee65ad22ef0973e26481be058c65005fd39fb93f9c43a20#213 metadata: '0': - - - '"\DLE@A"' - - '"C"' - - - '"\NAK@A"' - - '"D"' - - - '"0A"' - - '"E"' - - - '"A"' - - '"B"' - - 1 - 2 - - 11 - 3 + - - '"A"' + - '"B"' - - a - b + - - '"0A"' + - '"E"' - - aa - bb - - - aab - - ba - - ab - ba + - - '"\DLE@A"' + - '"C"' + - - '"\NAK@A"' + - '"D"' + - - aab + - ba - - aba - - - - '"\DLE@A"' - - '"C"' - - - '"\NAK@A"' - - '"D"' - - - '"0A"' - - '"E"' - - - '"A"' - - '"B"' - - - 1 + - - - 1 - 2 - - 11 - 3 + - - '"A"' + - '"B"' - - a - b + - - '"0A"' + - '"E"' - - aa - bb - - - aab - - ba - - ab - ba + - - '"\DLE@A"' + - '"C"' + - - '"\NAK@A"' + - '"D"' + - - aab + - ba - - abb - ba - - abb diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-cold.vkey b/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-cold.vkey new file mode 100644 index 0000000000..40afd9ae84 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-cold.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdVerificationKey_ed25519", + "description": "Constitutional Committee Cold Verification Key", + "cborHex": "58200a9d35aa5299580a67b1e43a3a4b6d43ef29c94e56c51ce4c17e9a53c1d0f39a" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-hot.vkey b/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-hot.vkey new file mode 100644 index 0000000000..fa9ebcb5d0 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-cc-hot.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeHotVerificationKey_ed25519", + "description": "Constitutional Committee Hot Verification Key", + "cborHex": "5820f010c4332699c6ea1e43b427919860277169382d43d2969b28a110cfa08d955c" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-cold.vkey b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-cold.vkey new file mode 100644 index 0000000000..c2a21b6a0d --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-cold.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdExtendedVerificationKey_ed25519_bip32", + "description": "", + "cborHex": "58400a9d35aa5299580a67b1e43a3a4b6d43ef29c94e56c51ce4c17e9a53c1d0f39aa7f68837c38ef680b2dc8f047581707a32f6fcade23d4e02177d389002484798" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-hot.vkey b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-hot.vkey new file mode 100644 index 0000000000..9cb85beea6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/extended-cc-hot.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeHotExtendedVerificationKey_ed25519_bip32", + "description": "", + "cborHex": "5840f010c4332699c6ea1e43b427919860277169382d43d2969b28a110cfa08d955c4f178f20955541ce918a6a1352c32536f22677008f9f918d109663e4d2bdc084" +} diff --git a/flake.lock b/flake.lock index 8ade406b7c..4bac217e1d 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1712241301, - "narHash": "sha256-Np3AKeg8JuT53MaoA9HAP3Rk+mzFJR05LbmamXtpeXM=", + "lastModified": 1713175844, + "narHash": "sha256-8Xz0kMPvgHp1rsv9FHwEl2N40DzPQv22qk+aUW361mM=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "91e98f31ae16e5a5833224c8ac46532fb72964a4", + "rev": "e00be463a34798f98c5d18e1d7cc0b8137547005", "type": "github" }, "original": { @@ -210,11 +210,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1711326208, - "narHash": "sha256-1yKfIKSwjo38ZiMoX0nxQ3xu5gROd2qk79vqYrSn7zI=", + "lastModified": 1713148874, + "narHash": "sha256-qJs+4QNxxB9aD+CsByOZR2aheGDb3xNRukw7D9TqSj4=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "50beb0a0ad21b5aa68a444482fbab71135525be6", + "rev": "9586d6737b7bf7480df9bd3e3e710fb530b4da9e", "type": "github" }, "original": {