Skip to content

Commit ff113b5

Browse files
chore(blockifier_test_utils): implement verify_cairo1_package
1 parent 091fd64 commit ff113b5

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
@@ -52,9 +52,18 @@ fn cairo1_package_dir(version: &String) -> PathBuf {
5252
project_path().unwrap().join(format!("target/bin/cairo_package__{version}"))
5353
}
5454

55+
/// Path to starknet-compile binary, of the specified version.
56+
fn starknet_compile_binary_path(version: &String) -> PathBuf {
57+
cairo1_package_dir(version).join("cairo/bin/starknet-compile")
58+
}
59+
60+
/// Path to starknet-sierra-compile binary, of the specified version.
61+
fn starknet_sierra_compile_binary_path(version: &String) -> PathBuf {
62+
cairo1_package_dir(version).join("cairo/bin/starknet-sierra-compile")
63+
}
64+
5565
/// Downloads the cairo package to the local directory.
5666
/// Creates the directory if it does not exist.
57-
#[allow(dead_code)]
5867
async fn download_cairo_package(version: &String) {
5968
let directory = cairo1_package_dir(version);
6069
info!("Downloading Cairo package to {directory:?}.");
@@ -73,6 +82,18 @@ async fn download_cairo_package(version: &String) {
7382
info!("Done.");
7483
}
7584

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

0 commit comments

Comments
 (0)