Skip to content

Commit 53e06d5

Browse files
chore(blockifier_test_utils): implement verify_cairo1_package
1 parent fa47704 commit 53e06d5

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:?}.");
@@ -64,6 +73,18 @@ async fn download_cairo_package(version: &String) {
6473
info!("Done.");
6574
}
6675

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

0 commit comments

Comments
 (0)