Skip to content

Commit

Permalink
Add test for validity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Apr 19, 2024
1 parent 60b3950 commit 059e139
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions vm/src/tests/cairo_pie_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,23 @@ fn serialize_cairo_pie() {
.unwrap(),
);
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn run_pie_validity_checks_integration() {
// Run the program
let program_content = include_bytes!("../../../cairo_programs/integration.json");
let mut hint_processor = BuiltinHintProcessor::new_empty();
let (runner, vm) = cairo_run(
program_content,
&CairoRunConfig {
layout: LayoutName::all_cairo,
..Default::default()
},
&mut hint_processor,
)
.expect("cairo_run failure");
// Obtain the pie
let cairo_pie = runner.get_cairo_pie(&vm).expect("Failed to get pie");
assert!(cairo_pie.run_validity_checks().is_ok())
}
2 changes: 1 addition & 1 deletion vm/src/vm/runners/cairo_pie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl CairoPie {
let validate_addr = |addr: Relocatable| -> Result<(), CairoPieValidationError> {
if !segment_sizes
.get(&addr.segment_index)
.is_some_and(|size| addr.offset < *size)
.is_some_and(|size| addr.offset <= *size)
{
return Err(CairoPieValidationError::InvalidAddress);

Check warning on line 173 in vm/src/vm/runners/cairo_pie.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/vm/runners/cairo_pie.rs#L173

Added line #L173 was not covered by tests
}
Expand Down

0 comments on commit 059e139

Please sign in to comment.