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

fix: default program attributes to empty vec #1450

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* fix: Default to empty attributes vector when the field is missing from the program JSON [#1450](https://github.com/lambdaclass/cairo-vm/pull/1450)

* fix: Change serialization of CairoPieMemory to match Python's binary format [#1447](https://github.com/lambdaclass/cairo-vm/pull/1447)

* fix: Remove Deserialize derive from CairoPie and fix Serialize implementation to match Python's [#1444](https://github.com/lambdaclass/cairo-vm/pull/1444)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions vm/src/serde/deserialize_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub struct ProgramJson {
pub identifiers: HashMap<String, Identifier>,
pub hints: BTreeMap<usize, Vec<HintParams>>,
pub reference_manager: ReferenceManager,
#[serde(default)]
pub attributes: Vec<Attribute>,
pub debug_info: Option<DebugInfo>,
}
Expand Down Expand Up @@ -1606,4 +1607,24 @@ mod tests {
ProgramError::InvalidHintPc(1, 1)
);
}

#[test]
fn parse_without_program_attributes() {
// Extracted from: https://testnet.starkscan.co/class/0x068dd0dd8a54ebdaa10563fbe193e6be1e0f7c423c0c3ce1e91c0b682a86b5f9
let program = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../cairo_programs/manually_compiled/program_without_attributes.json",
));
_ = deserialize_and_parse_program(program, None).expect("should be able to read file");
}

#[test]
fn parse_without_program_attributes_2() {
// Extracted from: https://testnet.starkscan.co/class/0x071b7f73b5e2b4f81f7cf01d4d1569ccba2921b3fa3170cf11cff3720dfe918e
let program = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../cairo_programs/manually_compiled/program_without_attributes_2.json",
));
_ = deserialize_and_parse_program(program, None).expect("should be able to read file");
}
}