-
Notifications
You must be signed in to change notification settings - Fork 0
Implement/Derive (de)serialization instances needed for test file #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f098597 to
110bd18
Compare
2a1c03c to
fde4cf8
Compare
| instance (ToJSON a, ToJSON b) => ToJSON (AnchoredSeq v a b) where | ||
| toJSON anchoredSeq = | ||
| object | ||
| [ "anchor" .= anchor anchoredSeq | ||
| , "sequence" .= toOldestFirst anchoredSeq | ||
| ] | ||
|
|
||
| instance (Anchorable v a b, FromJSON a, FromJSON b) => FromJSON (AnchoredSeq v a b) where | ||
| parseJSON = withObject "AnchoredSeq" $ \obj -> do | ||
| a <- obj .: "anchor" | ||
| s <- obj .: "sequence" | ||
| pure $ fromOldestFirst a s |
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 used the AnchoredSeq interface to implement the instances, instead of going down to StrictFingerTree as suggested. The reason being that I found no way of deconstructing it and leverage the StrictFingerTree instance.
| -- Note that most of the constraints in this instance declarations are caused | ||
| -- by the abstraction of the block type parameter. |
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.
At this point I've just made this compile. Still need to test that we can DO serialize a concrete block (the TestBlock I guess).
isovector
left a comment
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 great!
| (ToJSON (HeaderHash blk), HasHeader blk, ToJSON schedule, ToJSON blk) => | ||
| ToJSON (GenesisTest blk schedule) | ||
| where | ||
| toEncoding = genericToEncoding defaultOptions |
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.
why does this instance have toEncoding but the others do not?
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.
Figure I would be returning later to implement a custom instance, so it's like a little queue.
# Description Closes tweag/cardano-conformance-testing-of-consensus#52 This PR creates a separate module to accommodate the (orphan) instances needed to serialize/deserialize a `GenesisTest` as JSON; we take this approach to avoid spreading changes throughout the codebase during this phase of development. As specified in our design, `conformance-test-runner` consumes a test file that specifies (at least) a `PointSchedule` to run. It turns out our peer simulator would need access to the whole of a `GenesisTest` data, which will contain the `PointSchedule` in particular. In #3, the relevant instances were introduced for the `PointSchedule`alone. All this changes are moved into the aforementioned module.
Description
Closes tweag/cardano-conformance-testing-of-consensus#52
This PR creates a separate module to accommodate the (orphan) instances needed to serialize/deserialize a
GenesisTestas JSON; we take this approach to avoid spreading changes throughout the codebase during this phase of development.As specified in our design,
conformance-test-runnerconsumes a test file that specifies (at least) aPointScheduleto run.It turns out our peer simulator would need access to the whole of a
GenesisTestdata, which will contain thePointSchedulein particular.In #3, the relevant instances were introduced for the
PointSchedulealone. All this changes are moved into the aforementioned module.