Skip to content

Commit

Permalink
refactor(starknet_integration_tests): add test and verify function
Browse files Browse the repository at this point in the history
commit-id:847cf988
  • Loading branch information
nadin-Starkware committed Jan 15, 2025
1 parent a00727a commit bce05e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/starknet_integration_tests/src/end_to_end_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ pub async fn end_to_end_integration(tx_generator: &mut MultiAccountTransactionGe
// invocation. Consider using the builder pattern.
let sequencer_manager = SequencerSetupManager::run(sequencers_setup).await;

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

sequencer_manager.await_execution(EXPECTED_BLOCK_NUMBER).await;
// Run the integration test simulator and verify the results.
sequencer_manager
.test_and_verify(tx_generator, N_TXS, SENDER_ACCOUNT, sender_address, EXPECTED_BLOCK_NUMBER)
.await;

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

// Verify the results.
sequencer_manager.verify_results(sender_address, N_TXS).await;
}
13 changes: 13 additions & 0 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ pub struct SequencerSetupManager {
}

impl SequencerSetupManager {
pub async fn test_and_verify(
&self,
tx_generator: &mut MultiAccountTransactionGenerator,
n_txs: usize,
sender_account: AccountId,
sender_address: ContractAddress,
expected_block_number: BlockNumber,
) {
self.run_integration_test_simulator(tx_generator, n_txs, sender_account).await;
self.await_execution(expected_block_number).await;
self.verify_results(sender_address, n_txs).await;
}

pub async fn run(sequencers: Vec<SequencerSetup>) -> Self {
info!("Running sequencers.");
let sequencer_run_handles = sequencers
Expand Down

0 comments on commit bce05e4

Please sign in to comment.