-
Notifications
You must be signed in to change notification settings - Fork 180
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
Add test cases documenting CBOR's behaviour with omitted and extra fields #6880
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6880 +/- ##
==========================================
- Coverage 41.09% 41.07% -0.02%
==========================================
Files 2121 2121
Lines 185912 185912
==========================================
- Hits 76395 76360 -35
- Misses 103104 103137 +33
- Partials 6413 6415 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Very nice demonstration of behaviour
assert.NoError(t, err) | ||
|
||
var m1 model1 | ||
err = defaultDecMode.Unmarshal(bz, &m1) |
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.
it would be great to use the decoding mode defined in the package
flow-go/model/encoding/cbor/codec.go
Lines 38 to 41 in e8c8347
// NetworkDecMode is the DecMode used for decoding messages over the network. | |
// It returns an error if the message contains any extra field not present in the | |
// target (struct we are unmarshalling into), which prevents some classes of spamming. | |
var NetworkDecMode, _ = cbor.DecOptions{ExtraReturnErrors: cbor.ExtraDecErrorUnknownField}.DecMode() |
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.
That isn't defined on this branch, but we'll get this outcome when merging the feature branch.
Co-authored-by: Alexander Hentschel <[email protected]>
… into jord/cbor-codec-behaviour
This PR adds two test cases to the CBOR codec package which document the behaviour of the CBOR decoding mode used for the networking layer.