From aef480c6d7a962d283123683f7a5bab627c08c73 Mon Sep 17 00:00:00 2001 From: Yair <92672946+yair-starkware@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:29:48 +0300 Subject: [PATCH] chore(base_layer): relax ganache version requirement (#165) --- .github/workflows/papyrus_ci.yml | 2 +- .../papyrus_base_layer/src/base_layer_test.rs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/papyrus_ci.yml b/.github/workflows/papyrus_ci.yml index ad79a6784e..d6649d80bc 100644 --- a/.github/workflows/papyrus_ci.yml +++ b/.github/workflows/papyrus_ci.yml @@ -121,7 +121,7 @@ jobs: - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - uses: Swatinem/rust-cache@v2 - - run: npm install -g ganache@7.4.3 + - run: npm install -g ganache - name: Coverage run: cargo llvm-cov --codecov -r --output-path codecov.json env: diff --git a/crates/papyrus_base_layer/src/base_layer_test.rs b/crates/papyrus_base_layer/src/base_layer_test.rs index 6cbfa347b8..bd61e08dfd 100644 --- a/crates/papyrus_base_layer/src/base_layer_test.rs +++ b/crates/papyrus_base_layer/src/base_layer_test.rs @@ -14,6 +14,8 @@ use crate::BaseLayerContract; type EthereumContractAddress = String; type TestEthereumNodeHandle = (GanacheInstance, TempDir); +const MINIMAL_GANACHE_VERSION: u8 = 7; + // Returns a Ganache instance, preset with a Starknet core contract and some state updates: // Starknet contract address: 0xe2aF2c1AE11fE13aFDb7598D0836398108a4db0A // Ethereum block number starknet block number starknet block hash @@ -33,10 +35,20 @@ fn get_test_ethereum_node() -> (TestEthereumNodeHandle, EthereumContractAddress) .stdout, ) .to_string(); - // TODO(yair): Consider relaxing the version requirement. + const GANACHE_VERSION_PREFIX: &str = "ganache v"; + let ganache_version = ganache_version + .strip_prefix(GANACHE_VERSION_PREFIX) + .expect("Failed to parse Ganache version."); + let major_version = ganache_version + .split('.') + .next() + .expect("Failed to parse Ganache major version.") + .parse::() + .expect("Failed to parse Ganache major version."); assert!( - ganache_version.starts_with("ganache v7.4.3"), - "Wrong Ganache version, please install v7.4.3" + major_version >= MINIMAL_GANACHE_VERSION, + "Wrong Ganache version, expecting at least version 7. To install, run `npm install -g \ + ganache`." ); const DB_NAME: &str = "ganache-db"; let db_archive_path = format!("resources/{DB_NAME}.tar");