Skip to content

Commit

Permalink
update: Hashset to hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Nov 14, 2024
1 parent f24de0b commit a113579
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
7 changes: 5 additions & 2 deletions crates/orchestrator/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,11 +797,14 @@ pub mod validate_params {
#[rstest]
fn test_validate_service_params() {
let service_args: ServiceCliArgs = ServiceCliArgs {
max_block_to_process: Some("".to_string()),
min_block_to_process: Some("".to_string()),
max_block_to_process: Some("66645".to_string()),
min_block_to_process: Some("100".to_string()),
};
let service_params = validate_service_params(&service_args);
assert!(service_params.is_ok());
let service_params = service_params.unwrap();
assert_eq!(service_params.max_block_to_process, Some(66645));
assert_eq!(service_params.min_block_to_process, Some(100));
}
}
}
38 changes: 20 additions & 18 deletions e2e-tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -45,7 +45,7 @@ struct Setup {
mongo_db_instance: MongoDbServer,
starknet_client: StarknetClient,
sharp_client: SharpClient,
env_vector: HashSet<(String, String)>,
env_vector: HashMap<String, String>,
}

impl Setup {
Expand All @@ -72,42 +72,44 @@ impl Setup {
let (starknet_core_contract_address, verifier_contract_address) = anvil_setup.deploy_contracts().await;
println!("✅ Anvil setup completed");

let mut env_vec: HashSet<(String, String)> = HashSet::new();
let mut env_vec: HashMap<String, String> = HashMap::new();

let env_vars = dotenvy::vars();
for (key, value) in env_vars {
env_vec.insert((key, value));
env_vec.insert(key, value);
}

env_vec.insert((
env_vec.insert(
"MADARA_ORCHESTRATOR_MONGODB_CONNECTION_URL".to_string(),
mongo_db_instance.endpoint().to_string(),
));
);

// Adding other values to the environment variables vector
env_vec
.insert(("MADARA_ORCHESTRATOR_ETHEREUM_SETTLEMENT_RPC_URL".to_string(), anvil_setup.rpc_url.to_string()));
env_vec.insert(("MADARA_ORCHESTRATOR_SHARP_URL".to_string(), sharp_client.url()));
env_vec.insert(
"MADARA_ORCHESTRATOR_ETHEREUM_SETTLEMENT_RPC_URL".to_string(),
anvil_setup.rpc_url.to_string(),
);
env_vec.insert("MADARA_ORCHESTRATOR_SHARP_URL".to_string(), sharp_client.url());

// Adding impersonation for operator as our own address here.
// As we are using test contracts thus we don't need any impersonation.
// But that logic is being used in integration tests so to keep that. We
// add this address here.
// Anvil.addresses[0]
env_vec.insert((
env_vec.insert(
"MADARA_ORCHESTRATOR_STARKNET_OPERATOR_ADDRESS".to_string(),
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".to_string(),
));
env_vec.insert((
);
env_vec.insert(
"MADARA_ORCHESTRATOR_GPS_VERIFIER_CONTRACT_ADDRESS".to_string(),
verifier_contract_address.to_string(),
));
env_vec.insert((
);
env_vec.insert(
"MADARA_ORCHESTRATOR_L1_CORE_CONTRACT_ADDRESS".to_string(),
starknet_core_contract_address.to_string(),
));
env_vec.insert(("MADARA_ORCHESTRATOR_MAX_BLOCK_NO_TO_PROCESS".to_string(), l2_block_number));
env_vec.insert(("HEEMANK_TEST".to_string(), "array".to_string()));
);
env_vec.insert("MADARA_ORCHESTRATOR_MAX_BLOCK_NO_TO_PROCESS".to_string(), l2_block_number);
env_vec.insert("HEEMANK_TEST".to_string(), "array".to_string());

Self { mongo_db_instance, starknet_client, sharp_client, env_vector: env_vec }
}
Expand All @@ -126,7 +128,7 @@ impl Setup {
}

pub fn envs(&self) -> Vec<(String, String)> {
self.env_vector.iter().cloned().collect()
self.env_vector.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
}
}

Expand Down

0 comments on commit a113579

Please sign in to comment.