From 8ad0c344b5fd330b4fdaea8ba9a3da27389633d0 Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 30 Jul 2024 12:02:04 +0300 Subject: [PATCH] chore(blockifier): add text file with current compiler version for CI use --- crates/blockifier/src/test_utils/cairo_compile.rs | 6 +++++- crates/blockifier/src/test_utils/contracts.rs | 3 ++- .../tests/feature_contracts_compatibility_test.rs | 8 +++++++- crates/blockifier/tests/legacy_cairo1_compiler_tag.txt | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) 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 50720a63ab..debe5cb432 100644 --- a/crates/blockifier/src/test_utils/cairo_compile.rs +++ b/crates/blockifier/src/test_utils/cairo_compile.rs @@ -59,6 +59,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. /// Returns /, where the relative path can be /// overridden by the environment variable (otherwise, the default is used). @@ -166,7 +170,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 1ba748b9b7..ff33afe636 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -74,7 +74,8 @@ const ERC20_CAIRO1_CONTRACT_SOURCE_PATH: &str = "./ERC20/ERC20_Cairo1/ERC20.cair const ERC20_CAIRO1_CONTRACT_PATH: &str = "./ERC20/ERC20_Cairo1/erc20.casm.json"; // 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 = + include_str!("../../tests/legacy_cairo1_compiler_tag.txt"); /// Enum representing all feature contracts. /// The contracts that are implemented in both Cairo versions include a version field. diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index bb856a0fc7..b6e9c2e01f 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -1,6 +1,6 @@ use std::fs; -use blockifier::test_utils::contracts::FeatureContract; +use blockifier::test_utils::contracts::{FeatureContract, LEGACY_CONTRACT_COMPILER_TAG}; use blockifier::test_utils::CairoVersion; use pretty_assertions::assert_eq; use rstest::rstest; @@ -110,6 +110,12 @@ fn verify_and_get_files(cairo_version: CairoVersion) -> Vec<(String, String, Str paths } +#[test] +fn test_cairo1_legacy_compiler_version() { + // Legacy contract (check that the text file doesn't have whitespace for some reason). + assert_eq!(LEGACY_CONTRACT_COMPILER_TAG.trim(), 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..852700e118 --- /dev/null +++ b/crates/blockifier/tests/legacy_cairo1_compiler_tag.txt @@ -0,0 +1 @@ +v2.1.0 \ No newline at end of file