~zinigor/cardano-node/trunk

« back to all changes in this revision

Viewing changes to cardano-cli/test/Test/Cli/Pioneers/Exercise2.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.Cli.Pioneers.Exercise2
 
4
  ( tests
 
5
  ) where
 
6
 
 
7
import           Cardano.Prelude
 
8
import           Hedgehog (Property)
 
9
import           Test.OptParse
 
10
 
 
11
import qualified Hedgehog as H
 
12
import qualified Hedgehog.Extras.Test.Base as H
 
13
import qualified Hedgehog.Extras.Test.File as H
 
14
 
 
15
-- | 1. We generate a payment signing key
 
16
--   2. We create a tx body
 
17
--   3. We sign the tx body with the generated payment signing key
 
18
prop_createTransaction :: Property
 
19
prop_createTransaction = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
 
20
  -- Key filepaths
 
21
  paymentVerKey <- noteTempFile tempDir "payment-verification-key-file"
 
22
  paymentSignKey <- noteTempFile tempDir "payment-signing-key-file"
 
23
  transactionBodyFile <- noteTempFile tempDir "transaction-body"
 
24
  transactionFile <- noteTempFile tempDir "transaction-file"
 
25
 
 
26
  -- Generate payment signing key to sign transaction
 
27
  void $ execCardanoCLI
 
28
    [ "address","key-gen"
 
29
    , "--verification-key-file", paymentVerKey
 
30
    , "--signing-key-file", paymentSignKey
 
31
    ]
 
32
 
 
33
  H.assertFilesExist [paymentVerKey, paymentSignKey]
 
34
 
 
35
  -- Create transaction body
 
36
  void $ execCardanoCLI
 
37
    [ "transaction", "build-raw"
 
38
    , "--tx-in", "91999ea21177b33ebe6b8690724a0c026d410a11ad7521caa350abdafa5394c3#0"
 
39
    , "--auxiliary-script-file", "test/data/golden/shelley/multisig/scripts/all"
 
40
    , "--tx-in", "91999ea21177b33ebe6b8690724a0c026d410a11ad7521caa350abdafa5394c3#0"
 
41
    , "--auxiliary-script-file", "test/data/golden/shelley/multisig/scripts/all"
 
42
    , "--tx-out", "addr1v9wmu83pzajplrtpsq6tsqdgwr98x888trpmah2u0ezznsge7del3+100000000"
 
43
    , "--fee", "1000000"
 
44
    , "--invalid-hereafter", "500000"
 
45
    , "--out-file", transactionBodyFile
 
46
    ]
 
47
 
 
48
  H.assertFilesExist [transactionBodyFile]
 
49
 
 
50
  -- Sign transaction
 
51
  void $ execCardanoCLI
 
52
    [ "transaction", "sign"
 
53
    , "--tx-body-file", transactionBodyFile
 
54
    , "--signing-key-file", paymentSignKey
 
55
    , "--mainnet"
 
56
    , "--out-file", transactionFile
 
57
    ]
 
58
 
 
59
  H.assertFilesExist [paymentVerKey, paymentSignKey, transactionBodyFile, transactionFile]
 
60
 
 
61
-- -----------------------------------------------------------------------------
 
62
 
 
63
tests :: IO Bool
 
64
tests =
 
65
  H.checkSequential
 
66
    $ H.Group "Pioneers Example 2"
 
67
        [ ("prop_createTransaction", prop_createTransaction)
 
68
        ]