Skip to content

Commit

Permalink
refactor(starknet_integration_tests): rename SequencerSetupManager (s…
Browse files Browse the repository at this point in the history
…tarkware-libs#3462)

* refactor(starknet_integration_tests): rename SequencerSetup

commit-id:87c8d1a8

* refactor(starknet_integration_tests): rename SequencerSetupManager

commit-id:50b87cd4
  • Loading branch information
nadin-Starkware authored Jan 19, 2025
1 parent 48f23ca commit 7939fe8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 8 additions & 6 deletions crates/starknet_integration_tests/src/end_to_end_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use starknet_api::block::BlockNumber;
use starknet_sequencer_node::test_utils::node_runner::get_node_executable_path;
use tracing::info;

use crate::sequencer_manager::{get_sequencer_setup_configs, SequencerSetupManager};
use crate::sequencer_manager::{get_sequencer_setup_configs, IntegrationTestManager};

pub async fn end_to_end_integration(tx_generator: MultiAccountTransactionGenerator) {
const EXPECTED_BLOCK_NUMBER: BlockNumber = BlockNumber(15);
Expand All @@ -20,16 +20,18 @@ pub async fn end_to_end_integration(tx_generator: MultiAccountTransactionGenerat
// Run the sequencers.
// TODO(Nadin, Tsabary): Refactor to separate the construction of SequencerManager from its
// invocation. Consider using the builder pattern.
let sequencer_manager = SequencerSetupManager::run(sequencers_setup).await;
let integration_test_manager = IntegrationTestManager::run(sequencers_setup).await;

// Run the integration test simulator.
sequencer_manager.run_integration_test_simulator(tx_generator, N_TXS, SENDER_ACCOUNT).await;
integration_test_manager
.run_integration_test_simulator(tx_generator, N_TXS, SENDER_ACCOUNT)
.await;

sequencer_manager.await_execution(EXPECTED_BLOCK_NUMBER).await;
integration_test_manager.await_execution(EXPECTED_BLOCK_NUMBER).await;

info!("Shutting down nodes.");
sequencer_manager.shutdown_nodes();
integration_test_manager.shutdown_nodes();

// Verify the results.
sequencer_manager.verify_results(sender_address, N_TXS).await;
integration_test_manager.verify_results(sender_address, N_TXS).await;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl From<SequencerExecutionId> for NodeRunner {
}
}

pub struct SequencerSetup {
pub struct ExecutableSetup {
// Sequencer test identifier.
pub sequencer_execution_id: SequencerExecutionId,
// Client for adding transactions to the sequencer node.
Expand All @@ -73,7 +73,7 @@ pub struct SequencerSetup {

// TODO(Tsabary/ Nadin): reduce number of args.
#[allow(clippy::too_many_arguments)]
impl SequencerSetup {
impl ExecutableSetup {
#[instrument(skip(accounts, chain_info, consensus_manager_config), level = "debug")]
pub async fn new(
accounts: Vec<AccountTransactionGenerator>,
Expand Down
16 changes: 8 additions & 8 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use starknet_types_core::felt::Felt;
use tokio::task::JoinHandle;
use tracing::info;

use crate::integration_test_setup::{SequencerExecutionId, SequencerSetup};
use crate::integration_test_setup::{ExecutableSetup, SequencerExecutionId};
use crate::utils::{
create_chain_info,
create_consensus_manager_configs_from_network_configs,
Expand Down Expand Up @@ -64,13 +64,13 @@ impl ComposedComponentConfigs {
}
}

pub struct SequencerSetupManager {
pub sequencers: Vec<SequencerSetup>,
pub struct IntegrationTestManager {
pub sequencers: Vec<ExecutableSetup>,
pub sequencer_run_handles: Vec<JoinHandle<()>>,
}

impl SequencerSetupManager {
pub async fn run(sequencers: Vec<SequencerSetup>) -> Self {
impl IntegrationTestManager {
pub async fn run(sequencers: Vec<ExecutableSetup>) -> Self {
info!("Running sequencers.");
let sequencer_run_handles = sequencers
.iter()
Expand Down Expand Up @@ -192,7 +192,7 @@ async fn await_block(

pub(crate) async fn get_sequencer_setup_configs(
tx_generator: &MultiAccountTransactionGenerator,
) -> Vec<SequencerSetup> {
) -> Vec<ExecutableSetup> {
let test_unique_id = TestIdentifier::EndToEndIntegrationTest;

// TODO(Nadin): Assign a dedicated set of available ports to each sequencer.
Expand Down Expand Up @@ -224,7 +224,7 @@ pub(crate) async fn get_sequencer_setup_configs(
);

// TODO(Nadin): define the test storage here and pass it to the create_state_sync_configs and to
// the SequencerSetup
// the ExecutableSetup
let state_sync_configs = create_state_sync_configs(
StorageConfig::default(),
available_ports.get_next_ports(n_distributed_sequencers),
Expand Down Expand Up @@ -275,7 +275,7 @@ pub(crate) async fn get_sequencer_setup_configs(
)| {
let chain_info = chain_info.clone();
async move {
SequencerSetup::new(
ExecutableSetup::new(
accounts.to_vec(),
sequencer_execution_id,
chain_info,
Expand Down

0 comments on commit 7939fe8

Please sign in to comment.