-
Notifications
You must be signed in to change notification settings - Fork 631
{DO NOT MERGE} [CDEC-512] Create JSON round-trip and golden tests for GenesisData, GenesisProtocolConstants, and GenesisConfiguration #3458
Conversation
58f2229
to
88198d6
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.
Just a question about encoding/decoding.
@@ -38,6 +43,35 @@ goldenTestJSON x path = withFrozenCallStack $ do | |||
Left err -> failWith Nothing $ "could not decode: " <> show err | |||
Right x' -> x === x' | |||
|
|||
-- | Only check that the datatype equals the decoding of the file |
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.
Shouldn't we also be checking the encoding?
#3415
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.
The reason for these functions is to ensure backwards compatibility with existing serialized datatstructures, with default values for missing fields. We want to demonstrate that when the PR is merged, the tests for “deserialize this bytestring and check that the value is equal to a target value” still pass (once the given datatype is modified, in the source code, to have the default value in the newly added record field)
=> a | ||
-> FilePath | ||
-> Property | ||
goldenTestCanonicalJSONDec x path = withFrozenCallStack $ do |
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.
Same question as above.
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.
See above comment. These should be used sparingly, only to ensure backwards compatibility.
The To/FromJSON instances for Microsecond store the value as an integer denoting the # of Seconds. So they are rounded to the nearest 10^6.
Luke hit some weird type errors and I got them to go away by adding a type signature. This commit uses `roundTripsCanonicalJSONShow` to test `GenesisData`.
88198d6
to
6ef8619
Compare
Conflicting files on present on this branch.
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!
Description
We have to create and expand upon existing round-trip and golden tests for the aforementioned data types in order to ensure that the upcoming implementation of CO-354 doesn't break configuration backwards compatibility.
Linked issue
https://iohk.myjetbrains.com/youtrack/issue/CDEC-512
Type of change
Developer checklist
Testing checklist
QA Steps
Screenshots (if available)