~zinigor/cardano-node/trunk

« back to all changes in this revision

Viewing changes to cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs

  • Committer: Igor Zinovyev
  • Date: 2021-08-13 19:12:27 UTC
  • Revision ID: zinigor@gmail.com-20210813191227-stlnsj3mc5ypwn0c
Tags: upstream-1.27.0
ImportĀ upstreamĀ versionĀ 1.27.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{-# LANGUAGE OverloadedStrings #-}
 
2
 
 
3
module Test.Golden.Shelley.TextEnvelope.Keys.ExtendedPaymentKeys
 
4
  ( golden_shelleyExtendedPaymentKeys
 
5
  ) where
 
6
 
 
7
import           Cardano.Api (AsType (..), HasTextEnvelope (..))
 
8
import           Cardano.Prelude
 
9
import           Hedgehog (Property)
 
10
import           Test.OptParse
 
11
 
 
12
import qualified Hedgehog.Extras.Test.Base as H
 
13
 
 
14
{- HLINT ignore "Use camelCase" -}
 
15
 
 
16
-- | 1. Generate a key pair
 
17
--   2. Check for the existence of the key pair
 
18
--   3. Check the TextEnvelope serialization format has not changed.
 
19
golden_shelleyExtendedPaymentKeys :: Property
 
20
golden_shelleyExtendedPaymentKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
 
21
  -- Reference keys
 
22
  referenceVerKey <- noteInputFile "test/data/golden/shelley/keys/extended_payment_keys/verification_key"
 
23
  referenceSignKey <- noteInputFile "test/data/golden/shelley/keys/extended_payment_keys/signing_key"
 
24
 
 
25
  -- Key filepaths
 
26
  verKey <- noteTempFile tempDir "extended-payment-verification-key-file"
 
27
  signKey <- noteTempFile tempDir "extended-payment-signing-key-file"
 
28
 
 
29
  -- Generate payment verification key
 
30
  void $ execCardanoCLI
 
31
    [ "address","key-gen"
 
32
    , "--extended-key"
 
33
    , "--verification-key-file", verKey
 
34
    , "--signing-key-file", signKey
 
35
    ]
 
36
 
 
37
  let signingKeyType = textEnvelopeType (AsSigningKey AsPaymentExtendedKey)
 
38
      verificationKeyType = textEnvelopeType (AsVerificationKey AsPaymentExtendedKey)
 
39
 
 
40
  -- Check the newly created files have not deviated from the
 
41
  -- golden files
 
42
  checkTextEnvelopeFormat verificationKeyType referenceVerKey verKey
 
43
  checkTextEnvelopeFormat signingKeyType referenceSignKey signKey