feat: add --evm-path argument to test CLI
This commit is contained in:
@@ -16,8 +16,8 @@ for test in "${args[@]}"; do
|
|||||||
protocol="${test%%=*}"
|
protocol="${test%%=*}"
|
||||||
filter="${test#*=}"
|
filter="${test#*=}"
|
||||||
if [[ "$test" == *"="* ]]; then
|
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
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ struct Args {
|
|||||||
#[arg(long, required_unless_present = "package", conflicts_with = "package")]
|
#[arg(long, required_unless_present = "package", conflicts_with = "package")]
|
||||||
package_path: Option<String>,
|
package_path: Option<String>,
|
||||||
|
|
||||||
|
/// Path to the evm directory. If not provided, it will look for it in `../evm`
|
||||||
|
#[arg(long)]
|
||||||
|
evm_path: Option<PathBuf>,
|
||||||
|
|
||||||
/// If provided, only run the tests with a matching name
|
/// If provided, only run the tests with a matching name
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
match_test: Option<String>,
|
match_test: Option<String>,
|
||||||
@@ -50,6 +54,24 @@ impl Args {
|
|||||||
_ => Err(miette!("Either package or package_path must be provided")),
|
_ => Err(miette!("Either package or package_path must be provided")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn evm_path(&self) -> miette::Result<PathBuf> {
|
||||||
|
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<()> {
|
fn main() -> miette::Result<()> {
|
||||||
@@ -62,6 +84,7 @@ fn main() -> miette::Result<()> {
|
|||||||
|
|
||||||
let test_runner = TestRunner::new(
|
let test_runner = TestRunner::new(
|
||||||
args.package_path()?,
|
args.package_path()?,
|
||||||
|
args.evm_path()?,
|
||||||
args.match_test,
|
args.match_test,
|
||||||
args.tycho_logs,
|
args.tycho_logs,
|
||||||
args.db_url,
|
args.db_url,
|
||||||
|
|||||||
@@ -52,13 +52,12 @@ pub struct TestRunner {
|
|||||||
impl TestRunner {
|
impl TestRunner {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
substreams_path: PathBuf,
|
substreams_path: PathBuf,
|
||||||
|
evm_path: PathBuf,
|
||||||
match_test: Option<String>,
|
match_test: Option<String>,
|
||||||
tycho_logs: bool,
|
tycho_logs: bool,
|
||||||
db_url: String,
|
db_url: String,
|
||||||
vm_traces: bool,
|
vm_traces: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let repo_root = env::current_dir().expect("Failed to get current directory");
|
|
||||||
let evm_path = repo_root.join("evm");
|
|
||||||
let adapter_contract_builder =
|
let adapter_contract_builder =
|
||||||
AdapterContractBuilder::new(evm_path.to_string_lossy().to_string());
|
AdapterContractBuilder::new(evm_path.to_string_lossy().to_string());
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user