Skip to content

Commit 4e0bd9b

Browse files
chore(blockifier_test_utils): implement verify_cairo1_package
1 parent b6d57b7 commit 4e0bd9b

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

crates/blockifier_test_utils/src/cairo_compile.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,18 @@ fn cairo1_package_dir(version: &String) -> PathBuf {
4242
project_path().unwrap().join(format!("target/bin/cairo_package__{version}"))
4343
}
4444

45+
/// Path to starknet-compile binary, of the specified version.
46+
fn starknet_compile_binary_path(version: &String) -> PathBuf {
47+
cairo1_package_dir(version).join("cairo/bin/starknet-compile")
48+
}
49+
50+
/// Path to starknet-sierra-compile binary, of the specified version.
51+
fn starknet_sierra_compile_binary_path(version: &String) -> PathBuf {
52+
cairo1_package_dir(version).join("cairo/bin/starknet-sierra-compile")
53+
}
54+
4555
/// Downloads the cairo package to the local directory.
4656
/// Creates the directory if it does not exist.
47-
#[allow(dead_code)]
4857
async fn download_cairo_package(version: &String) {
4958
let directory = cairo1_package_dir(version);
5059
info!("Downloading Cairo package to {directory:?}.");
@@ -70,6 +79,18 @@ async fn download_cairo_package(version: &String) {
7079
info!("Done.");
7180
}
7281

82+
/// Verifies that the Cairo1 package (of the given version) is available.
83+
#[allow(dead_code)]
84+
async fn verify_cairo1_package(version: &String, download_if_missing: bool) {
85+
let cairo_compiler_path = starknet_compile_binary_path(version);
86+
let sierra_compiler_path = starknet_sierra_compile_binary_path(version);
87+
if download_if_missing && (!cairo_compiler_path.exists() || !sierra_compiler_path.exists()) {
88+
download_cairo_package(version).await;
89+
}
90+
assert!(cairo_compiler_path.exists(), "Cairo compiler not found at {cairo_compiler_path:?}");
91+
assert!(sierra_compiler_path.exists(), "Sierra compiler not found at {sierra_compiler_path:?}");
92+
}
93+
7394
/// Runs a command. If it has succeeded, it returns the command's output; otherwise, it panics with
7495
/// stderr output.
7596
fn run_and_verify_output(command: &mut Command) -> Output {

0 commit comments

Comments
 (0)