Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI golden tests for new cardano-address key conversion command
- Loading branch information
Showing
8 changed files
with
228 additions
and
0 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
190 changes: 190 additions & 0 deletions
190
cardano-cli/test/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.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,190 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Golden.Shelley.Key.ConvertCardanoAddressKey | ||
( golden_convertCardanoAddressByronSigningKey | ||
, golden_convertCardanoAddressIcarusSigningKey | ||
, golden_convertCardanoAddressShelleyPaymentSigningKey | ||
, golden_convertCardanoAddressShelleyStakeSigningKey | ||
) where | ||
|
||
import Cardano.Prelude hiding (readFile) | ||
|
||
import Hedgehog (Property, (===)) | ||
|
||
import Test.OptParse | ||
|
||
{- HLINT ignore "Reduce duplication" -} | ||
|
||
-- | An example signing key generated by @cardano-address@ using the | ||
-- deprecated Byron style. | ||
exampleByronSigningKey :: Text | ||
exampleByronSigningKey = | ||
"xprv1pp72a64en2vf568jywe9azlgrqe3p2jjf9gxxeejn2fex8g889x54w6emg2egkaz2rxyc" | ||
<> "560fp0hrv8y0hzpuzu27zhhhgwc8t5tvrczz2jnhhjwdnd6cdjx4dxehrsr2pr406rchw" | ||
<> "ctfwrgpc9r7nmakvaegyz9" | ||
|
||
-- | An example signing key generated by @cardano-address@ using the Icarus | ||
-- style. | ||
exampleIcarusSigningKey :: Text | ||
exampleIcarusSigningKey = | ||
"xprv1yq7c6nlmxncg7txy0z6lqf3fww4vm20m60lrxttx5lr4qmkvh395m3p59v8fn4ku9mzyc" | ||
<> "g2rkxatgwm86uc3pvrt06e43afya6rm0s2azlpnc9yrhygl2heckeyhhtgad08c0zljpn" | ||
<> "c6fse2ldzyx9c86yvddxjw" | ||
|
||
-- | An example signing key generated by @cardano-address@ using the Shelley | ||
-- style. | ||
exampleShelleySigningKey :: Text | ||
exampleShelleySigningKey = | ||
"xprv1yq7c6nlmxncg7txy0z6lqf3fww4vm20m60lrxttx5lr4qmkvh395m3p59v8fn4ku9mzyc" | ||
<> "g2rkxatgwm86uc3pvrt06e43afya6rm0s2azlpnc9yrhygl2heckeyhhtgad08c0zljpn" | ||
<> "c6fse2ldzyx9c86yvddxjw" | ||
|
||
-- | Test that converting a @cardano-address@ Byron signing key yields the | ||
-- expected result. | ||
golden_convertCardanoAddressByronSigningKey :: Property | ||
golden_convertCardanoAddressByronSigningKey = | ||
propertyOnce . moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
-- `cardano-address` signing key filepath | ||
signingKeyFp <- noteTempFile tempDir "cardano-address-byron.skey" | ||
|
||
-- Converted signing key filepath | ||
convertedSigningKeyFp <- | ||
noteTempFile tempDir "converted-cardano-address-byron.skey" | ||
|
||
-- Write `cardano-address` signing key to disk | ||
liftIO $ writeFile signingKeyFp exampleByronSigningKey | ||
assertFilesExist [signingKeyFp] | ||
|
||
-- Convert the `cardano-address` signing key | ||
void $ execCardanoCLI | ||
[ "shelley","key","convert-cardano-address-key" | ||
, "--byron-payment-key" | ||
, "--signing-key-file", signingKeyFp | ||
, "--out-file", convertedSigningKeyFp | ||
] | ||
|
||
-- Check for existence of the converted signing key file | ||
assertFilesExist [convertedSigningKeyFp] | ||
|
||
-- Check that the contents of the converted signing key file match that of | ||
-- the golden file. | ||
actualConvertedSigningKey <- readFile convertedSigningKeyFp | ||
expectedConvertedSigningKey <- | ||
readFile $ | ||
"test/data/golden/shelley/keys/converted_cardano-address_keys/" | ||
<> "byron_signing_key" | ||
expectedConvertedSigningKey === actualConvertedSigningKey | ||
|
||
-- | Test that converting a @cardano-address@ Icarus signing key yields the | ||
-- expected result. | ||
golden_convertCardanoAddressIcarusSigningKey :: Property | ||
golden_convertCardanoAddressIcarusSigningKey = | ||
propertyOnce . moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
-- `cardano-address` signing key filepath | ||
signingKeyFp <- noteTempFile tempDir "cardano-address-icarus.skey" | ||
|
||
-- Converted signing key filepath | ||
convertedSigningKeyFp <- | ||
noteTempFile tempDir "converted-cardano-address-icarus.skey" | ||
|
||
-- Write `cardano-address` signing key to disk | ||
liftIO $ writeFile signingKeyFp exampleIcarusSigningKey | ||
assertFilesExist [signingKeyFp] | ||
|
||
-- Convert the `cardano-address` signing key | ||
void $ execCardanoCLI | ||
[ "shelley","key","convert-cardano-address-key" | ||
, "--icarus-payment-key" | ||
, "--signing-key-file", signingKeyFp | ||
, "--out-file", convertedSigningKeyFp | ||
] | ||
|
||
-- Check for existence of the converted signing key file | ||
assertFilesExist [convertedSigningKeyFp] | ||
|
||
-- Check that the contents of the converted signing key file match that of | ||
-- the golden file. | ||
actualConvertedSigningKey <- readFile convertedSigningKeyFp | ||
expectedConvertedSigningKey <- | ||
readFile $ | ||
"test/data/golden/shelley/keys/converted_cardano-address_keys/" | ||
<> "icarus_signing_key" | ||
expectedConvertedSigningKey === actualConvertedSigningKey | ||
|
||
-- | Test that converting a @cardano-address@ Shelley payment signing key | ||
-- yields the expected result. | ||
golden_convertCardanoAddressShelleyPaymentSigningKey :: Property | ||
golden_convertCardanoAddressShelleyPaymentSigningKey = | ||
propertyOnce . moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
-- `cardano-address` signing key filepath | ||
signingKeyFp <- | ||
noteTempFile tempDir "cardano-address-shelley-payment.skey" | ||
|
||
-- Converted signing key filepath | ||
convertedSigningKeyFp <- | ||
noteTempFile tempDir "converted-cardano-address-shelley-payment.skey" | ||
|
||
-- Write `cardano-address` signing key to disk | ||
liftIO $ writeFile signingKeyFp exampleShelleySigningKey | ||
assertFilesExist [signingKeyFp] | ||
|
||
-- Convert the `cardano-address` signing key | ||
void $ execCardanoCLI | ||
[ "shelley","key","convert-cardano-address-key" | ||
, "--shelley-payment-key" | ||
, "--signing-key-file", signingKeyFp | ||
, "--out-file", convertedSigningKeyFp | ||
] | ||
|
||
-- Check for existence of the converted signing key file | ||
assertFilesExist [convertedSigningKeyFp] | ||
|
||
-- Check that the contents of the converted signing key file match that of | ||
-- the golden file. | ||
actualConvertedSigningKey <- readFile convertedSigningKeyFp | ||
expectedConvertedSigningKey <- | ||
readFile $ | ||
"test/data/golden/shelley/keys/converted_cardano-address_keys/" | ||
<> "shelley_payment_signing_key" | ||
expectedConvertedSigningKey === actualConvertedSigningKey | ||
|
||
-- | Test that converting a @cardano-address@ Shelley stake signing key yields | ||
-- the expected result. | ||
golden_convertCardanoAddressShelleyStakeSigningKey :: Property | ||
golden_convertCardanoAddressShelleyStakeSigningKey = | ||
propertyOnce . moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
-- `cardano-address` signing key filepath | ||
signingKeyFp <- | ||
noteTempFile tempDir "cardano-address-shelley-stake.skey" | ||
|
||
-- Converted signing key filepath | ||
convertedSigningKeyFp <- | ||
noteTempFile tempDir "converted-cardano-address-shelley-stake.skey" | ||
|
||
-- Write `cardano-address` signing key to disk | ||
liftIO $ writeFile signingKeyFp exampleShelleySigningKey | ||
assertFilesExist [signingKeyFp] | ||
|
||
-- Convert the `cardano-address` signing key | ||
void $ execCardanoCLI | ||
[ "shelley","key","convert-cardano-address-key" | ||
, "--shelley-stake-key" | ||
, "--signing-key-file", signingKeyFp | ||
, "--out-file", convertedSigningKeyFp | ||
] | ||
|
||
-- Check for existence of the converted signing key file | ||
assertFilesExist [convertedSigningKeyFp] | ||
|
||
-- Check that the contents of the converted signing key file match that of | ||
-- the golden file. | ||
actualConvertedSigningKey <- readFile convertedSigningKeyFp | ||
expectedConvertedSigningKey <- | ||
readFile $ | ||
"test/data/golden/shelley/keys/converted_cardano-address_keys/" | ||
<> "shelley_stake_signing_key" | ||
expectedConvertedSigningKey === actualConvertedSigningKey |
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
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/keys/converted_cardano-address_keys/byron_signing_key
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,5 @@ | ||
{ | ||
"type": "PaymentSigningKeyByron_ed25519_bip32", | ||
"description": "", | ||
"cborHex": "5880087caeeab99a989a68f223b25e8be8183310aa5249506367329a93931d07394d4abb59da15945ba250cc4c534f485f71b0e47dc41e0b8af0af7ba1d83ae8b60f975e5b024cda7923bacc4c25cca498b9e67380dfe588764b614d8e7a37656dfd0212a53bde4e6cdbac3646ab4d9b8e03504757e878bbb0b4b8680e0a3f4f7db3" | ||
} |
5 changes: 5 additions & 0 deletions
5
cardano-cli/test/data/golden/shelley/keys/converted_cardano-address_keys/icarus_signing_key
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,5 @@ | ||
{ | ||
"type": "PaymentSigningKeyByron_ed25519_bip32", | ||
"description": "", | ||
"cborHex": "5880203d8d4ffb34f08f2cc478b5f0262973aacda9fbd3fe332d66a7c7506eccbc4b4dc4342b0e99d6dc2ec44c2143b1bab43b67d73110b06b7eb358f524ee87b7c13ceae36bc0e1fbaacbcb259f9342c322459015ea351bc0f644d93de7d0099a735d17c33c1483b911f55f38b6497bad1d6bcf878bf20cf1a4c32afb44431707d1" | ||
} |
5 changes: 5 additions & 0 deletions
5
.../test/data/golden/shelley/keys/converted_cardano-address_keys/shelley_payment_signing_key
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,5 @@ | ||
{ | ||
"type": "PaymentExtendedSigningKeyShelley_ed25519_bip32", | ||
"description": "", | ||
"cborHex": "5880203d8d4ffb34f08f2cc478b5f0262973aacda9fbd3fe332d66a7c7506eccbc4b4dc4342b0e99d6dc2ec44c2143b1bab43b67d73110b06b7eb358f524ee87b7c13ceae36bc0e1fbaacbcb259f9342c322459015ea351bc0f644d93de7d0099a735d17c33c1483b911f55f38b6497bad1d6bcf878bf20cf1a4c32afb44431707d1" | ||
} |
5 changes: 5 additions & 0 deletions
5
...li/test/data/golden/shelley/keys/converted_cardano-address_keys/shelley_stake_signing_key
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,5 @@ | ||
{ | ||
"type": "StakeExtendedSigningKeyShelley_ed25519_bip32", | ||
"description": "", | ||
"cborHex": "5880203d8d4ffb34f08f2cc478b5f0262973aacda9fbd3fe332d66a7c7506eccbc4b4dc4342b0e99d6dc2ec44c2143b1bab43b67d73110b06b7eb358f524ee87b7c13ceae36bc0e1fbaacbcb259f9342c322459015ea351bc0f644d93de7d0099a735d17c33c1483b911f55f38b6497bad1d6bcf878bf20cf1a4c32afb44431707d1" | ||
} |