Skip to content

Commit 4a2ff74

Browse files
committed
Review changes
1 parent a2d1784 commit 4a2ff74

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

cardano-node/src/Cardano/Node/Run.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,7 @@ updateBlockForging startupTracer blockType nodeKernel nc = do
729729
(BlockForgingUpdate (if isNonProducing || null blockForging
730730
then DisabledBlockForging
731731
else EnabledBlockForging))
732-
unless isNonProducing $
733-
setBlockForging nodeKernel blockForging
732+
setBlockForging nodeKernel blockForging
734733
Nothing ->
735734
traceWith startupTracer
736735
$ BlockForgingBlockTypeMismatch

cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ instance ( LogFormatting (Header blk)
504504
| dtal == DDetailed ]
505505
++ [ "events" .= toJSON (map (forMachine dtal) events)
506506
| not (null events) ]
507-
++ [ "tipBlockHash" .= tipBlockHash]
508-
++ [ "tipBlockParentHash" .= tipBlockParentHash]
509-
++ [ "tipBlockIssuerVerificationKeyHash" .= tipBlockIssuerVkHashText]
507+
++ [ "tipBlockHash" .= tipBlockHash
508+
, "tipBlockParentHash" .= tipBlockParentHash
509+
, "tipBlockIssuerVerificationKeyHash" .= tipBlockIssuerVkHashText]
510510
forMachine dtal (ChainDB.SwitchedToAFork events selChangedInfo old new) =
511511
let ChainInformation { .. } = chainInformation selChangedInfo old new 0
512512
tipBlockIssuerVkHashText :: Text
@@ -527,9 +527,9 @@ instance ( LogFormatting (Header blk)
527527
| dtal == DDetailed ]
528528
++ [ "events" .= toJSON (map (forMachine dtal) events)
529529
| not (null events) ]
530-
++ [ "tipBlockHash" .= tipBlockHash]
531-
++ [ "tipBlockParentHash" .= tipBlockParentHash]
532-
++ [ "tipBlockIssuerVerificationKeyHash" .= tipBlockIssuerVkHashText]
530+
++ [ "tipBlockHash" .= tipBlockHash
531+
, "tipBlockParentHash" .= tipBlockParentHash
532+
, "tipBlockIssuerVerificationKeyHash" .= tipBlockIssuerVkHashText]
533533

534534
forMachine dtal (ChainDB.AddBlockValidation ev') =
535535
forMachine dtal ev'
@@ -2152,13 +2152,7 @@ chainInformation selChangedInfo oldFrag frag blocksUncoupledDelta = ChainInforma
21522152
}
21532153
where
21542154
tipIssuerVkHash :: BlockIssuerVerificationKeyHash
2155-
tipIssuerVkHash =
2156-
case AF.head frag of
2157-
Left AF.AnchorGenesis ->
2158-
NoBlockIssuer
2159-
Left (AF.Anchor _s _h _b) ->
2160-
NoBlockIssuer
2161-
Right blk -> getIssuerVerificationKeyHash blk
2155+
tipIssuerVkHash = either (const NoBlockIssuer) getIssuerVerificationKeyHash (AF.head frag)
21622156

21632157
fragmentChainDensity ::
21642158
HasHeader (Header blk)
Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
1+
{-# LANGUAGE FlexibleContexts #-}
2+
3+
14
-- | Check namespace consistencies agains configurations
25
module Test.Cardano.Tracing.NewTracing.Consistency (tests) where
36

47
import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration)
58

6-
import Control.Monad.IO.Class (liftIO)
9+
import Control.Monad.IO.Class (MonadIO, liftIO)
710
import Data.Text
11+
import System.Directory (canonicalizePath)
12+
import System.FilePath ((</>))
813

914
import Hedgehog (Property)
1015
import qualified Hedgehog as H
11-
import qualified Hedgehog.Extras.Test.Base as H.Base
16+
import qualified Hedgehog.Extras.Test.Base as H
17+
import qualified Hedgehog.Extras.Test.Process as H
1218
import Hedgehog.Internal.Property (PropertyName (PropertyName))
1319

14-
tests :: IO Bool
15-
tests = H.checkSequential
20+
tests :: MonadIO m => m Bool
21+
tests = do
22+
H.checkSequential
1623
$ H.Group "Configuration Consistency tests"
17-
$ test
18-
<$> [ ( []
19-
-- This file name shoud reference the current standard config with new tracing
20-
, "mainnet-config-new-tracing.json"
21-
, configPrefix)
22-
, ( []
23-
, "goodConfig.yaml"
24-
, testPrefix)
25-
, ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB"
26-
, "Config namespace error: Illegal namespace SubscriptionDNS"
27-
]
28-
, "badConfig.yaml"
29-
, testPrefix)
30-
]
24+
$ Prelude.map test
25+
[ ( []
26+
-- This file name shoud reference the current standard config with new tracing
27+
, "mainnet-config-new-tracing.json"
28+
, configPrefix)
29+
, ( []
30+
, "goodConfig.yaml"
31+
, testPrefix)
32+
, ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB"
33+
, "Config namespace error: Illegal namespace SubscriptionDNS"
34+
]
35+
, "badConfig.yaml"
36+
, testPrefix)
37+
]
3138
where
3239
test (actualValue, goldenBaseName, prefix) =
3340
(PropertyName goldenBaseName, goldenTestJSON actualValue goldenBaseName prefix)
3441

3542

36-
goldenTestJSON :: [Text] -> FilePath -> FilePath -> Property
37-
goldenTestJSON expectedOutcome goldenFileBaseName prefix =
43+
goldenTestJSON :: [Text] -> FilePath -> (FilePath -> IO FilePath) -> Property
44+
goldenTestJSON expectedOutcome goldenFileBaseName prefixFunc =
3845
H.withTests 1 $ H.withShrinks 0 $ H.property $ do
39-
goldenFp <- H.Base.note $ prefix <> goldenFileBaseName
46+
basePath <- H.getProjectBase
47+
prefixPath <- liftIO $ prefixFunc basePath
48+
goldenFp <- H.note $ prefixPath </> goldenFileBaseName
4049
actualValue <- liftIO $ checkNodeTraceConfiguration goldenFp
4150
actualValue H.=== expectedOutcome
4251

4352

44-
configPrefix :: FilePath
45-
configPrefix = "../configuration/cardano/"
53+
configPrefix :: FilePath -> IO FilePath
54+
configPrefix projectBase = do
55+
base <- canonicalizePath projectBase
56+
return $ base </> "configuration/cardano"
4657

47-
testPrefix :: FilePath
48-
testPrefix = "test/Test/Cardano/Tracing/NewTracing/data/"
58+
testPrefix :: FilePath -> IO FilePath
59+
testPrefix _ = pure "test/Test/Cardano/Tracing/NewTracing/data/"

0 commit comments

Comments
 (0)