Skip to content

Execute the cardano-cli at the process level - #1450

Merged
iohk-bors[bot] merged 3 commits into
masterfrom
execute-cardano-cli-as-process
Jul 14, 2020
Merged

iohk-bors[bot] merged 3 commits into
masterfrom
execute-cardano-cli-as-process

Conversation

@newhoggy

@newhoggy newhoggy commented Jul 14, 2020 •

Copy link
Copy Markdown
Contributor

New execCardanoCLI function which uses one of:

  • $CARDANO_CLI if it is defined
  • cabal exec -- cardano-cli otherwise

New workspace function which creates a temporary directory and cleans it up. The clean up is signalled by writing a done file.

The Genesis.Create test is modified to use execCardanoCLI and workspace.

New dependency on process library.

@Jimbo4350 Jimbo4350 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

maybeCardanoCli <- IO.lookupEnv "CARDANO_CLI"
case maybeCardanoCli of
Just cardanoCli -> IO.readProcess cardanoCli arguments ""
Nothing -> IO.readProcess "cabal" ("exec":"--":"cardano-cli":arguments) ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@newhoggy

Copy link
Copy Markdown
Contributor Author

Thanks!

@newhoggy

Copy link
Copy Markdown
Contributor Author

bors merge

@iohk-bors

iohk-bors Bot commented Jul 14, 2020

Copy link
Copy Markdown
Contributor

@iohk-bors
iohk-bors Bot merged commit c381854 into master Jul 14, 2020
@iohk-bors
iohk-bors Bot deleted the execute-cardano-cli-as-process branch July 14, 2020 10:13
iohk-bors Bot added a commit that referenced this pull request Jul 15, 2020
1453: Replace address shell tests with hedgehog tests r=newhoggy a=newhoggy

# Pre-requisite PRs

#1450

# New tests

* `Address.Create`
* `Address.KeyGen`

# New note functions
The new `noteEval` and `noteEvalM` functions can be used to annotate values that are evaluated or computed.  This provides a good user experience for inspecting failed tests for example in the following test the filenames are displayed after lines `22` and `28` whilst `stdout` is display after lines `30` and `39`

```  
       ┏━━ test/Test/CLI/Shelley/Golden/Address/Build.hs ━━━
    16 ┃ golden_shelleyAddressBuild :: Property
    17 ┃ golden_shelleyAddressBuild = OP.propertyOnce $ OP.workspace "tmp/address-key-gen" $ \tempDir -> do
    18 ┃   addressVKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.vkey") "{\
    19 ┃     \    \"type\": \"PaymentVerificationKeyShelley\",\
    20 ┃     \    \"description\": \"Payment Verification Key\",\
    21 ┃     \    \"cborHex\": \"58208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea423427\"\
    22 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.vkey"
    23 ┃   addressSKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.skey") "\
    24 ┃     \{\
    25 ┃     \    \"type\": \"StakingVerificationKeyShelley\",\
    26 ┃     \    \"description\": \"Stake Verification Key\",\
    27 ┃     \    \"cborHex\": \"5820bd07998bca8de945482d950a3051f0e4d18afedecbc08d4c99c23f1804f3c8e5\"\
    28 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.skey"
    29 ┃ 
    30 ┃   stackingAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    31 ┃     [ "shelley","address","build"
    32 ┃     , "--testnet-magic", "14"
    33 ┃     , "--payment-verification-key-file", addressVKeyFile
    34 ┃     , "--staking-verification-key-file", addressSKeyFile
    35 ┃     ]
    36 ┃ 
    37 ┃   length (L.lines stackingAddressText) === 1
    38 ┃ 
    39 ┃   enterpriseAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    40 ┃     [ "shelley","address","build"
    41 ┃     , "--testnet-magic", "14"
    42 ┃     , "--payment-verification-key-file", addressVKeyFile
    43 ┃     , "--staking-verification-key-file", addressSKeyFile
    44 ┃     ]
    45 ┃ 
    46 ┃   length (L.lines enterpriseAddressText) === 1
    47 ┃ 
    48 ┃   True === False
       ┃   ^^^^^^^^^^^^^^
       ┃   │ ━━━ Failed (- lhs) (+ rhs) ━━━
       ┃   │ - True
       ┃   │ + False
```

Co-authored-by: John Ky <[email protected]>
newhoggy added a commit to IntersectMBO/cardano-api that referenced this pull request May 23, 2023
1453: Replace address shell tests with hedgehog tests r=newhoggy a=newhoggy

# Pre-requisite PRs

IntersectMBO/cardano-node#1450

# New tests

* `Address.Create`
* `Address.KeyGen`

# New note functions
The new `noteEval` and `noteEvalM` functions can be used to annotate values that are evaluated or computed.  This provides a good user experience for inspecting failed tests for example in the following test the filenames are displayed after lines `22` and `28` whilst `stdout` is display after lines `30` and `39`

```  
       ┏━━ test/Test/CLI/Shelley/Golden/Address/Build.hs ━━━
    16 ┃ golden_shelleyAddressBuild :: Property
    17 ┃ golden_shelleyAddressBuild = OP.propertyOnce $ OP.workspace "tmp/address-key-gen" $ \tempDir -> do
    18 ┃   addressVKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.vkey") "{\
    19 ┃     \    \"type\": \"PaymentVerificationKeyShelley\",\
    20 ┃     \    \"description\": \"Payment Verification Key\",\
    21 ┃     \    \"cborHex\": \"58208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea423427\"\
    22 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.vkey"
    23 ┃   addressSKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.skey") "\
    24 ┃     \{\
    25 ┃     \    \"type\": \"StakingVerificationKeyShelley\",\
    26 ┃     \    \"description\": \"Stake Verification Key\",\
    27 ┃     \    \"cborHex\": \"5820bd07998bca8de945482d950a3051f0e4d18afedecbc08d4c99c23f1804f3c8e5\"\
    28 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.skey"
    29 ┃ 
    30 ┃   stackingAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    31 ┃     [ "shelley","address","build"
    32 ┃     , "--testnet-magic", "14"
    33 ┃     , "--payment-verification-key-file", addressVKeyFile
    34 ┃     , "--staking-verification-key-file", addressSKeyFile
    35 ┃     ]
    36 ┃ 
    37 ┃   length (L.lines stackingAddressText) === 1
    38 ┃ 
    39 ┃   enterpriseAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    40 ┃     [ "shelley","address","build"
    41 ┃     , "--testnet-magic", "14"
    42 ┃     , "--payment-verification-key-file", addressVKeyFile
    43 ┃     , "--staking-verification-key-file", addressSKeyFile
    44 ┃     ]
    45 ┃ 
    46 ┃   length (L.lines enterpriseAddressText) === 1
    47 ┃ 
    48 ┃   True === False
       ┃   ^^^^^^^^^^^^^^
       ┃   │ ━━━ Failed (- lhs) (+ rhs) ━━━
       ┃   │ - True
       ┃   │ + False
```

Co-authored-by: John Ky <[email protected]>
newhoggy added a commit to IntersectMBO/cardano-cli that referenced this pull request May 24, 2023
1453: Replace address shell tests with hedgehog tests r=newhoggy a=newhoggy

# Pre-requisite PRs

IntersectMBO/cardano-node#1450

# New tests

* `Address.Create`
* `Address.KeyGen`

# New note functions
The new `noteEval` and `noteEvalM` functions can be used to annotate values that are evaluated or computed.  This provides a good user experience for inspecting failed tests for example in the following test the filenames are displayed after lines `22` and `28` whilst `stdout` is display after lines `30` and `39`

```  
       ┏━━ test/Test/CLI/Shelley/Golden/Address/Build.hs ━━━
    16 ┃ golden_shelleyAddressBuild :: Property
    17 ┃ golden_shelleyAddressBuild = OP.propertyOnce $ OP.workspace "tmp/address-key-gen" $ \tempDir -> do
    18 ┃   addressVKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.vkey") "{\
    19 ┃     \    \"type\": \"PaymentVerificationKeyShelley\",\
    20 ┃     \    \"description\": \"Payment Verification Key\",\
    21 ┃     \    \"cborHex\": \"58208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea423427\"\
    22 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.vkey"
    23 ┃   addressSKeyFile <- OP.noteEvalM $ OP.newFileWithContents (tempDir <> "/address.skey") "\
    24 ┃     \{\
    25 ┃     \    \"type\": \"StakingVerificationKeyShelley\",\
    26 ┃     \    \"description\": \"Stake Verification Key\",\
    27 ┃     \    \"cborHex\": \"5820bd07998bca8de945482d950a3051f0e4d18afedecbc08d4c99c23f1804f3c8e5\"\
    28 ┃     \}"
       ┃     │ "tmp/address-key-gen/test-9f98f97fdf26709f/address.skey"
    29 ┃ 
    30 ┃   stackingAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    31 ┃     [ "shelley","address","build"
    32 ┃     , "--testnet-magic", "14"
    33 ┃     , "--payment-verification-key-file", addressVKeyFile
    34 ┃     , "--staking-verification-key-file", addressSKeyFile
    35 ┃     ]
    36 ┃ 
    37 ┃   length (L.lines stackingAddressText) === 1
    38 ┃ 
    39 ┃   enterpriseAddressText <- OP.noteEvalM . liftIO $ OP.execCardanoCLI
       ┃   │ "addr_test1qpfqwx0t6v5d80f6gqaznkk676vph0wmt68lfera8am87f5pksj9lpze8a3uplezj6fsy48h0grfp75auhuknjkz0jcqqnm3zv\n"
    40 ┃     [ "shelley","address","build"
    41 ┃     , "--testnet-magic", "14"
    42 ┃     , "--payment-verification-key-file", addressVKeyFile
    43 ┃     , "--staking-verification-key-file", addressSKeyFile
    44 ┃     ]
    45 ┃ 
    46 ┃   length (L.lines enterpriseAddressText) === 1
    47 ┃ 
    48 ┃   True === False
       ┃   ^^^^^^^^^^^^^^
       ┃   │ ━━━ Failed (- lhs) (+ rhs) ━━━
       ┃   │ - True
       ┃   │ + False
```

Co-authored-by: John Ky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants