Skip to content

Commit

Permalink
feat: Add separate index for zk_ee (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Jan 13, 2025
1 parent 22070cb commit d24ec18
Show file tree
Hide file tree
Showing 8 changed files with 17,096 additions and 16 deletions.
24 changes: 17 additions & 7 deletions evm_tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl EvmTester {
where
D: EraVMDeployer,
{
let tests = self.all_tests()?;
let tests = self.all_tests(Environment::EVMEmulator)?;
let vm = Arc::new(vm);

let _: Vec<()> = tests
Expand All @@ -95,7 +95,7 @@ impl EvmTester {
/// Runs all tests on ZK OS.
///
pub fn run_zk_os(self, vm: ZkOS) -> anyhow::Result<()> {
let tests = self.all_tests()?;
let tests = self.all_tests(Environment::ZkOS)?;
let vm = Arc::new(vm);

let _: Vec<()> = tests
Expand All @@ -111,12 +111,13 @@ impl EvmTester {
///
/// Returns all tests from all directories.
///
fn all_tests(&self) -> anyhow::Result<Vec<Test>> {
fn all_tests(&self, environment: Environment) -> anyhow::Result<Vec<Test>> {
let mut tests = Vec::with_capacity(16384);

tests.extend(self.directory::<EthereumGeneralStateTestsDirectory>(
Self::GENERAL_STATE_TESTS,
Self::GENERAL_STATE_TESTS_FILLER,
environment,
)?);

Ok(tests)
Expand All @@ -125,12 +126,21 @@ impl EvmTester {
///
/// Returns all tests from the specified directory.
///
fn directory<T>(&self, path: &str, filler_path: &str) -> anyhow::Result<Vec<Test>>
fn directory<T>(
&self,
path: &str,
filler_path: &str,
environment: Environment,
) -> anyhow::Result<Vec<Test>>
where
T: Collection,
{
T::read_all(Path::new(path), Path::new(filler_path), &self.filters).map_err(|error| {
anyhow::anyhow!("Failed to read the tests directory `{path}`: {error}")
})
T::read_all(
Path::new(path),
Path::new(filler_path),
&self.filters,
environment,
)
.map_err(|error| anyhow::anyhow!("Failed to read the tests directory `{path}`: {error}"))
}
}
15 changes: 6 additions & 9 deletions evm_tester/src/test_suits/ethereum_general_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@ use std::path::Path;
use std::path::PathBuf;

pub mod index;
pub mod platforms;

use platforms::index_for_environment;

use crate::filters::Filters;
use crate::test::Test;
use crate::test_suits::Collection;
use crate::Environment;

///
/// The Ethereum tests directory.
///
pub struct EthereumGeneralStateTestsDirectory;

impl EthereumGeneralStateTestsDirectory {
///
/// The index file path.
///
/// Must be appended to the tests directory.
///
const INDEX_NAME: &'static str = "ethereum-general-state-tests.yaml";

///
/// Reads the Ethereum test index.
///
Expand All @@ -39,9 +36,9 @@ impl Collection for EthereumGeneralStateTestsDirectory {
directory_path: &Path,
filler_path: &Path,
filters: &Filters,
environment: Environment,
) -> anyhow::Result<Vec<Test>> {
let index_path = PathBuf::from(Self::INDEX_NAME);

let index_path = PathBuf::from(index_for_environment(environment));
Ok(Self::read_index(index_path.as_path())?
.into_enabled_list(directory_path)
.into_iter()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
///
/// The index file path.
///
pub const INDEX_PATH: &'static str = "indexes/emulator/ethereum-general-state-tests.yaml";
11 changes: 11 additions & 0 deletions evm_tester/src/test_suits/ethereum_general_state/platforms/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::Environment;

pub mod emulator;
pub mod zk_ee;

pub fn index_for_environment(environment: Environment) -> &'static str {
match environment {
Environment::EVMEmulator => emulator::INDEX_PATH,
Environment::ZkOS => zk_ee::INDEX_PATH,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
///
/// The index file path.
///
pub const INDEX_PATH: &'static str = "indexes/zk_ee/ethereum-general-state-tests.yaml";
2 changes: 2 additions & 0 deletions evm_tester/src/test_suits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod ethereum_general_state;

use crate::filters::Filters;
use crate::test::Test;
use crate::Environment;
use std::path::Path;

///
Expand All @@ -19,5 +20,6 @@ pub trait Collection {
directory_path: &Path,
filler_path: &Path,
filters: &Filters,
environment: Environment,
) -> anyhow::Result<Vec<Test>>;
}
Loading

0 comments on commit d24ec18

Please sign in to comment.