diff --git a/Cargo.lock b/Cargo.lock index ef5fea3552..4ab708895a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11141,6 +11141,7 @@ dependencies = [ "assert_matches", "async-trait", "hyper 0.14.32", + "once_cell", "papyrus_config", "pretty_assertions", "rstest", diff --git a/crates/starknet_sequencer_infra/Cargo.toml b/crates/starknet_sequencer_infra/Cargo.toml index 08d60b14e8..470a95b778 100644 --- a/crates/starknet_sequencer_infra/Cargo.toml +++ b/crates/starknet_sequencer_infra/Cargo.toml @@ -29,5 +29,6 @@ validator.workspace = true [dev-dependencies] assert_matches.workspace = true +once_cell.workspace = true pretty_assertions.workspace = true starknet-types-core.workspace = true diff --git a/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs b/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs index c0284a71a7..a7bc97f0df 100644 --- a/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs +++ b/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs @@ -1,7 +1,8 @@ use std::fmt::Debug; use std::net::SocketAddr; use std::sync::Arc; - +use once_cell::sync::Lazy; +use std::sync::{Arc, Mutex}; use async_trait::async_trait; use hyper::body::to_bytes; use hyper::header::CONTENT_TYPE; @@ -64,6 +65,33 @@ const DESERIALIZE_REQ_ERROR_MESSAGE: &str = "Could not deserialize client reques const DESERIALIZE_RES_ERROR_MESSAGE: &str = "Could not deserialize server response"; const VALID_VALUE_A: ValueA = Felt::ONE; + + +// Define the shared fixture +static TEST_PORTS: Lazy>> = Lazy::new(|| { + let mut available_ports = AvailablePorts::new(test_unique_index, 0); + Arc::new(Mutex::new(fixture)) +}); + +// Mock data type for illustration +struct YourSharedDataType { + value: u32, +} + +impl YourSharedDataType { + fn new() -> Self { + Self { value: 0 } + } + + fn increment(&mut self) { + self.value += 1; + } + + fn get_value(&self) -> u32 { + self.value + } +} + #[async_trait] impl ComponentAClientTrait for RemoteComponentClient { async fn a_get_value(&self) -> ResultA {