Skip to content

Commit

Permalink
chore(starknet_integration_tests): add verify_txs_accepted impl for t…
Browse files Browse the repository at this point in the history
…he simulator

commit-id:03dfa5c0
  • Loading branch information
nadin-Starkware committed Feb 13, 2025
1 parent 1d68e28 commit 899dc3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ async fn main() -> anyhow::Result<()> {

sequencer_simulator.await_execution(EXPECTED_BLOCK_NUMBER).await;

// TODO(Nadin): verfy txs are accepted.
// TODO(Nadin): pass node index as an argument.
sequencer_simulator.verify_txs_accepted(0, &mut tx_generator, SENDER_ACCOUNT).await;

info!("Simulation completed successfully");

Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl IntegrationTestManager {
}
}

fn nonce_to_usize(nonce: Nonce) -> usize {
pub fn nonce_to_usize(nonce: Nonce) -> usize {
let prefixed_hex = nonce.0.to_hex_string();
let unprefixed_hex = prefixed_hex.split_once("0x").unwrap().1;
usize::from_str_radix(unprefixed_hex, 16).unwrap()
Expand Down
22 changes: 19 additions & 3 deletions crates/starknet_integration_tests/src/sequencer_simulator_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use starknet_sequencer_node::utils::load_and_validate_config;
use tracing::info;

use crate::monitoring_utils;
use crate::sequencer_manager::nonce_to_usize;
use crate::utils::{send_account_txs, TestScenario};

pub struct SequencerSimulator {
Expand Down Expand Up @@ -55,8 +56,23 @@ impl SequencerSimulator {
.await;
}

// TODO(Nadin): Implement this function.
pub async fn verify_txs_accepted(&self) {
unimplemented!();
pub async fn verify_txs_accepted(
&self,
sequencer_idx: usize,
tx_generator: &mut MultiAccountTransactionGenerator,
sender_account: AccountId,
) {
let account = tx_generator.account_with_id(sender_account);
let expected_n_batched_txs = nonce_to_usize(account.get_nonce());
info!(
"Verifying that sequencer {} got {} batched txs.",
sequencer_idx, expected_n_batched_txs
);
monitoring_utils::verify_txs_accepted(
&self.monitoring_client,
sequencer_idx,
expected_n_batched_txs,
)
.await;
}
}

0 comments on commit 899dc3f

Please sign in to comment.