/
MIRCertificate.hs
58 lines (44 loc) · 1.94 KB
/
MIRCertificate.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
{-# LANGUAGE OverloadedStrings #-}
module Test.CLI.Shelley.TextEnvelope.Golden.Certificates.MIRCertificate
( golden_shelleyMIRCertificate
) where
import Cardano.Prelude
import Cardano.Api.Typed (AsType(..), HasTextEnvelope (..))
import Hedgehog (Property)
import qualified Hedgehog as H
import Test.OptParse
-- | 1. Generate stake key pair
-- 2. Create MIR certificate
-- s. Check the TextEnvelope serialization format has not changed.
golden_shelleyMIRCertificate :: Property
golden_shelleyMIRCertificate =
propertyOnce $ do
-- Reference keys
let referenceMIRCertificate = "test/Test/golden/shelley/certificates/mir_certificate"
-- Key filepaths
let verKey = "stake-verification-key-file"
signKey = "stake-signing-key-file"
mirCertificate = "mir-certificate-file"
createdFiles = [verKey, signKey, mirCertificate]
-- Generate stake key pair
execCardanoCLIParser
createdFiles
$ evalCardanoCLIParser [ "shelley","stake-address","key-gen"
, "--verification-key-file", verKey
, "--signing-key-file", signKey
]
assertFilesExist [verKey, signKey]
-- Create MIR certificate
execCardanoCLIParser
createdFiles
$ evalCardanoCLIParser [ "shelley","governance","create-mir-certificate"
, "--reserves" --TODO: Should also do "--reserves"
, "--stake-verification-key-file", verKey
, "--reward", "1000"
, "--out-file", mirCertificate
]
assertFilesExist [mirCertificate]
let registrationCertificateType = textEnvelopeType AsCertificate
checkTextEnvelopeFormat createdFiles registrationCertificateType referenceMIRCertificate mirCertificate
liftIO $ fileCleanup createdFiles
H.success