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): await batcher block more configurable #4323

Open
wants to merge 1 commit into
base: noam.s/refactor_starknet_integration_tests_add_unique_test_ids
Choose a base branch
from
Open
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
39 changes: 16 additions & 23 deletions crates/starknet_integration_tests/src/monitoring_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,14 @@ pub async fn get_batcher_latest_block_number(
/// error if after the given number of attempts the target block number has not been reached.
pub async fn await_batcher_block(
interval: u64,
target_block_number: BlockNumber,
condition: impl Fn(&BlockNumber) -> bool + Send + Sync,
max_attempts: usize,
batcher_monitoring_client: &MonitoringClient,
node_index: usize,
batcher_index: usize,
logger: CustomLogger,
) -> 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(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_index, batcher_index
)),
);

run_until(interval, max_attempts, get_latest_block_number_closure, condition, Some(logger))
.await
.ok_or(())
Expand All @@ -57,16 +46,20 @@ pub async fn await_execution(
"Awaiting until {expected_block_number} blocks have been created in sequencer {}.",
node_index
);
await_batcher_block(
5000,
expected_block_number,
50,
monitoring_client,
node_index,
batcher_index,
)
.await
.expect("Block number should have been reached.");
let condition =
|&latest_block_number: &BlockNumber| latest_block_number >= expected_block_number;

let logger = CustomLogger::new(
TraceLevel::Info,
Some(format!(
"Waiting for batcher height metric to reach block {expected_block_number} in \
sequencer {} executable {}.",
node_index, batcher_index
)),
);
await_batcher_block(5000, condition, 50, monitoring_client, logger)
.await
.expect("Block number should have been reached.");
}

pub async fn verify_txs_accepted(
Expand Down
Loading