@@ -46,6 +46,7 @@ use crate::orchestrator_versioned_constants::VersionedConstants;
4646use crate :: test_utils:: {
4747 block_info,
4848 create_test_and_network_deps,
49+ send_proposal_to_validator_context,
4950 SetupDepsArgs ,
5051 ETH_TO_FRI_RATE ,
5152 INTERNAL_TX_BATCH ,
@@ -81,26 +82,10 @@ async fn validate_proposal_success() {
8182 // Initialize the context for a specific height, starting with round 0.
8283 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await . unwrap ( ) ;
8384
84- let ( mut content_sender, content_receiver) =
85- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
86- content_sender. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
87- content_sender
88- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
89- . await
90- . unwrap ( ) ;
91- content_sender
92- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
93- . await
94- . unwrap ( ) ;
95- content_sender
96- . send ( ProposalPart :: Fin ( ProposalFin {
97- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
98- } ) )
99- . await
100- . unwrap ( ) ;
85+ let content_receiver =
86+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
10187 let fin_receiver =
10288 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
103- content_sender. close_channel ( ) ;
10489 assert_eq ! ( fin_receiver. await . unwrap( ) . 0 , STATE_DIFF_COMMITMENT . 0.0 ) ;
10590}
10691
@@ -258,23 +243,8 @@ async fn interrupt_active_proposal() {
258243 let fin_receiver_0 =
259244 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
260245
261- let ( mut content_sender_1, content_receiver) =
262- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
263- content_sender_1. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
264- content_sender_1
265- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
266- . await
267- . unwrap ( ) ;
268- content_sender_1
269- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
270- . await
271- . unwrap ( ) ;
272- content_sender_1
273- . send ( ProposalPart :: Fin ( ProposalFin {
274- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
275- } ) )
276- . await
277- . unwrap ( ) ;
246+ let content_receiver =
247+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
278248 let fin_receiver_1 = context
279249 . validate_proposal (
280250 ProposalInit { round : 1 , ..Default :: default ( ) } ,
@@ -605,8 +575,6 @@ async fn gas_price_limits(#[case] maximum: bool) {
605575 let mut context = deps. build_context ( ) ;
606576
607577 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await . unwrap ( ) ;
608- let ( mut content_sender, content_receiver) =
609- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
610578
611579 let mut block_info = block_info ( BlockNumber ( 0 ) ) ;
612580
@@ -621,21 +589,7 @@ async fn gas_price_limits(#[case] maximum: bool) {
621589 }
622590
623591 // Send the block info, some transactions and then fin.
624- content_sender. send ( ProposalPart :: BlockInfo ( block_info) . clone ( ) ) . await . unwrap ( ) ;
625- content_sender
626- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
627- . await
628- . unwrap ( ) ;
629- content_sender
630- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
631- . await
632- . unwrap ( ) ;
633- content_sender
634- . send ( ProposalPart :: Fin ( ProposalFin {
635- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
636- } ) )
637- . await
638- . unwrap ( ) ;
592+ let content_receiver = send_proposal_to_validator_context ( & mut context, block_info) . await ;
639593
640594 // Even though we used the minimum/maximum gas price, not the values we gave the provider,
641595 // the proposal should be still be valid due to the clamping of limit prices.
@@ -845,26 +799,10 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
845799 // Initialize the context for a specific height, starting with round 0.
846800 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await . unwrap ( ) ;
847801
848- let ( mut content_sender, content_receiver) =
849- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
850- content_sender. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
851- content_sender
852- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
853- . await
854- . unwrap ( ) ;
855- content_sender
856- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
857- . await
858- . unwrap ( ) ;
859- content_sender
860- . send ( ProposalPart :: Fin ( ProposalFin {
861- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
862- } ) )
863- . await
864- . unwrap ( ) ;
802+ let content_receiver =
803+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
865804 let fin_receiver =
866805 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
867- content_sender. close_channel ( ) ;
868806 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
869807 assert_eq ! ( proposal_commitment. 0 , STATE_DIFF_COMMITMENT . 0.0 ) ;
870808
0 commit comments