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

Test to assert mainnet configuration is valid #3236

Merged
merged 1 commit into from
Sep 25, 2021

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Sep 22, 2021

Ensures that configuration/cardano/mainnet-config.json is always valid.

@newhoggy
Copy link
Contributor Author

When the mainnet configuration has a bad hash, the test fails in the following way:

test/Spec.hs
  Spec
    Spec.Config.Mainnet: FAIL (0.32s)
        ✗ Spec.Config.Mainnet failed
          after 1 test.

             ┏━━ test/Spec/Config/Mainnet.hs ━━━
          42 ┃ hprop_configMainnet :: Property
          43 ┃ hprop_configMainnet = H.propertyOnce $ do
          44 ┃   projectBase <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase
             ┃   │ /Users/jky/wrk/iohk/cardano-node
          45 ┃   result <- H.evalIO $ runExceptT $ initialLedgerState $ projectBase </> "configuration/cardano/mainnet-config.json"
          46 ┃   case result of
          47 ┃     Right (env, ledgerState) -> True === True
          48 ┃     Left e -> H.failWithCustom GHC.callStack Nothing (T.unpack (renderInitialLedgerStateError e))

          Failed to read or parse a genesis file linked from the network config file: Failed reading Byron genesis file "/Users/jky/wrk/iohk/cardano-node/configuration/cardano/mainnet-byron-genesis.json": GenesisHashMismatch (GenesisHash {unGenesisHash = 5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb}) 5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940eb0

          This failure can be reproduced by running:
          > recheck (Size 0) (Seed 37402807113868204 7424638759470100821) Spec.Config.Mainnet

      Use '--hedgehog-replay "Size 0 Seed 37402807113868204 7424638759470100821"' to reproduce.

import qualified System.Directory as IO

hprop_configMainnet :: Property
hprop_configMainnet = H.propertyOnce $ do
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm...this test would probably be better placed in cardano-cli as we aren't starting a testnet to run it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the tests.

Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM! Just squash the commits before merging 👍

@newhoggy newhoggy force-pushed the test-to-assert-mainnet-configuration-is-valid branch from 4748b02 to 02851fb Compare September 24, 2021 13:07
@newhoggy newhoggy force-pushed the test-to-assert-mainnet-configuration-is-valid branch from 02851fb to b9f7ce6 Compare September 25, 2021 07:15
@newhoggy
Copy link
Contributor Author

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 25, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit ed7fdbf into master Sep 25, 2021
@iohk-bors iohk-bors bot deleted the test-to-assert-mainnet-configuration-is-valid branch September 25, 2021 09:42
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