Fix RFC 7049 canonical CBOR map key ordering and add property test#1075
Conversation
234daa4 to
bed74a7
Compare
Jimbo4350
left a comment
There was a problem hiding this comment.
You are weakening the unit_canonicalise_cbor property test. Why not leave it as it is and just add your prop_canonicalise_cbor property?
|
@Jimbo4350 correct. That's because the test felt too complicated to understand and debug. Now that part of the code is covered by |
We are losing ease of debuggability. Removing Your new property will fail and only render the value that failed: I agree it's not easy to read but it can be cleaned up. |
|
This PR is stale because it has been open 45 days with no activity. |
ef2ba00 to
4aa90c0
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the CBOR canonicalisation test suite to add targeted unit tests plus a new property test that recursively checks canonicalisation (intended to align with CIP-21 / RFC 7049 canonical ordering rules).
Changes:
- Replaces the previous single canonicalisation property with three deterministic “unit” properties covering maps and maps inside definite/indefinite lists.
- Adds a QuickCheck-driven property that checks canonicalisation is canonical (per a local predicate) and idempotent.
- Introduces helper functions/data (
exampleInputMap,exampleCanonicalMap,decodeTerm, key comparator).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4aa90c0 to
1a4c796
Compare
|
@Jimbo4350 I've simplified the unit tests, moved out the special cases of list and indefinite list to separate tests A bug also came up where the keys are not sorted by length first instead of just lexicographically. This PR fixes it. |
1a4c796 to
2d8edd3
Compare
Changelog
Context
This PR reverts partially changes made to the test in: https://github.com/IntersectMBO/cardano-api/pull/1047/files
It also adds a property test, which recursively validates canonicalisation of CBOR accordingly to CIP-21.
Checklist