Skip to content

Commit

Permalink
chore(starknet_integration_tests): move verify_tx_accepted to monitor…
Browse files Browse the repository at this point in the history
…ing_utils

commit-id:6fcff9f6
  • Loading branch information
nadin-Starkware committed Feb 9, 2025
1 parent fb193d2 commit ed855e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
17 changes: 17 additions & 0 deletions crates/starknet_integration_tests/src/monitoring_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ pub async fn await_execution(node: &NodeSetup, expected_block_number: BlockNumbe
.await
.expect("Block number should have been reached.");
}

pub async fn verify_txs_accepted(
monitoring_client: &MonitoringClient,
sequencer_idx: usize,
expected_n_batched_txs: usize,
) {
info!("Verifying that sequencer {sequencer_idx} got {expected_n_batched_txs} batched txs.");
let n_batched_txs = monitoring_client
.get_metric::<usize>(metric_definitions::BATCHED_TRANSACTIONS.get_name())
.await
.expect("Failed to get batched txs metric.");
assert_eq!(
n_batched_txs, expected_n_batched_txs,
"Sequencer {sequencer_idx} got an unexpected number of batched txs. Expected \
{expected_n_batched_txs} got {n_batched_txs}"
);
}
13 changes: 2 additions & 11 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tokio::task::JoinHandle;
use tracing::info;

use crate::integration_test_setup::{ExecutableSetup, NodeExecutionId};
use crate::monitoring_utils::await_execution;
use crate::monitoring_utils::{await_execution, verify_txs_accepted};
use crate::utils::{
create_chain_info,
create_consensus_manager_configs_from_network_configs,
Expand Down Expand Up @@ -315,16 +315,7 @@ impl IntegrationTestManager {
let (sequencer_idx, monitoring_client) = self.running_batcher_monitoring_client();
let account = self.tx_generator.account_with_id(sender_account);
let expected_n_batched_txs = nonce_to_usize(account.get_nonce());
info!("Verifying that sequencer {sequencer_idx} got {expected_n_batched_txs} batched txs.");
let n_batched_txs = monitoring_client
.get_metric::<usize>(metric_definitions::BATCHED_TRANSACTIONS.get_name())
.await
.expect("Failed to get batched txs metric.");
assert_eq!(
n_batched_txs, expected_n_batched_txs,
"Sequencer {sequencer_idx} got an unexpected number of batched txs. Expected \
{expected_n_batched_txs} got {n_batched_txs}"
);
verify_txs_accepted(monitoring_client, sequencer_idx, expected_n_batched_txs).await;
}
}

Expand Down

0 comments on commit ed855e5

Please sign in to comment.