Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3236: Test to assert mainnet configuration is valid r=newhoggy a=newhoggy Ensures that `configuration/cardano/mainnet-config.json` is always valid. Co-authored-by: John Ky <john.ky@iohk.io>
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{-# LANGUAGE DisambiguateRecordFields #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Config.Mainnet | ||
( tests | ||
) where | ||
|
||
import Cardano.Api (initialLedgerState, renderInitialLedgerStateError) | ||
import Control.Monad | ||
import Control.Monad.Trans.Except | ||
import Data.Bool (Bool(..)) | ||
import Data.Either (Either(..)) | ||
import Data.Function | ||
import Data.Maybe | ||
import Hedgehog (Property) | ||
import System.FilePath ((</>)) | ||
import System.IO (IO) | ||
|
||
import qualified Data.Text as T | ||
import qualified GHC.Stack as GHC | ||
import qualified Hedgehog as H | ||
import qualified Hedgehog.Extras.Test.Base as H | ||
import qualified Hedgehog.Extras.Test.Process as H | ||
import qualified System.Directory as IO | ||
|
||
hprop_configMainnet :: Property | ||
hprop_configMainnet = H.propertyOnce $ do | ||
projectBase <- H.note =<< H.evalIO . IO.canonicalizePath =<< H.getProjectBase | ||
result <- H.evalIO $ runExceptT $ initialLedgerState $ projectBase </> "configuration/cardano/mainnet-config.json" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
case result of | ||
Right (_, _) -> return () | ||
Left e -> H.failWithCustom GHC.callStack Nothing (T.unpack (renderInitialLedgerStateError e)) | ||
|
||
tests :: IO Bool | ||
tests = | ||
H.checkSequential | ||
$ H.Group "Test.Config.Mainnet" | ||
[ ("hprop_configMainnet", hprop_configMainnet) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not a good practice to hardcode paths like this. Shouldn't it be a user-configurable option?