-
Notifications
You must be signed in to change notification settings - Fork 631
[release/1.3.1] [CO-354] Override RequiresNetworkMagic from CoreConfiguration #3659
Conversation
174fbf8
to
e6a679f
Compare
d8a0928
to
d8ebf20
Compare
d8ebf20
to
fd4b172
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Should we get another review, though?
parseJSON = withObject "core" $ \obj -> do | ||
ccg <- obj .: "genesis" | ||
ccdsv <- obj .: "dbSerializeVersion" | ||
ccrnm <- determineRNM <$> obj .:? "requiresNetworkMagic" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line can be replaced with (docs)
ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust
whether that is more or less readable is another question 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be neater to use .!=
as you suggest, and then add a comment to highlight the subtlety.
-- If "requiresNetworkMagic" is not specified, default to NMMustBeJust
ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/src/Test/Pos/Helpers.hs
Outdated
:: forall a. (IdTestingRequiredClassesAlmost a, ToAndFromCanonicalJson a) | ||
=> Gen a | ||
-> Spec | ||
canonicalJsonTest' genA = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would canonicalJsonTestWithGen
or something similar be a more descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhuesch Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me.
parseJSON = withObject "core" $ \obj -> do | ||
ccg <- obj .: "genesis" | ||
ccdsv <- obj .: "dbSerializeVersion" | ||
ccrnm <- determineRNM <$> obj .:? "requiresNetworkMagic" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be neater to use .!=
as you suggest, and then add a comment to highlight the subtlety.
-- If "requiresNetworkMagic" is not specified, default to NMMustBeJust
ccrnm <- obj .:? "requiresNetworkMagic" .!= NMMustBeJust
- Rename to `canonicalJsonTestWithGen`. - Use Aeson optional-with-default combinator.
f4ca784
to
baf55d4
Compare
We want to be sure that mainnet/staging both have `NMMustBeNothing` as the `requiresNetworkMagic` field of their `ProtocolMagic` value, which is read from config. We add a simple test which can be run on the `lib/configuration.yaml` file and check multiple YAML keys for valid `RequiresNetworkMagic`s.
Description
Linked issue
https://iohk.myjetbrains.com/youtrack/issue/CO-354
Type of change
Developer checklist
Testing checklist