From 894b169e6f1853855072de88ec209d6ae193c87e Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 11 Sep 2025 09:39:28 +0200 Subject: [PATCH] feat: add `--evm-path` argument to test CLI --- protocol-testing/entrypoint.sh | 4 ++-- protocol-testing/src/main.rs | 23 +++++++++++++++++++++++ protocol-testing/src/test_runner.rs | 3 +-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/protocol-testing/entrypoint.sh b/protocol-testing/entrypoint.sh index 676af4e..2c0c9ce 100644 --- a/protocol-testing/entrypoint.sh +++ b/protocol-testing/entrypoint.sh @@ -16,8 +16,8 @@ for test in "${args[@]}"; do protocol="${test%%=*}" filter="${test#*=}" if [[ "$test" == *"="* ]]; then - tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL" --match-test "$filter" + tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL" --evm-path "/app/evm" --match-test "$filter" else - tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL" + tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL" --evm-path "/app/evm" fi done diff --git a/protocol-testing/src/main.rs b/protocol-testing/src/main.rs index 0eb88bf..07ef31c 100644 --- a/protocol-testing/src/main.rs +++ b/protocol-testing/src/main.rs @@ -25,6 +25,10 @@ struct Args { #[arg(long, required_unless_present = "package", conflicts_with = "package")] package_path: Option, + /// Path to the evm directory. If not provided, it will look for it in `../evm` + #[arg(long)] + evm_path: Option, + /// If provided, only run the tests with a matching name #[arg(long)] match_test: Option, @@ -50,6 +54,24 @@ impl Args { _ => Err(miette!("Either package or package_path must be provided")), } } + + fn evm_path(&self) -> miette::Result { + match self.evm_path.as_ref() { + Some(path) => Ok(path.clone()), + None => { + let current_dir = std::env::current_dir() + .map_err(|e| miette!("Failed to get current directory: {}", e))?; + let mut evm_dir = current_dir.join("../evm"); + if !evm_dir.exists() { + evm_dir = current_dir.join("evm"); + if !evm_dir.exists() { + return Err(miette!("evm directory not found")); + } + } + Ok(evm_dir) + } + } + } } fn main() -> miette::Result<()> { @@ -62,6 +84,7 @@ fn main() -> miette::Result<()> { let test_runner = TestRunner::new( args.package_path()?, + args.evm_path()?, args.match_test, args.tycho_logs, args.db_url, diff --git a/protocol-testing/src/test_runner.rs b/protocol-testing/src/test_runner.rs index a86dd98..7ab15dc 100644 --- a/protocol-testing/src/test_runner.rs +++ b/protocol-testing/src/test_runner.rs @@ -52,13 +52,12 @@ pub struct TestRunner { impl TestRunner { pub fn new( substreams_path: PathBuf, + evm_path: PathBuf, match_test: Option, tycho_logs: bool, db_url: String, vm_traces: bool, ) -> Self { - let repo_root = env::current_dir().expect("Failed to get current directory"); - let evm_path = repo_root.join("evm"); let adapter_contract_builder = AdapterContractBuilder::new(evm_path.to_string_lossy().to_string()); Self {