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): move verify_tx_accepted to monitor… #4026

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
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}"
);
}
21 changes: 8 additions & 13 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use starknet_infra_utils::test_utils::{
MAX_NUMBER_OF_INSTANCES_PER_TEST,
};
use starknet_monitoring_endpoint::test_utils::MonitoringClient;
use starknet_sequencer_metrics::metric_definitions;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::config::component_execution_config::{
ActiveComponentExecutionConfig,
Expand All @@ -28,7 +27,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;
use crate::utils::{
create_chain_info,
create_consensus_manager_configs_from_network_configs,
Expand Down Expand Up @@ -308,23 +307,19 @@ impl IntegrationTestManager {
async fn await_execution(&self, expected_block_number: BlockNumber) {
let running_node =
self.running_nodes.iter().next().expect("At least one node should be running").1;
await_execution(&running_node.node_setup, expected_block_number).await;
monitoring_utils::await_execution(&running_node.node_setup, expected_block_number).await;
}

async fn verify_txs_accepted(&self, sender_account: AccountId) {
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}"
);
monitoring_utils::verify_txs_accepted(
monitoring_client,
sequencer_idx,
expected_n_batched_txs,
)
.await;
}
}

Expand Down
Loading