Skip to content

Commit

Permalink
chore(starknet_integration_tests): add available ports to network config
Browse files Browse the repository at this point in the history
commit-id:f09b3b07
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 18, 2024
1 parent d97f6d7 commit 0e171d0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/papyrus_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository.workspace = true
license-file.workspace = true

[features]
testing = []
testing = ["starknet_sequencer_infra/testing"]

[dependencies]
async-stream.workspace = true
Expand Down Expand Up @@ -35,6 +35,7 @@ papyrus_network_types.workspace = true
replace_with.workspace = true
serde = { workspace = true, features = ["derive"] }
starknet_api.workspace = true
starknet_sequencer_infra = { workspace = true, optional = true, features = ["testing"] }
thiserror.workspace = true
tokio = { workspace = true, features = ["full", "sync"] }
tokio-retry.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_network/src/network_manager/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use libp2p::gossipsub::SubscriptionError;
use libp2p::identity::Keypair;
use libp2p::{Multiaddr, PeerId};
use papyrus_common::tcp::find_n_free_ports;
use starknet_sequencer_infra::test_utils::AvailablePorts;

use super::{
BroadcastTopicClient,
Expand Down Expand Up @@ -177,9 +178,12 @@ pub fn create_connected_network_configs(n: usize) -> Vec<NetworkConfig> {
configs
}

// TODO(Tsabary): remove #[allow(unused_variables)].
#[allow(unused_variables)]
pub fn create_network_configs_connected_to_broadcast_channels<T>(
n_configs: usize,
topic: Topic,
available_ports: &mut AvailablePorts,
) -> (Vec<NetworkConfig>, BroadcastTopicChannels<T>)
where
T: TryFrom<Bytes> + 'static,
Expand Down
10 changes: 7 additions & 3 deletions crates/starknet_integration_tests/src/flow_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ impl FlowTestSetup {
test_unique_index: u16,
) -> Self {
let chain_info = create_chain_info();
let mut available_ports = AvailablePorts::new(test_unique_index, 0);

let accounts = tx_generator.accounts();
let (consensus_manager_configs, consensus_proposals_channels) =
create_consensus_manager_configs_and_channels(SEQUENCER_INDICES.len());
create_consensus_manager_configs_and_channels(
SEQUENCER_INDICES.len(),
&mut available_ports,
);
let [sequencer_0_consensus_manager_config, sequencer_1_consensus_manager_config]: [ConsensusManagerConfig;
2] = consensus_manager_configs.try_into().unwrap();

Expand All @@ -66,7 +70,7 @@ impl FlowTestSetup {
chain_info.clone(),
sequencer_0_consensus_manager_config,
sequencer_0_mempool_p2p_config,
AvailablePorts::new(test_unique_index, 0),
AvailablePorts::new(test_unique_index, 1),
)
.await;
let sequencer_1 = SequencerSetup::new(
Expand All @@ -75,7 +79,7 @@ impl FlowTestSetup {
chain_info,
sequencer_1_consensus_manager_config,
sequencer_1_mempool_p2p_config,
AvailablePorts::new(test_unique_index, 1),
AvailablePorts::new(test_unique_index, 2),
)
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ impl IntegrationTestSetup {
.await;

let (mut consensus_manager_configs, _consensus_proposals_channels) =
create_consensus_manager_configs_and_channels(SEQUENCER_INDICES.len());
create_consensus_manager_configs_and_channels(
SEQUENCER_INDICES.len(),
&mut available_ports,
);
let mut mempool_p2p_configs =
create_mempool_p2p_configs(SEQUENCER_INDICES.len(), chain_info.chain_id.clone());

Expand Down
2 changes: 2 additions & 0 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ pub async fn create_config(

pub fn create_consensus_manager_configs_and_channels(
n_managers: usize,
available_ports: &mut AvailablePorts,
) -> (Vec<ConsensusManagerConfig>, BroadcastTopicChannels<StreamMessage<ProposalPart>>) {
let (network_configs, broadcast_channels) =
create_network_configs_connected_to_broadcast_channels(
n_managers,
papyrus_network::gossipsub_impl::Topic::new(
starknet_consensus_manager::consensus_manager::CONSENSUS_PROPOSALS_TOPIC,
),
available_ports,
);
// TODO: Need to also add a channel for votes, in addition to the proposals channel.

Expand Down

0 comments on commit 0e171d0

Please sign in to comment.