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

refactor(starknet_integration_tests): remove node_setup arg from monitoring_utils functions #4027

Open
wants to merge 1 commit into
base: spr/main/6fcff9f6
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
33 changes: 22 additions & 11 deletions crates/starknet_integration_tests/src/monitoring_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use starknet_monitoring_endpoint::test_utils::MonitoringClient;
use starknet_sequencer_metrics::metric_definitions;
use tracing::info;

use crate::sequencer_manager::NodeSetup;

/// Gets the latest block number from the batcher's metrics.
pub async fn get_batcher_latest_block_number(
batcher_monitoring_client: &MonitoringClient,
Expand All @@ -27,19 +25,20 @@ pub async fn await_batcher_block(
interval: u64,
target_block_number: BlockNumber,
max_attempts: usize,
node: &NodeSetup,
batcher_monitoring_client: &MonitoringClient,
node_index: usize,
batcher_index: usize,
) -> Result<BlockNumber, ()> {
let condition = |&latest_block_number: &BlockNumber| latest_block_number >= target_block_number;
let get_latest_block_number_closure =
|| get_batcher_latest_block_number(node.batcher_monitoring_client());
|| get_batcher_latest_block_number(batcher_monitoring_client);

let logger = CustomLogger::new(
TraceLevel::Info,
Some(format!(
"Waiting for batcher height metric to reach block {target_block_number} in sequencer \
{} executable {}.",
node.get_node_index().unwrap(),
node.get_batcher_index()
node_index, batcher_index
)),
);

Expand All @@ -48,14 +47,26 @@ pub async fn await_batcher_block(
.ok_or(())
}

pub async fn await_execution(node: &NodeSetup, expected_block_number: BlockNumber) {
pub async fn await_execution(
monitoring_client: &MonitoringClient,
expected_block_number: BlockNumber,
node_index: usize,
batcher_index: usize,
) {
info!(
"Awaiting until {expected_block_number} blocks have been created in sequencer {}.",
node.get_node_index().unwrap()
node_index
);
await_batcher_block(5000, expected_block_number, 50, node)
.await
.expect("Block number should have been reached.");
await_batcher_block(
5000,
expected_block_number,
50,
monitoring_client,
node_index,
batcher_index,
)
.await
.expect("Block number should have been reached.");
}

pub async fn verify_txs_accepted(
Expand Down
9 changes: 8 additions & 1 deletion crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,14 @@ 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;
monitoring_utils::await_execution(&running_node.node_setup, expected_block_number).await;
let running_node_setup = &running_node.node_setup;
monitoring_utils::await_execution(
running_node_setup.batcher_monitoring_client(),
expected_block_number,
running_node_setup.get_node_index().unwrap(),
running_node_setup.get_batcher_index(),
)
.await;
}

async fn verify_txs_accepted(&self, sender_account: AccountId) {
Expand Down