From a1135791d4146eed785039a35c7516d207202a83 Mon Sep 17 00:00:00 2001 From: Heemank Verma Date: Thu, 14 Nov 2024 15:56:05 +0530 Subject: [PATCH] update: Hashset to hashmap --- crates/orchestrator/src/cli/mod.rs | 7 ++++-- e2e-tests/tests.rs | 38 ++++++++++++++++-------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/crates/orchestrator/src/cli/mod.rs b/crates/orchestrator/src/cli/mod.rs index 859abe80..c067b7db 100644 --- a/crates/orchestrator/src/cli/mod.rs +++ b/crates/orchestrator/src/cli/mod.rs @@ -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)); } } } diff --git a/e2e-tests/tests.rs b/e2e-tests/tests.rs index c9d31ec8..03862ddc 100644 --- a/e2e-tests/tests.rs +++ b/e2e-tests/tests.rs @@ -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}; @@ -45,7 +45,7 @@ struct Setup { mongo_db_instance: MongoDbServer, starknet_client: StarknetClient, sharp_client: SharpClient, - env_vector: HashSet<(String, String)>, + env_vector: HashMap, } impl Setup { @@ -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 = 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 } } @@ -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() } }