Skip to content

Commit

Permalink
Fix: Serialize pie function (#415)
Browse files Browse the repository at this point in the history
* add test demostrating bug in serialize/deserialize function

* remove println

* Update pie.rs

* add fix of pie serialization

* fmt + clippy

* fmt + clippy

* Update pie.rs

* fmt + clippy
  • Loading branch information
HermanObst authored Oct 31, 2024
1 parent b765e8e commit e0f92c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cairo-lang-starknet-classes = { version = "=2.8.2" }
cairo-lang-utils = { version = "=2.8.2" }
cairo-lang-casm = { version = "=2.8.2" }
cairo-type-derive = { version = "0.1.0", path = "crates/cairo-type-derive" }
cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", branch = "notlesh/segment-arena-relocation-fix", features = ["cairo-1-hints", "extensive_hints", "mod_builtin"] }
cairo-vm = { git = "https://github.com/Moonsong-Labs/cairo-vm", branch = "herman/fix-pie-serialization", features = ["cairo-1-hints", "extensive_hints", "mod_builtin"] }
clap = { version = "4.5.4", features = ["derive"] }
c-kzg = { version = "1.0.3" }
env_logger = "0.11.3"
Expand Down
Binary file added tests/integration/common/data/173404.zip
Binary file not shown.
24 changes: 24 additions & 0 deletions tests/integration/pie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,27 @@ fn convert_b64_to_raw(os_pie_string: String) {
assert!(file_path.exists(), "Missing file {:}", file_path.to_string_lossy());
}
}

#[rstest]
fn deserialize_serialize_pie() {
let path_read =
Path::new(env!("CARGO_MANIFEST_DIR")).join("integration").join("common").join("data").join("173404.zip");
let pie_read = CairoPie::read_zip_file(&path_read).unwrap();
pie_read.run_validity_checks().expect("Valid reference PIE");
println!("SNOS output is valid");

let path_write =
Path::new(env!("CARGO_MANIFEST_DIR")).join("integration").join("common").join("data").join("173404_test.zip");
pie_read.write_zip_file(&path_write).expect("Could not write pie");
let pie_write = CairoPie::read_zip_file(&path_write).unwrap();

pie_write.check_pie_compatibility(&pie_read).expect("Compatible pies");

println!("Pies are compatibles");

pie_write.run_validity_checks().expect("Valid reference PIE");

println!("Written file is valid");
// Remove zip file created by the test
std::fs::remove_file(path_write).unwrap();
}

0 comments on commit e0f92c9

Please sign in to comment.