@@ -46,6 +46,7 @@ use crate::orchestrator_versioned_constants::VersionedConstants;
4646use crate :: test_utils:: {
4747 block_info,
4848 create_test_and_network_deps,
49+ SetupDepsArgs ,
4950 ETH_TO_FRI_RATE ,
5051 INTERNAL_TX_BATCH ,
5152 STATE_DIFF_COMMITMENT ,
@@ -74,7 +75,7 @@ async fn cancelled_proposal_aborts() {
7475#[ tokio:: test]
7576async fn validate_proposal_success ( ) {
7677 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
77- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
78+ deps. setup_deps_for_validate ( SetupDepsArgs :: default ( ) ) ;
7879 let mut context = deps. build_context ( ) ;
7980
8081 // Initialize the context for a specific height, starting with round 0.
@@ -137,8 +138,8 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
137138 true => TX_BATCH . to_vec ( ) ,
138139 false => TX_BATCH . iter ( ) . take ( TX_BATCH . len ( ) - 1 ) . cloned ( ) . collect ( ) ,
139140 } ;
140- let final_n_executed_txs = executed_transactions. len ( ) ;
141- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , final_n_executed_txs , 1 ) ;
141+ let n_executed_txs_count = executed_transactions. len ( ) ;
142+ deps. setup_deps_for_validate ( SetupDepsArgs { n_executed_txs_count , .. Default :: default ( ) } ) ;
142143 let mut context = deps. build_context ( ) ;
143144
144145 // Initialize the context for a specific height, starting with round 0.
@@ -153,7 +154,7 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
153154 ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) ;
154155 content_sender. send ( transactions. clone ( ) ) . await . unwrap ( ) ;
155156 content_sender
156- . send ( ProposalPart :: ExecutedTransactionCount ( final_n_executed_txs . try_into ( ) . unwrap ( ) ) )
157+ . send ( ProposalPart :: ExecutedTransactionCount ( n_executed_txs_count . try_into ( ) . unwrap ( ) ) )
157158 . await
158159 . unwrap ( ) ;
159160 let fin = ProposalPart :: Fin ( ProposalFin {
@@ -176,7 +177,7 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
176177 ) ;
177178 assert_eq ! (
178179 receiver. next( ) . await . unwrap( ) ,
179- ProposalPart :: ExecutedTransactionCount ( final_n_executed_txs . try_into( ) . unwrap( ) )
180+ ProposalPart :: ExecutedTransactionCount ( n_executed_txs_count . try_into( ) . unwrap( ) )
180181 ) ;
181182 assert_eq ! ( receiver. next( ) . await . unwrap( ) , fin) ;
182183 assert ! ( receiver. next( ) . await . is_none( ) ) ;
@@ -185,7 +186,7 @@ async fn validate_then_repropose(#[case] execute_all_txs: bool) {
185186#[ tokio:: test]
186187async fn proposals_from_different_rounds ( ) {
187188 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
188- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
189+ deps. setup_deps_for_validate ( SetupDepsArgs :: default ( ) ) ;
189190 let mut context = deps. build_context ( ) ;
190191 // Initialize the context for a specific height, starting with round 0.
191192 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await . unwrap ( ) ;
@@ -245,7 +246,7 @@ async fn proposals_from_different_rounds() {
245246#[ tokio:: test]
246247async fn interrupt_active_proposal ( ) {
247248 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
248- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
249+ deps. setup_deps_for_validate ( SetupDepsArgs :: default ( ) ) ;
249250 let mut context = deps. build_context ( ) ;
250251 // Initialize the context for a specific height, starting with round 0.
251252 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await . unwrap ( ) ;
@@ -294,7 +295,7 @@ async fn build_proposal() {
294295 let before: u64 =
295296 chrono:: Utc :: now ( ) . timestamp ( ) . try_into ( ) . expect ( "Timestamp conversion failed" ) ;
296297 let ( mut deps, mut network) = create_test_and_network_deps ( ) ;
297- deps. setup_deps_for_build ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
298+ deps. setup_deps_for_build ( SetupDepsArgs :: default ( ) ) ;
298299 let mut context = deps. build_context ( ) ;
299300 let fin_receiver = context. build_proposal ( ProposalInit :: default ( ) , TIMEOUT ) . await . unwrap ( ) ;
300301 // Test proposal parts.
@@ -330,7 +331,7 @@ async fn build_proposal() {
330331async fn build_proposal_skips_write_for_height_0 ( ) {
331332 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
332333
333- deps. setup_deps_for_build ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
334+ deps. setup_deps_for_build ( SetupDepsArgs :: default ( ) ) ;
334335
335336 // Make sure the state sync client isn't called by clearing its expectations.
336337 deps. state_sync_client = MockStateSyncClient :: new ( ) ;
@@ -353,7 +354,7 @@ async fn build_proposal_skips_write_for_height_above_0() {
353354
354355 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
355356
356- deps. setup_deps_for_build ( HEIGHT , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
357+ deps. setup_deps_for_build ( SetupDepsArgs { start_block_number : HEIGHT , .. Default :: default ( ) } ) ;
357358
358359 // We already have the previous block in sync:
359360 deps. state_sync_client
@@ -380,7 +381,7 @@ async fn build_proposal_writes_prev_blob_if_cannot_get_latest_block_number() {
380381
381382 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
382383
383- deps. setup_deps_for_build ( HEIGHT , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
384+ deps. setup_deps_for_build ( SetupDepsArgs { start_block_number : HEIGHT , .. Default :: default ( ) } ) ;
384385
385386 deps. state_sync_client . expect_get_latest_block_number ( ) . returning ( || {
386387 Err ( StateSyncClientError :: ClientError ( ClientError :: CommunicationFailure ( "" . to_string ( ) ) ) )
@@ -412,7 +413,7 @@ async fn build_proposal_cende_failure() {
412413 const HEIGHT : BlockNumber = BlockNumber ( 9 ) ;
413414
414415 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
415- deps. setup_deps_for_build ( HEIGHT , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
416+ deps. setup_deps_for_build ( SetupDepsArgs { start_block_number : HEIGHT , .. Default :: default ( ) } ) ;
416417 // We do not have the previous block in sync, so we must try to write the previous height blob.
417418 deps. state_sync_client
418419 . expect_get_latest_block_number ( )
@@ -443,7 +444,7 @@ async fn build_proposal_cende_incomplete() {
443444 const HEIGHT : BlockNumber = BlockNumber ( 9 ) ;
444445
445446 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
446- deps. setup_deps_for_build ( HEIGHT , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
447+ deps. setup_deps_for_build ( SetupDepsArgs { start_block_number : HEIGHT , .. Default :: default ( ) } ) ;
447448 // We do not have the previous block in sync, so we must try to write the previous height blob.
448449 deps. state_sync_client
449450 . expect_get_latest_block_number ( )
@@ -510,7 +511,10 @@ async fn propose_then_repropose(#[case] execute_all_txs: bool) {
510511 true => TX_BATCH . to_vec ( ) ,
511512 false => TX_BATCH . iter ( ) . take ( TX_BATCH . len ( ) - 1 ) . cloned ( ) . collect ( ) ,
512513 } ;
513- deps. setup_deps_for_build ( BlockNumber ( 0 ) , transactions. len ( ) , 1 ) ;
514+ deps. setup_deps_for_build ( SetupDepsArgs {
515+ n_executed_txs_count : transactions. len ( ) ,
516+ ..Default :: default ( )
517+ } ) ;
514518 let mut context = deps. build_context ( ) ;
515519 // Build proposal.
516520 let fin_receiver = context. build_proposal ( ProposalInit :: default ( ) , TIMEOUT ) . await . unwrap ( ) ;
@@ -576,7 +580,7 @@ async fn eth_to_fri_rate_out_of_range() {
576580#[ tokio:: test]
577581async fn gas_price_limits ( #[ case] maximum : bool ) {
578582 let ( mut deps, _network) = create_test_and_network_deps ( ) ;
579- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
583+ deps. setup_deps_for_validate ( SetupDepsArgs :: default ( ) ) ;
580584 let context_config = ContextDynamicConfig :: default ( ) ;
581585 let min_gas_price = context_config. min_l1_gas_price_wei ;
582586 let min_data_price = context_config. min_l1_data_gas_price_wei ;
@@ -649,7 +653,7 @@ async fn decision_reached_sends_correct_values() {
649653 // We need to create a valid proposal to call decision_reached on.
650654 //
651655 // 1. Build proposal setup starts.
652- deps. setup_deps_for_build ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
656+ deps. setup_deps_for_build ( SetupDepsArgs :: default ( ) ) ;
653657
654658 const BLOCK_TIME_STAMP_SECONDS : u64 = 123456 ;
655659 let mut clock = MockClock :: new ( ) ;
@@ -699,7 +703,7 @@ async fn decision_reached_sends_correct_values() {
699703#[ tokio:: test]
700704async fn oracle_fails_on_startup ( #[ case] l1_oracle_failure : bool ) {
701705 let ( mut deps, mut network) = create_test_and_network_deps ( ) ;
702- deps. setup_deps_for_build ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
706+ deps. setup_deps_for_build ( SetupDepsArgs :: default ( ) ) ;
703707
704708 if l1_oracle_failure {
705709 let mut l1_prices_oracle_client = MockL1GasPriceProviderClient :: new ( ) ;
@@ -774,8 +778,11 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
774778 let ( mut deps, mut network) = create_test_and_network_deps ( ) ;
775779 // Validate block number 0, call decision_reached to save the previous block info (block 0), and
776780 // attempt to build_proposal on block number 1.
777- deps. setup_deps_for_validate ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
778- deps. setup_deps_for_build ( BlockNumber ( 1 ) , INTERNAL_TX_BATCH . len ( ) , 1 ) ;
781+ deps. setup_deps_for_validate ( SetupDepsArgs :: default ( ) ) ;
782+ deps. setup_deps_for_build ( SetupDepsArgs {
783+ start_block_number : BlockNumber ( 1 ) ,
784+ ..Default :: default ( )
785+ } ) ;
779786
780787 // set up batcher decision_reached
781788 deps. batcher . expect_decision_reached ( ) . times ( 1 ) . return_once ( |_| {
@@ -971,7 +978,15 @@ async fn override_prices_behavior(
971978
972979 // Setup dependencies and mocks.
973980 #[ allow( clippy:: as_conversions) ]
974- deps. setup_deps_for_build ( BlockNumber ( 0 ) , INTERNAL_TX_BATCH . len ( ) , build_success as usize ) ;
981+ deps. setup_deps_for_build ( SetupDepsArgs {
982+ number_of_times : build_success as usize ,
983+ ..Default :: default ( )
984+ } ) ;
985+ if !build_success {
986+ // We use number_of_times equal zero in this case, but we still expect the start height to
987+ // be called.
988+ deps. batcher . expect_start_height ( ) . times ( 1 ) . return_once ( |_| Ok ( ( ) ) ) ;
989+ }
975990 deps. l1_gas_price_provider . expect_get_eth_to_fri_rate ( ) . returning ( |_| Ok ( ETH_TO_FRI_RATE ) ) ;
976991 deps. batcher . expect_decision_reached ( ) . return_once ( move |_| {
977992 Ok ( DecisionReachedResponse {
0 commit comments