-
Notifications
You must be signed in to change notification settings - Fork 13
/
NonExtendedKey.hs
106 lines (86 loc) · 4.71 KB
/
NonExtendedKey.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{-# LANGUAGE OverloadedStrings #-}
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
import Test.Cardano.CLI.Util (execCardanoCLI, propertyOnce)
import Hedgehog (Property)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Golden as H
{- HLINT ignore "Use camelCase" -}
-- | Test that converting a @cardano-address@ Byron signing key yields the
-- expected result.
hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey :: Property
hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
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"
-- Convert the `cardano-address` signing key
void $ execCardanoCLI
[ "key", "non-extended-key"
, "--extended-verification-key-file", genesisVKeyFp
, "--verification-key-file", outFp
]
H.diffFileVsGoldenFile outFp nonExtendedFp
-- | Test that converting a @cardano-address@ Byron signing key yields the
-- expected result.
hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley :: Property
hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
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"
-- Convert the `cardano-address` signing key
void $ execCardanoCLI
[ "key", "non-extended-key"
, "--extended-verification-key-file", genesisVKeyFp
, "--verification-key-file", outFp
]
H.diffFileVsGoldenFile outFp nonExtendedFp
-- | Test that converting a drep extended verification key yields the
-- expected result.
hprop_golden_KeyNonExtendedKey_DRepExtendedVerificationKey :: Property
hprop_golden_KeyNonExtendedKey_DRepExtendedVerificationKey =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
extendedKeyFile <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/extended-drep.vkey"
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"
void $ execCardanoCLI
[ "conway", "key", "non-extended-key"
, "--extended-verification-key-file", extendedKeyFile
, "--verification-key-file", outFp
]
H.diffFileVsGoldenFile outFp goldenFile
-- | Test that converting a payment extended verification key yields the
-- expected result.
hprop_golden_extended_payment_vkey_to_non_extended_vkey :: Property
hprop_golden_extended_payment_vkey_to_non_extended_vkey =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
extendedKeyFile <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/extended-payment.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"
void $ execCardanoCLI
[ "conway", "key", "non-extended-key"
, "--extended-verification-key-file", extendedKeyFile
, "--verification-key-file", outFp
]
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