Skip to content

Commit

Permalink
chore(starknet_integration_tests): pass relevant ports to config gen fn
Browse files Browse the repository at this point in the history
commit-id:0ce5f26a
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 25, 2024
1 parent b651202 commit fea9f6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 5 additions & 7 deletions crates/papyrus_network/src/network_manager/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@ where
Ok(TestSubscriberChannels { subscriber_channels, mock_network })
}

pub fn create_connected_network_configs(
n: usize,
available_ports: &mut AvailablePorts,
) -> Vec<NetworkConfig> {
let mut ports = available_ports.get_next_ports(n);
pub fn create_connected_network_configs(mut ports: Vec<u16>) -> Vec<NetworkConfig> {
let number_of_configs = ports.len();
let port0 = ports.remove(0);

let secret_key0 = [1u8; 32];
Expand All @@ -163,7 +160,7 @@ pub fn create_connected_network_configs(
secret_key: Some(secret_key0.to_vec()),
..Default::default()
};
let mut configs = Vec::with_capacity(n);
let mut configs = Vec::with_capacity(number_of_configs);
configs.push(config0);
for port in ports.iter() {
configs.push(NetworkConfig {
Expand Down Expand Up @@ -191,7 +188,8 @@ where
{
const BUFFER_SIZE: usize = 1000;

let mut channels_configs = create_connected_network_configs(n_configs + 1, available_ports);
let ports = available_ports.get_next_ports(n_configs + 1);
let mut channels_configs = create_connected_network_configs(ports);
let broadcast_channels = channels_configs.pop().unwrap();

let mut channels_network_manager = NetworkManager::new(broadcast_channels, None);
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ pub fn create_mempool_p2p_configs(
chain_id: ChainId,
available_ports: &mut AvailablePorts,
) -> Vec<MempoolP2pConfig> {
create_connected_network_configs(n_mempools, available_ports)
let ports = available_ports.get_next_ports(n_mempools);
create_connected_network_configs(ports)
.into_iter()
.map(|mut network_config| {
network_config.chain_id = chain_id.clone();
Expand Down

0 comments on commit fea9f6a

Please sign in to comment.