Skip to content

Commit 2590e48

Browse files
Merge #4894
4894: Re-add support for decoding GenesisExtendedKey text envelope r=newhoggy a=newhoggy Resolves #4893 Co-authored-by: John Ky <[email protected]>
2 parents 6a42069 + aa7a30c commit 2590e48

File tree

6 files changed

+65
-0
lines changed

6 files changed

+65
-0
lines changed

cardano-api/src/Cardano/Api/DeserialiseAnyOf.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,6 @@ deserialiseAnyVerificationKeyTextEnvelope bs =
311311
, FromSomeType (AsVerificationKey AsPaymentKey) APaymentVerificationKey
312312
, FromSomeType (AsVerificationKey AsPaymentExtendedKey) APaymentExtendedVerificationKey
313313
, FromSomeType (AsVerificationKey AsGenesisUTxOKey) AGenesisUTxOVerificationKey
314+
, FromSomeType (AsVerificationKey AsGenesisExtendedKey) AGenesisExtendedVerificationKey
314315
]
315316

cardano-cli/cardano-cli.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ test-suite cardano-cli-golden
241241
Test.Golden.Byron.UpdateProposal
242242
Test.Golden.Byron.Vote
243243
Test.Golden.Byron.Witness
244+
Test.Golden.Key
245+
Test.Golden.Key.NonExtendedKey
244246
Test.Golden.Shelley
245247
Test.Golden.Shelley.Address.Build
246248
Test.Golden.Shelley.Address.Info

cardano-cli/test/Test/Golden/Key.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
module Test.Golden.Key
4+
( keyTests
5+
) where
6+
7+
import qualified Test.Golden.Key.NonExtendedKey
8+
9+
import qualified Hedgehog as H
10+
11+
keyTests :: IO Bool
12+
keyTests =
13+
H.checkSequential
14+
$ H.Group "Key command group"
15+
[ ("golden_KeyNonExtendedKey", Test.Golden.Key.NonExtendedKey.golden_KeyNonExtendedKey)
16+
]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
module Test.Golden.Key.NonExtendedKey
4+
( golden_KeyNonExtendedKey
5+
) where
6+
7+
import Control.Monad (void)
8+
import Hedgehog (Property)
9+
import qualified Hedgehog.Extras.Test.Base as H
10+
import qualified Hedgehog.Extras.Test.File as H
11+
import System.FilePath ((</>))
12+
import Test.OptParse (execCardanoCLI, propertyOnce)
13+
import Test.Utilities (diffVsGoldenFile)
14+
15+
{- HLINT ignore "Use camelCase" -}
16+
17+
-- | Test that converting a @cardano-address@ Byron signing key yields the
18+
-- expected result.
19+
golden_KeyNonExtendedKey :: Property
20+
golden_KeyNonExtendedKey =
21+
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
22+
genesisVKeyFp <- H.note "test/data/golden/key/non-extended-keys/shelley.000.vkey"
23+
nonExtendedGenesisVKeyFp <- H.note $ tempDir </> "non-extended-shelley.000.vkey"
24+
25+
H.assertFilesExist [genesisVKeyFp]
26+
27+
-- Convert the `cardano-address` signing key
28+
void $ execCardanoCLI
29+
[ "key", "non-extended-key"
30+
, "--extended-verification-key-file", genesisVKeyFp
31+
, "--verification-key-file", nonExtendedGenesisVKeyFp
32+
]
33+
34+
-- Check for existence of the converted signing key file
35+
H.assertFilesExist [nonExtendedGenesisVKeyFp]
36+
37+
contents <- H.readFile nonExtendedGenesisVKeyFp
38+
39+
diffVsGoldenFile contents nonExtendedGenesisVKeyFp

cardano-cli/test/cardano-cli-golden.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import qualified Test.Golden.Byron.SigningKeys
44
import qualified Test.Golden.Byron.Tx
55
import qualified Test.Golden.Byron.UpdateProposal
66
import qualified Test.Golden.Byron.Vote
7+
import qualified Test.Golden.Key
78
import qualified Test.Golden.Shelley
89
import qualified Test.Golden.TxView
910

@@ -14,6 +15,7 @@ main =
1415
, Test.Golden.Byron.Tx.txTests
1516
, Test.Golden.Byron.UpdateProposal.updateProposalTest
1617
, Test.Golden.Byron.Vote.voteTests
18+
, Test.Golden.Key.keyTests
1719
, Test.Golden.Shelley.keyTests
1820
, Test.Golden.Shelley.certificateTests
1921
, Test.Golden.Shelley.keyConversionTests
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "GenesisExtendedVerificationKey_ed25519_bip32",
3+
"description": "",
4+
"cborHex": "58400834b58f4bdda9522bb202af1f546db4cbbd94b068ae72c9fd96d9b55279edf0f97694cea85a4926ffeacab704b4a7de037c7f6d078135442a52fe45e39bcace"
5+
}

0 commit comments

Comments
 (0)