Skip to content
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

enforce unique map keys in CBOR decoding, ver. 9 #3277

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

JaredCorduan
Copy link
Contributor

Description

Starting in major version 9, we raise a CBOR decoding error if a map contains duplicate keys.

resolves #2965

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with fourmolu (which can be run with scripts/fourmolize.sh
  • Self-reviewed the diff

@JaredCorduan JaredCorduan requested a review from lehins February 1, 2023 22:38
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a more efficient way to implement stricter Map decoder, which I suggested in a comment.

Also, maybe you wanna try adding a quickcheck property test to hspec test suite? I think it would be a good exercise to get first hand experience with hspec. This is just a suggestion, so feel free to ignore it.

Hedgehog definitely works, so the test that is already included in this PR will work just fine, but since we mostly use QuckCheck, I thought it would be better if we stick to one tool for consistency. However, if you prefer Hedgehog there is nothing wrong with using both of the random property testing libraries.

@JaredCorduan JaredCorduan force-pushed the jc/cbor-enforce-unique-map-keys branch from d0c78b0 to cef1bec Compare February 2, 2023 02:58
@JaredCorduan
Copy link
Contributor Author

Also, maybe you wanna try adding a quickcheck property test to hspec test suite? I think it would be a good exercise to get first hand experience with hspec. This is just a suggestion, so feel free to ignore it.

I only used Hedgehog since that was what was already being used in the Failure module. In general, I'd like to move completely over to QC.. I'll definitely poke around with using QuickCheck in hspec tomorrow, probably in a new test module, thanks for the motivation.

@SebastienGllmt
Copy link
Contributor

Starting in major version 9, we know raise a decoding error if a CBOR
map contains duplicate keys.

resolves #2965
@JaredCorduan JaredCorduan force-pushed the jc/cbor-enforce-unique-map-keys branch from cef1bec to ff7ea5a Compare February 2, 2023 15:55
@JaredCorduan
Copy link
Contributor Author

@lehins I redid the tests in QuickCheck. let me know if this is what you had in mind.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!!! 🙂

@JaredCorduan JaredCorduan merged commit 69f3ab9 into master Feb 2, 2023
@iohk-bors iohk-bors bot deleted the jc/cbor-enforce-unique-map-keys branch February 2, 2023 18:08
@jmhrpr
Copy link

jmhrpr commented Feb 3, 2023

What was the behaviour when decoding a map with duplicate keys? Like, what value for the duplicate key was used?

@JaredCorduan
Copy link
Contributor Author

What was the behaviour when decoding a map with duplicate keys? Like, what value for the duplicate key was used?

it was overwriting (so right biased).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

duplicate keys in CBOR map decoding
4 participants