Skip to content

Commit

Permalink
fix: default program attributes to empty vec (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oppen committed Oct 2, 2023
1 parent b6b7350 commit f6c7cb0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
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");
}
}

0 comments on commit f6c7cb0

Please sign in to comment.