diff --git a/crates/orchestrator/src/config.rs b/crates/orchestrator/src/config.rs index 5475d805..dc0fd408 100644 --- a/crates/orchestrator/src/config.rs +++ b/crates/orchestrator/src/config.rs @@ -1,9 +1,5 @@ -#[cfg(feature = "testing")] -use std::str::FromStr; use std::sync::Arc; -#[cfg(feature = "testing")] -use alloy::primitives::Address; #[cfg(feature = "testing")] use alloy::providers::RootProvider; use aws_config::meta::region::RegionProviderChain; @@ -295,9 +291,9 @@ pub async fn build_settlement_client( { Ok(Box::new(EthereumSettlementClient::with_test_params( RootProvider::new_http(ethereum_settlement_params.ethereum_rpc_url.clone()), - Address::from_str(ðereum_settlement_params.l1_core_contract_address)?, + ethereum_settlement_params.l1_core_contract_address, ethereum_settlement_params.ethereum_rpc_url.clone(), - Some(Address::from_str(ðereum_settlement_params.starknet_operator_address)?), + Some(ethereum_settlement_params.starknet_operator_address), ))) } } diff --git a/crates/settlement-clients/ethereum/src/tests/mod.rs b/crates/settlement-clients/ethereum/src/tests/mod.rs index 6389f1fb..bbd4a8e5 100644 --- a/crates/settlement-clients/ethereum/src/tests/mod.rs +++ b/crates/settlement-clients/ethereum/src/tests/mod.rs @@ -161,8 +161,14 @@ mod settlement_client_tests { let ethereum_settlement_params = EthereumSettlementValidatedArgs { ethereum_rpc_url: setup.rpc_url, ethereum_private_key: get_env_var_or_panic("MADARA_ORCHESTRATOR_ETHEREUM_PRIVATE_KEY"), - l1_core_contract_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS"), - starknet_operator_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS"), + l1_core_contract_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS", + )) + .expect("Invalid L1 core contract address"), + starknet_operator_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS", + )) + .expect("Invalid Starknet operator address"), }; // Deploying a dummy contract @@ -233,15 +239,21 @@ mod settlement_client_tests { let ethereum_settlement_params = EthereumSettlementValidatedArgs { ethereum_rpc_url: setup.rpc_url, ethereum_private_key: get_env_var_or_panic("MADARA_ORCHESTRATOR_ETHEREUM_PRIVATE_KEY"), - l1_core_contract_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS"), - starknet_operator_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS"), + l1_core_contract_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS", + )) + .expect("Invalid L1 core contract address"), + starknet_operator_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS", + )) + .expect("Invalid Starknet operator address"), }; let ethereum_settlement_client = EthereumSettlementClient::with_test_params( setup.provider.clone(), - Address::from_str(ðereum_settlement_params.l1_core_contract_address).unwrap(), + ethereum_settlement_params.l1_core_contract_address, ethereum_settlement_params.ethereum_rpc_url, - Some(Address::from_str(ðereum_settlement_params.starknet_operator_address).unwrap()), + Some(ethereum_settlement_params.starknet_operator_address), ); // let nonce = ethereum_settlement_client.get_nonce().await.expect("Unable to fetch nonce"); @@ -299,13 +311,19 @@ mod settlement_client_tests { let ethereum_settlement_params = EthereumSettlementValidatedArgs { ethereum_rpc_url: setup.rpc_url, ethereum_private_key: get_env_var_or_panic("MADARA_ORCHESTRATOR_ETHEREUM_PRIVATE_KEY"), - l1_core_contract_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS"), - starknet_operator_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS"), + l1_core_contract_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS", + )) + .expect("Invalid L1 core contract address"), + starknet_operator_address: Address::from_str(&get_env_var_or_panic( + "MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS", + )) + .expect("Invalid Starknet operator address"), }; let ethereum_settlement_client = EthereumSettlementClient::with_test_params( setup.provider.clone(), - Address::from_str(ðereum_settlement_params.l1_core_contract_address).unwrap(), + ethereum_settlement_params.l1_core_contract_address, ethereum_settlement_params.ethereum_rpc_url, None, ); diff --git a/e2e-tests/src/node.rs b/e2e-tests/src/node.rs index bef74615..f491efd3 100644 --- a/e2e-tests/src/node.rs +++ b/e2e-tests/src/node.rs @@ -40,16 +40,10 @@ impl Orchestrator { let repository_root = &get_repository_root(); std::env::set_current_dir(repository_root).expect("Failed to change working directory"); - let (mode_str, is_run_mode) = match mode { - OrchestratorMode::Setup => { - println!("Running orchestrator in Setup mode"); - (OrchestratorMode::Setup.to_string(), false) - } - OrchestratorMode::Run => { - println!("Running orchestrator in Run mode"); - (OrchestratorMode::Run.to_string(), true) - } - }; + let is_run_mode = mode == OrchestratorMode::Run; + let mode_str = mode.to_string(); + + println!("Running orchestrator in {} mode", mode_str); // Configure common command arguments let mut command = Command::new("cargo"); @@ -90,41 +84,28 @@ impl Orchestrator { let mut process = command.spawn().expect("Failed to start process"); - if is_run_mode { - // Set up stdout and stderr handling for run mode - let stdout = process.stdout.take().expect("Failed to capture stdout"); - thread::spawn(move || { - let reader = BufReader::new(stdout); - reader.lines().for_each(|line| { - if let Ok(line) = line { - println!("STDOUT: {}", line); - } - }); + // Set up stdout and stderr handling for run mode + let stdout = process.stdout.take().expect("Failed to capture stdout"); + thread::spawn(move || { + let reader = BufReader::new(stdout); + reader.lines().for_each(|line| { + if let Ok(line) = line { + println!("STDOUT: {}", line); + } }); - - let stderr = process.stderr.take().expect("Failed to capture stderr"); - thread::spawn(move || { - let reader = BufReader::new(stderr); - reader.lines().for_each(|line| { - if let Ok(line) = line { - eprintln!("STDERR: {}", line); - } - }); + }); + + let stderr = process.stderr.take().expect("Failed to capture stderr"); + thread::spawn(move || { + let reader = BufReader::new(stderr); + reader.lines().for_each(|line| { + if let Ok(line) = line { + eprintln!("STDERR: {}", line); + } }); + }); - Some(Self { process, address }) - } else { - // Handle setup mode - let status = process.wait().expect("Failed to wait for process"); - if status.success() { - println!("Setup Orchestrator completed successfully"); - } else if let Some(code) = status.code() { - println!("Setup Orchestrator failed with exit code: {}", code); - } else { - println!("Setup Orchestrator terminated by signal"); - } - None - } + if is_run_mode { Some(Self { process, address }) } else { None } } pub fn endpoint(&self) -> Url {