Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bharath-123 committed Aug 30, 2024
1 parent a5a8f76 commit fece56c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
34 changes: 24 additions & 10 deletions crates/astria-composer/src/executor/tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::{
io::Write,
sync::mpsc,
time::Duration,
};

use astria_core::{
generated::{
composer::v1alpha1::BuilderBundlePacket,
protocol::account::v1alpha1::NonceResponse,
protocol::accounts::v1alpha1::NonceResponse,
sequencerblock::v1alpha1 as raw_sequencer,
},
primitive::v1::{
Expand Down Expand Up @@ -73,6 +74,10 @@ use crate::{
},
mount_executed_block,
mount_get_commitment_state,
sequencer_hooks::{
FinalizedHashInfo,
OptimisticBlockInfo,
},
test_utils::sequence_action_of_max_size,
Config,
};
Expand Down Expand Up @@ -323,10 +328,12 @@ async fn full_bundle() {
// set up the executor, channel for writing seq actions, and the sequencer mock
let (sequencer, cfg, _keyfile, test_executor) = setup().await;
let shutdown_token = CancellationToken::new();
let (filtered_block_sender, filtered_block_receiver) =
tokio::sync::mpsc::channel::<OptimisticBlockInfo>(10);
let (finalized_hash_sender, finalized_hash_receiver) =
tokio::sync::mpsc::channel::<FinalizedHashInfo>(10);
let metrics = Box::leak(Box::new(Metrics::new(cfg.rollup.as_str())));
mount_genesis(&sequencer, &cfg.sequencer_chain_id).await;
let (_filtered_block_sender, filtered_block_receiver) = tokio::sync::mpsc::channel(1);
let (_finalized_hash_sender, finalized_hash_receiver) = tokio::sync::mpsc::channel(1);
let (executor, executor_handle) = executor::Builder {
sequencer_url: cfg.sequencer_url.clone(),
sequencer_chain_id: cfg.sequencer_chain_id.clone(),
Expand Down Expand Up @@ -382,7 +389,7 @@ async fn full_bundle() {
..sequence_action_of_max_size(cfg.max_bytes_per_bundle)
};

let rollup_data: Vec<raw_sequencer::RollupData> = vec![seq0.clone()]
let rollup_data: Vec<raw_sequencer::RollupData> = vec![seq0.clone(), seq1.clone()]
.iter()
.map(|item| RollupData::SequencedData(item.clone().data).to_raw())
.collect();
Expand Down Expand Up @@ -474,10 +481,12 @@ async fn bundle_triggered_by_block_timer() {
// set up the executor, channel for writing seq actions, and the sequencer mock
let (sequencer, cfg, _keyfile, test_executor) = setup().await;
let shutdown_token = CancellationToken::new();
let (filtered_block_sender, filtered_block_receiver) =
tokio::sync::mpsc::channel::<OptimisticBlockInfo>(10);
let (finalized_hash_sender, finalized_hash_receiver) =
tokio::sync::mpsc::channel::<FinalizedHashInfo>(10);
let metrics = Box::leak(Box::new(Metrics::new(cfg.rollup.as_str())));
mount_genesis(&sequencer, &cfg.sequencer_chain_id).await;
let (_filtered_block_sender, filtered_block_receiver) = tokio::sync::mpsc::channel(1);
let (_finalized_hash_sender, finalized_hash_receiver) = tokio::sync::mpsc::channel(1);
let (executor, executor_handle) = executor::Builder {
sequencer_url: cfg.sequencer_url.clone(),
sequencer_chain_id: cfg.sequencer_chain_id.clone(),
Expand Down Expand Up @@ -631,8 +640,10 @@ async fn two_seq_actions_single_bundle() {
let shutdown_token = CancellationToken::new();
let metrics = Box::leak(Box::new(Metrics::new(cfg.rollup.as_str())));
mount_genesis(&sequencer, &cfg.sequencer_chain_id).await;
let (_filtered_block_sender, filtered_block_receiver) = tokio::sync::mpsc::channel(1);
let (_finalized_hash_sender, finalized_hash_receiver) = tokio::sync::mpsc::channel(1);
let (filtered_block_sender, filtered_block_receiver) =
tokio::sync::mpsc::channel::<OptimisticBlockInfo>(10);
let (finalized_hash_sender, finalized_hash_receiver) =
tokio::sync::mpsc::channel::<FinalizedHashInfo>(10);
let (executor, executor_handle) = executor::Builder {
sequencer_url: cfg.sequencer_url.clone(),
sequencer_chain_id: cfg.sequencer_chain_id.clone(),
Expand Down Expand Up @@ -788,8 +799,11 @@ async fn chain_id_mismatch_returns_error() {
let metrics = Box::leak(Box::new(Metrics::new(cfg.rollup.as_str())));
let rollup_name = RollupId::new([0; ROLLUP_ID_LEN]);

let (_filtered_block_sender, filtered_block_receiver) = tokio::sync::mpsc::channel(1);
let (_finalized_hash_sender, finalized_hash_receiver) = tokio::sync::mpsc::channel(1);
let (filtered_block_sender, filtered_block_receiver) =
tokio::sync::mpsc::channel::<OptimisticBlockInfo>(10);
let (finalized_hash_sender, finalized_hash_receiver) =
tokio::sync::mpsc::channel::<FinalizedHashInfo>(10);

// mount a status response with an incorrect chain_id
mount_genesis(&sequencer, "bad-chain-id").await;

Expand Down
12 changes: 9 additions & 3 deletions crates/astria-sequencer/src/app/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ pub(crate) async fn initialize_app_with_storage(
let mempool = Mempool::new();
let metrics = Box::leak(Box::new(Metrics::new()));
// TODO - temp addr
let mut app = App::new(snapshot, mempool, "127.0.0.1:232".to_string(), metrics)
.await
.unwrap();
let mut app = App::new(
snapshot,
mempool,
"127.0.0.1:232".to_string(),
false,
metrics,
)
.await
.unwrap();

let genesis_state = genesis_state.unwrap_or_else(self::genesis_state);

Expand Down
1 change: 1 addition & 0 deletions crates/astria-sequencer/src/service/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ mod test {
snapshot,
mempool.clone(),
"127.0.0.1:34".to_string(),
false,
metrics,
)
.await
Expand Down

0 comments on commit fece56c

Please sign in to comment.