Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cardano-testnet: call the CLI check-node-configuration to catch configuration errors #6096

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Jan 30, 2025

Description

Call the CLI's "new" check-node-configuration command in cardano-testnet setup.

This both serves as a test of check-node-configuration and will also help catch configuration errors earlier (and with a nice error message). The latter is particularly important as we will soon release cardano-testnet and let users supply genesis files (see roadmap and issue about supplying genesis files).

Fixes #6028

How to trust this PR

The tests still pass, so the cal is successful

Try to break the genesis files, for example apply this patch:

--- a/cardano-testnet/src/Testnet/Components/Configuration.hs
+++ b/cardano-testnet/src/Testnet/Components/Configuration.hs
@@ -75,8 +75,8 @@ createConfigJson :: ()
 createConfigJson (TmpAbsolutePath tempAbsPath) sbe = GHC.withFrozenCallStack $ do
   byronGenesisHash <- getByronGenesisHash $ tempAbsPath </> "byron-genesis.json"
   shelleyGenesisHash <- getHash ShelleyEra "ShelleyGenesisHash"
-  alonzoGenesisHash  <- getHash AlonzoEra  "AlonzoGenesisHash"
-  conwayGenesisHash  <- getHash ConwayEra  "ConwayGenesisHash"
+  alonzoGenesisHash  <- getHash ConwayEra  "AlonzoGenesisHash"
+  conwayGenesisHash  <- getHash AlonzoEra  "ConwayGenesisHash"

Run cardano-testnet's tests:

cabal test cardano-testnet-test

And observe that, as expected, the tests fail with the expected error:

              ┃     │ ━━━━ command ━━━━
              ┃     │ /home/churlin/.local/state/cabal/store/ghc-8.10.7/cardano-cli-10.3.0.0-e-cardano-cli-0a5a7130af59b84c2d65c8b4b8cad9fc373753786ec928a2dc0d3f04d5276bf8/bin/cardano-cli debug check-node-configuration --node-configuration-file /tmp/nix-shell.hc4ID6/submit-api-transaction-2-test-63f5646fc9235289/configuration.yaml
              ┃     │ Process exited with non-zero exit-code: 1
              ┃     │ ━━━━ stdout ━━━━
              ┃     │ Checking byron genesis file: /tmp/nix-shell.hc4ID6/submit-api-transaction-2-test-63f5646fc9235289/byron-genesis.json
              ┃     │ 
              ┃     │ ━━━━ stderr ━━━━
              ┃     │ Wrong genesis hash for /tmp/nix-shell.hc4ID6/submit-api-transaction-2-test-63f5646fc9235289/alonzo-genesis.json in /tmp/nix-shell.hc4ID6/submit-api-transaction-2-test-63f5646fc9235289/configuration.yaml: when computing the hash, got: a4844d02149b2c12da7195fdcb82fefc13641d8e78fe5d964d054bf48dee0f1a, but the node configuration files states that this hash is expected: 33aacea1c55c0cab6c9906f2e435cb47ede3eda3f9b7f5d4eaf4ec616e890596

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
  • Self-reviewed the diff

…guration errors

This also happens to be a test of check-node-configuration :-)
@smelc smelc marked this pull request as ready for review January 30, 2025 15:31
@smelc smelc requested a review from a team as a code owner January 30, 2025 15:31
Copy link
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

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

Nice! I was going to ask about writing H.note around, the execCli, but I am guessing from your comment it already shows the output if it fails

@smelc smelc enabled auto-merge January 30, 2025 15:52
@smelc smelc added this pull request to the merge queue Jan 30, 2025
Merged via the queue into master with commit ca38b9d Jan 30, 2025
22 of 26 checks passed
@smelc smelc deleted the smelc/testnet-call-cli-check-node-configuration branch January 30, 2025 17:16
Icelandjack pushed a commit that referenced this pull request Feb 5, 2025
…ck-node-configuration

cardano-testnet: call the CLI check-node-configuration to catch configuration errors
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.

cardano-testnet: use cardano-cli's check-node-configuration command
3 participants