-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ciborium and Cleanups #2
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
❌ Unreviewed dependencies found
|
Codecov Report
@@ Coverage Diff @@
## main #2 +/- ##
=======================================
Coverage ? 83.08%
=======================================
Files ? 1
Lines ? 136
Branches ? 0
=======================================
Hits ? 113
Misses ? 23
Partials ? 0 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Co-authored-by: Chris Beck <[email protected]>
this issue slightly worries me: enarx/ciborium#51 |
Can we try adding some more tests here, like nested structs, and enums? The test coverage on this seems pretty light compared to the variety of ways in which we use it |
Trying to use the bytes they provide in that issue results in #[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]
struct S {
pubkey: [u8; 32]
}
#[test]
fn try_51() {
extern crate std;
let s = S {
pubkey: [189, 182, 166, 93, 174, 37, 6, 247, 39, 203, 228, 101, 121, 197, 203, 42, 98, 138, 145, 12, 12, 76, 145, 168, 132, 185, 90, 18, 54, 28, 248, 170],
};
let serialized = serialize(&s).unwrap();
// Data from https://github.com/enarx/ciborium/issues/51
// Uncomment the lines to see the error
// let data = vec![161, 102, 112, 117, 98, 75, 101, 121, 88, 32, 189, 182, 166, 93, 174, 37, 6, 247, 39, 203, 228, 101, 121, 197, 203, 42, 98, 138, 145, 12, 12, 76, 145, 168, 132, 185, 90, 18, 54, 28, 248, 170];
// assert_eq!(format!("{r:?}"), "sushi");
let data = vec![161, 102, 112, 117, 98, 107, 101, 121, 152, 32, 24, 189, 24, 182, 24, 166, 24, 93, 24, 174, 24, 37, 6, 24, 247, 24, 39, 24, 203, 24, 228, 24, 101, 24, 121, 24, 197, 24, 203, 24, 42, 24, 98, 24, 138, 24, 145, 12, 12, 24, 76, 24, 145, 24, 168, 24, 132, 24, 185, 24, 90, 18, 24, 54, 24, 28, 24, 248, 24, 170];
assert_eq!(serialized, data);
let r = ciborium::de::from_reader::<S, _>(&data[..]);
assert_eq!(r.is_ok(), true);
assert_eq!(r.unwrap(), 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'll approve with some more unit test coverage
@nick-mobilecoin This is ready to go if you could re-review (for changes). |
Motivation
serde_cbor
has been unmaintained forever now, we've avoided switching tociborium
because it would not support deserialization to a borrowed string, whichserde_cbor
did. However, I'd rather pass cargo deny advisories than continue with this.We can fix any issues arising from this when we make mobilecoin.git use this crate.