Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(starknet_integration_tests): add test identifier #2794

Open
wants to merge 1 commit into
base: spr/main/7d577cc9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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