Skip to content

Commit

Permalink
resolve test input file mainnet-config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeier committed Dec 12, 2024
1 parent ecb34ce commit 1c7393e
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration)

import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Text
import qualified System.Directory as IO
import System.FilePath ((</>))

import Hedgehog (Property)
Expand All @@ -21,40 +22,45 @@ tests = do
H.checkSequential
$ H.Group "Configuration Consistency tests"
$ Prelude.map test
[ {--( []
-- This file name shoud reference the current standard config with new tracing
-- Add this testcase when hydra has access to a config file with new tracing config
[ ( []
-- This file name should reference the current standard config with new tracing
, configSubdir
, "mainnet-config.json"
, configPrefix)
,--}
)
,
( []
, testSubdir
, "goodConfig.yaml"
, testPrefix)
)
, ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB"
, "Config namespace error: Illegal namespace SubscriptionDNS"
]
, testSubdir
, "badConfig.yaml"
, testPrefix)
)
]
where
test (actualValue, goldenBaseName, prefix) =
(PropertyName goldenBaseName, goldenTestJSON actualValue goldenBaseName prefix)
test (actualValue, subDir, goldenBaseName) =
(PropertyName goldenBaseName, goldenTestJSON actualValue subDir goldenBaseName)


goldenTestJSON :: [Text] -> FilePath -> (FilePath -> IO FilePath) -> Property
goldenTestJSON expectedOutcome goldenFileBaseName prefixFunc =
goldenTestJSON :: [Text] -> SubdirSelection -> FilePath -> Property
goldenTestJSON expectedOutcome subDir goldenFileBaseName =
H.withTests 1 $ H.withShrinks 0 $ H.property $ do
basePath <- H.getProjectBase
prefixPath <- liftIO $ prefixFunc basePath
goldenFp <- H.note $ prefixPath </> goldenFileBaseName
base <- resolveDir subDir
goldenFp <- H.note $ base </> goldenFileBaseName
actualValue <- liftIO $ checkNodeTraceConfiguration goldenFp
actualValue H.=== expectedOutcome
where
resolveDir (ExternalSubdir d) = do
base <- H.evalIO . IO.canonicalizePath =<< H.getProjectBase
pure $ base </> d
resolveDir (InternalSubdir d) =
pure d

data SubdirSelection =
InternalSubdir FilePath
| ExternalSubdir FilePath

-- configPrefix :: FilePath -> IO FilePath
-- configPrefix projectBase = do
-- base <- canonicalizePath projectBase
-- return $ base </> "configuration/cardano/"

testPrefix :: FilePath -> IO FilePath
testPrefix _ = pure "test/Test/Cardano/Tracing/NewTracing/data/"
testSubdir, configSubdir :: SubdirSelection
testSubdir = InternalSubdir "test/Test/Cardano/Tracing/NewTracing/data"
configSubdir = ExternalSubdir "configuration/cardano"

0 comments on commit 1c7393e

Please sign in to comment.