Add golden tests for the rest of the query result types#5794
Conversation
29462f1 to
46169ab
Compare
|
The golden test files are in binary, which makes them hard to check, I suggest using |
lehins
left a comment
There was a problem hiding this comment.
Great job on adding those examples.
Could I please ask you to confirm for each JSON instances that you added in this PR (as a comment on the PR itself, namely in Github, not in code) whether it was moved over from some place in cardano-api/consensus or did you add them yourself? This will be important for integration work and ensuring that we didn't break the interface
@lehins I have added the details to the PR description, as that it can be found quickly. 👍 Thanks! 🙌 |
@Soupstraw this would be a change to the test harnesses we are using, and could be a separate PR 👍 Thanks! 🙌 |
dd5ecf3 to
6803880
Compare
I do very much appose storing binary golden files in hex form in the repo. Not only they double the size of files and add unnecessary overhead to all golden tests, but they also make PRs enormous in size (since github will start to treat them as text). I am not sure who in their right mind would manually inspect hex diff of golden files in a PR review? IMHO, it would result in a ridiculous and useless diff on Github. @Soupstraw, maybe you by now developed a superpower of reading CBOR in hex form, after so much work on cuddle, but I don't think anyone else wants to read hex in PRs 😅. |
eraLedgerStateQueryGoldenSpec requires full {To,From}JSON+{Enc,Dec}CBOR.
Some query result types do not have all these instances: some lack only
FromJSON, some both {To,From}JSON.
Also export exampleVrfVerKeyHash from Shelley.Examples.
JSON goldens should only need to test encoding, and moreover we have to ensure that all ledger state query result types are able to be encoded: and so the test harnesses collapse back to a single one. Some ToJSON instances were found to be orphans in downstream packages because ledger didn't have those instances. * DefaultVote: from cardano-cli/src/Cardano/CLI/Orphan.hs * StakeSnapshot, StakeSnapshots: from cardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hs * QueryPoolStateResult: written fresh — no prior ToJSON found across cardano-api, cardano-cli, ouroboros-consensus, or cardano-db-sync, including via intermediate wrapper types. Implemented here via KeyValuePairs to match other query result types. We run the tests to add JSON goldens for queryPoolState, queryStakePoolDefaultVote, and queryStakeSnapshots, which the new instances unblock. Note: this bundles three logical changes (instance absorption, harness collapse, 3 new goldens).
* Add missing changelog entries. * Revert missing cddl section in shelley changelog. * Convert positional args to record syntax in Examples. Also, * Needed some examples re-exported from conway, they seemed to have been updated, and led to updates to the goldens.
6803880 to
20bfe48
Compare
lehins
left a comment
There was a problem hiding this comment.
Awesome work!
Thank you!
Description
There is no separate issue for this one. Consider this a follow up of #5659 where we add golden examples for all query results.
Note
Some
ToJSONinstances were found to be orphans in downstream packages because ledger didn't have those instances. These have been added here. Also an instance that could not be found, has been invented.DefaultVote: fromcardano-cli/src/Cardano/CLI/Orphan.hsStakeSnapshot,StakeSnapshots: fromcardano-api/src/Cardano/Api/Internal/Orphans/Serialisation.hsQueryPoolStateResult: written fresh — no priorToJSONfound acrosscardano-api,cardano-cli,ouroboros-consensus, orcardano-db-sync, including via intermediate wrapper types. Implemented here viaKeyValuePairsto match other query result types.Checklist
CHANGELOG.mdfiles updated for packages with externally visible changes.NOTE: New section is never added with the code changes. (See RELEASING.md).
.cabalandCHANGELOG.mdfiles when necessary, according to theversioning process.
.cabalfiles updated when necessary.NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
scripts/fourmolize.sh).scripts/cabal-format.sh).scripts/gen-cddl.sh)hie.yamlupdated (usescripts/gen-hie.sh).