Skip to content

Commit

Permalink
update: added e2e corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Nov 13, 2024
1 parent 3c3f83d commit 414d624
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 57 deletions.
8 changes: 2 additions & 6 deletions crates/orchestrator/src/config.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(&ethereum_settlement_params.l1_core_contract_address)?,
ethereum_settlement_params.l1_core_contract_address,
ethereum_settlement_params.ethereum_rpc_url.clone(),
Some(Address::from_str(&ethereum_settlement_params.starknet_operator_address)?),
Some(ethereum_settlement_params.starknet_operator_address),
)))
}
}
Expand Down
36 changes: 27 additions & 9 deletions crates/settlement-clients/ethereum/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(&ethereum_settlement_params.l1_core_contract_address).unwrap(),
ethereum_settlement_params.l1_core_contract_address,
ethereum_settlement_params.ethereum_rpc_url,
Some(Address::from_str(&ethereum_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");
Expand Down Expand Up @@ -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(&ethereum_settlement_params.l1_core_contract_address).unwrap(),
ethereum_settlement_params.l1_core_contract_address,
ethereum_settlement_params.ethereum_rpc_url,
None,
);
Expand Down
65 changes: 23 additions & 42 deletions e2e-tests/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 414d624

Please sign in to comment.