Skip to content

Commit

Permalink
chore(starknet_integration_tests): add test identifier
Browse files Browse the repository at this point in the history
commit-id:8cca3def
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 18, 2024
1 parent b12e2cb commit d97f6d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ use starknet_types_core::felt::Felt;
use tracing::info;

use crate::integration_test_setup::IntegrationTestSetup;
use crate::test_identifiers::TestIdentifier;
use crate::utils::send_account_txs;

// TODO(Tsabary): create an enum that maps test names to unique indices, replace constants.
const END_TO_END_INTEGRATION_TEST_UNIQUE_ID: u16 = 0;

/// Reads the latest block number from the storage.
fn get_latest_block_number(storage_reader: &StorageReader) -> BlockNumber {
let txn = storage_reader.begin_ro_txn().unwrap();
Expand Down Expand Up @@ -67,7 +65,7 @@ pub async fn end_to_end_integration(mut tx_generator: MultiAccountTransactionGen
// Creating the storage for the test.
let integration_test_setup = IntegrationTestSetup::new_from_tx_generator(
&tx_generator,
END_TO_END_INTEGRATION_TEST_UNIQUE_ID,
TestIdentifier::EndToEndIntegrationTest.into(),
)
.await;

Expand Down
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pub mod end_to_end_integration;
pub mod flow_test_setup;
pub mod integration_test_setup;
pub mod state_reader;
pub mod test_identifiers;
pub mod utils;
14 changes: 14 additions & 0 deletions crates/starknet_integration_tests/src/test_identifiers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[derive(Debug)]
pub enum TestIdentifier {
EndToEndIntegrationTest,
EndToEndFlowTest,
}

impl From<TestIdentifier> for u16 {
fn from(variant: TestIdentifier) -> Self {
match variant {
TestIdentifier::EndToEndIntegrationTest => 0,
TestIdentifier::EndToEndFlowTest => 1,
}
}
}
11 changes: 6 additions & 5 deletions crates/starknet_integration_tests/tests/end_to_end_flow_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rstest::{fixture, rstest};
use starknet_api::block::{BlockHash, BlockNumber};
use starknet_api::transaction::TransactionHash;
use starknet_integration_tests::flow_test_setup::{FlowTestSetup, SequencerSetup};
use starknet_integration_tests::test_identifiers::TestIdentifier;
use starknet_integration_tests::utils::{
create_integration_test_tx_generator,
run_integration_test_scenario,
Expand All @@ -28,9 +29,6 @@ use tracing::debug;
const INITIAL_HEIGHT: BlockNumber = BlockNumber(0);
const LAST_HEIGHT: BlockNumber = BlockNumber(2);

// TODO(Tsabary): create an enum that maps test names to unique indices, replace constants.
const END_TO_END_FLOW_TEST_UNIQUE_ID: u16 = 1;

#[fixture]
fn tx_generator() -> MultiAccountTransactionGenerator {
create_integration_test_tx_generator()
Expand All @@ -44,8 +42,11 @@ async fn end_to_end_flow(mut tx_generator: MultiAccountTransactionGenerator) {
const LISTEN_TO_BROADCAST_MESSAGES_TIMEOUT: std::time::Duration =
std::time::Duration::from_secs(50);
// Setup.
let mut mock_running_system =
FlowTestSetup::new_from_tx_generator(&tx_generator, END_TO_END_FLOW_TEST_UNIQUE_ID).await;
let mut mock_running_system = FlowTestSetup::new_from_tx_generator(
&tx_generator,
TestIdentifier::EndToEndFlowTest.into(),
)
.await;

tokio::join!(
wait_for_sequencer_node(&mock_running_system.sequencer_0),
Expand Down

0 comments on commit d97f6d7

Please sign in to comment.