Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions cedar-drt/fuzz/fuzz_targets/roundtrip-entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ fuzz_target!(|input: FuzzTargetInput| {
Extensions::all_available(),
TCComputation::EnforceAlreadyComputed,
);
let roundtripped_entities = eparser
.from_json_value(json.clone())
.expect("Should be able to parse serialized entity JSON");
// Weaker assertion for schema based parsing because it adds actions from the schema into entities.
for e in input.entities {
let roundtripped_e = roundtripped_entities
.entity(e.uid())
.expect("Schema-based roundtrip dropped entity");
assert_eq!(&e, roundtripped_e);
match eparser.from_json_value(json.clone()) {
Ok(roundtripped_entities) => {
// Weaker assertion for schema based parsing because it adds actions from the schema into entities.
for e in input.entities {
let roundtripped_e = roundtripped_entities
.entity(e.uid())
.expect("Schema-based roundtrip dropped entity");
assert_eq!(&e, roundtripped_e);
}
}
Err(errs) => {
assert!(matches!(errs, EntitiesError::InvalidEntity(_)));
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add a comment explaining why InvalidEntity is the only expected error, just for future people who might see this code and wonder?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I didn't follow this conversation and am already confused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I'll do it now.

}
}
});