From 103ae1b4e0682bc87f0fcb81f7ef5c65d13ca057 Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 7 May 2024 13:05:22 +0300 Subject: [PATCH] chore: add text file with current compiler version for CI use Signed-off-by: Dori Medini --- crates/blockifier/src/test_utils/cairo_compile.rs | 6 +++++- crates/blockifier/src/test_utils/contracts.rs | 2 +- crates/blockifier/tests/cairo1_compiler_tag.txt | 1 + .../tests/feature_contracts_compatibility_test.rs | 13 ++++++++++++- .../blockifier/tests/legacy_cairo1_compiler_tag.txt | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 crates/blockifier/tests/cairo1_compiler_tag.txt create mode 100644 crates/blockifier/tests/legacy_cairo1_compiler_tag.txt diff --git a/crates/blockifier/src/test_utils/cairo_compile.rs b/crates/blockifier/src/test_utils/cairo_compile.rs index 88a0dc0395..be66c009a7 100644 --- a/crates/blockifier/src/test_utils/cairo_compile.rs +++ b/crates/blockifier/src/test_utils/cairo_compile.rs @@ -56,6 +56,10 @@ pub fn cairo1_compiler_version() -> String { } } +pub fn cairo1_compiler_tag() -> String { + format!("v{}", cairo1_compiler_version()) +} + /// Returns the path to the local Cairo1 compiler repository. fn local_cairo1_compiler_repo_path() -> PathBuf { // Location of blockifier's Cargo.toml. @@ -149,7 +153,7 @@ fn verify_cairo0_compiler_deps() { fn verify_cairo1_compiler_deps(git_tag_override: Option) { let cairo_repo_path = local_cairo1_compiler_repo_path(); - let tag = git_tag_override.unwrap_or(format!("v{}", cairo1_compiler_version())); + let tag = git_tag_override.unwrap_or(cairo1_compiler_tag()); // Check if the path is a directory. assert!( diff --git a/crates/blockifier/src/test_utils/contracts.rs b/crates/blockifier/src/test_utils/contracts.rs index 3c2e969e88..30de54d111 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -58,7 +58,7 @@ const ERC20_CONTRACT_PATH: &str = const ERC20_CONTRACT_SOURCE_PATH: &str = "./ERC20_without_some_syscalls/ERC20/ERC20.cairo"; // Legacy contract is compiled with a fixed version of the compiler. -const LEGACY_CONTRACT_COMPILER_TAG: &str = "v2.1.0"; +pub const LEGACY_CONTRACT_COMPILER_TAG: &str = "v2.1.0"; /// Enum representing all feature contracts. /// The contracts that are implemented in both Cairo versions include a version field. diff --git a/crates/blockifier/tests/cairo1_compiler_tag.txt b/crates/blockifier/tests/cairo1_compiler_tag.txt new file mode 100644 index 0000000000..8a965c1168 --- /dev/null +++ b/crates/blockifier/tests/cairo1_compiler_tag.txt @@ -0,0 +1 @@ +v2.6.0 diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index e7d2d45bb8..34546d3572 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -1,6 +1,7 @@ use std::fs; -use blockifier::test_utils::contracts::FeatureContract; +use blockifier::test_utils::cairo_compile::cairo1_compiler_tag; +use blockifier::test_utils::contracts::{FeatureContract, LEGACY_CONTRACT_COMPILER_TAG}; use blockifier::test_utils::CairoVersion; use pretty_assertions::assert_eq; use rstest::rstest; @@ -109,6 +110,16 @@ fn verify_and_get_files(cairo_version: CairoVersion) -> Vec<(String, String, Str paths } +#[test] +fn test_cairo1_compiler_version_ci_files() { + // For all except the legacy contract. + let on_file = include_str!("cairo1_compiler_tag.txt").trim().to_string(); + assert_eq!(on_file, cairo1_compiler_tag()); + // Legacy contract + let on_file = include_str!("legacy_cairo1_compiler_tag.txt").trim().to_string(); + assert_eq!(on_file, LEGACY_CONTRACT_COMPILER_TAG); +} + #[test] fn verify_feature_contracts_match_enum() { let mut compiled_paths_from_enum: Vec = FeatureContract::all_feature_contracts() diff --git a/crates/blockifier/tests/legacy_cairo1_compiler_tag.txt b/crates/blockifier/tests/legacy_cairo1_compiler_tag.txt new file mode 100644 index 0000000000..1defe531bf --- /dev/null +++ b/crates/blockifier/tests/legacy_cairo1_compiler_tag.txt @@ -0,0 +1 @@ +v2.1.0