-
Notifications
You must be signed in to change notification settings - Fork 730
/
Copy pathNonExtendedKey.hs
62 lines (49 loc) · 2.38 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
{-# LANGUAGE OverloadedStrings #-}
module Test.Golden.Key.NonExtendedKey
( golden_KeyNonExtendedKey_GenesisExtendedVerificationKey
, golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley
) where
import Control.Monad (void)
import Hedgehog (Property)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import System.FilePath ((</>))
import Test.OptParse (execCardanoCLI, propertyOnce)
import Test.Utilities (diffFileVsGoldenFile)
{- HLINT ignore "Use camelCase" -}
-- | Test that converting a @cardano-address@ Byron signing key yields the
-- expected result.
golden_KeyNonExtendedKey_GenesisExtendedVerificationKey :: Property
golden_KeyNonExtendedKey_GenesisExtendedVerificationKey =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
genesisVKeyFp <- H.note "test/data/golden/key/non-extended-keys/shelley.000.vkey"
nonExtendedFp <- H.note "test/data/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"
, "--extended-verification-key-file", genesisVKeyFp
, "--verification-key-file", outFp
]
-- Check for existence of the converted signing key file
H.assertFilesExist [outFp]
diffFileVsGoldenFile outFp nonExtendedFp
-- | Test that converting a @cardano-address@ Byron signing key yields the
-- expected result.
golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley :: Property
golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
genesisVKeyFp <- H.note "test/data/golden/key/non-extended-keys/stake.000.vkey"
nonExtendedFp <- H.note "test/data/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"
, "--extended-verification-key-file", genesisVKeyFp
, "--verification-key-file", outFp
]
-- Check for existence of the converted signing key file
H.assertFilesExist [outFp]
diffFileVsGoldenFile outFp nonExtendedFp