From e31d80ccf59cb2c4ff35c9e36b6ce14be05f30a5 Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 30 Jul 2024 11:58:21 +0300 Subject: [PATCH] chore(blockifier): verify local cairo repo state before compiling --- .../src/test_utils/cairo_compile.rs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/blockifier/src/test_utils/cairo_compile.rs b/crates/blockifier/src/test_utils/cairo_compile.rs index 403c988b95..d4fc00efcb 100644 --- a/crates/blockifier/src/test_utils/cairo_compile.rs +++ b/crates/blockifier/src/test_utils/cairo_compile.rs @@ -172,14 +172,32 @@ fn verify_cairo0_compiler_deps() { } fn prepare_cairo1_compiler_deps(git_tag_override: Option) { - // TODO(Dori, 1/6/2024): Check repo exists. + let cairo_repo_path = local_cairo1_compiler_repo_path(); let tag = git_tag_override.unwrap_or(format!("v{}", cairo1_compiler_version())); + + // Check if the path is a directory. + assert!( + cairo_repo_path.is_dir(), + "Cannot verify Cairo1 contracts, Cairo repo not found at {0}.\nPlease run:\n\ + git clone https://github.com/starkware-libs/cairo {0}\nThen rerun the test.", + cairo_repo_path.to_string_lossy(), + ); + // Checkout the required version in the compiler repo. run_and_verify_output(Command::new("git").args([ "-C", // TODO(Dori, 1/6/2024): Handle CI case (repo path will be different). - local_cairo1_compiler_repo_path().to_str().unwrap(), + cairo_repo_path.to_str().unwrap(), "checkout", &tag, ])); + + // Verify that the checked out tag is as expected. + run_and_verify_output(Command::new("git").args([ + "-C", + cairo_repo_path.to_str().unwrap(), + "rev-parse", + "--verify", + &tag, + ])); }