@@ -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 ETH_TO_FRI_RATE ,
5051 INTERNAL_TX_BATCH ,
5152 STATE_DIFF_COMMITMENT ,
@@ -80,26 +81,10 @@ async fn validate_proposal_success() {
8081 // Initialize the context for a specific height, starting with round 0.
8182 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await ;
8283
83- let ( mut content_sender, content_receiver) =
84- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
85- content_sender. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
86- content_sender
87- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
88- . await
89- . unwrap ( ) ;
90- content_sender
91- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
92- . await
93- . unwrap ( ) ;
94- content_sender
95- . send ( ProposalPart :: Fin ( ProposalFin {
96- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
97- } ) )
98- . await
99- . unwrap ( ) ;
84+ let content_receiver =
85+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
10086 let fin_receiver =
10187 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
102- content_sender. close_channel ( ) ;
10388 assert_eq ! ( fin_receiver. await . unwrap( ) . 0 , STATE_DIFF_COMMITMENT . 0.0 ) ;
10489}
10590
@@ -257,23 +242,8 @@ async fn interrupt_active_proposal() {
257242 let fin_receiver_0 =
258243 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
259244
260- let ( mut content_sender_1, content_receiver) =
261- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
262- content_sender_1. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
263- content_sender_1
264- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
265- . await
266- . unwrap ( ) ;
267- content_sender_1
268- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
269- . await
270- . unwrap ( ) ;
271- content_sender_1
272- . send ( ProposalPart :: Fin ( ProposalFin {
273- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
274- } ) )
275- . await
276- . unwrap ( ) ;
245+ let content_receiver =
246+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
277247 let fin_receiver_1 = context
278248 . validate_proposal (
279249 ProposalInit { round : 1 , ..Default :: default ( ) } ,
@@ -598,8 +568,6 @@ async fn gas_price_limits(#[case] maximum: bool) {
598568 let mut context = deps. build_context ( ) ;
599569
600570 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await ;
601- let ( mut content_sender, content_receiver) =
602- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
603571
604572 let mut block_info = block_info ( BlockNumber ( 0 ) ) ;
605573
@@ -614,21 +582,7 @@ async fn gas_price_limits(#[case] maximum: bool) {
614582 }
615583
616584 // Send the block info, some transactions and then fin.
617- content_sender. send ( ProposalPart :: BlockInfo ( block_info) . clone ( ) ) . await . unwrap ( ) ;
618- content_sender
619- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
620- . await
621- . unwrap ( ) ;
622- content_sender
623- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
624- . await
625- . unwrap ( ) ;
626- content_sender
627- . send ( ProposalPart :: Fin ( ProposalFin {
628- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
629- } ) )
630- . await
631- . unwrap ( ) ;
585+ let content_receiver = send_proposal_to_validator_context ( & mut context, block_info) . await ;
632586
633587 // Even though we used the minimum/maximum gas price, not the values we gave the provider,
634588 // the proposal should be still be valid due to the clamping of limit prices.
@@ -835,26 +789,10 @@ async fn oracle_fails_on_second_block(#[case] l1_oracle_failure: bool) {
835789 // Initialize the context for a specific height, starting with round 0.
836790 context. set_height_and_round ( BlockNumber ( 0 ) , 0 ) . await ;
837791
838- let ( mut content_sender, content_receiver) =
839- mpsc:: channel ( context. config . static_config . proposal_buffer_size ) ;
840- content_sender. send ( ProposalPart :: BlockInfo ( block_info ( BlockNumber ( 0 ) ) ) ) . await . unwrap ( ) ;
841- content_sender
842- . send ( ProposalPart :: Transactions ( TransactionBatch { transactions : TX_BATCH . to_vec ( ) } ) )
843- . await
844- . unwrap ( ) ;
845- content_sender
846- . send ( ProposalPart :: ExecutedTransactionCount ( INTERNAL_TX_BATCH . len ( ) . try_into ( ) . unwrap ( ) ) )
847- . await
848- . unwrap ( ) ;
849- content_sender
850- . send ( ProposalPart :: Fin ( ProposalFin {
851- proposal_commitment : ProposalCommitment ( STATE_DIFF_COMMITMENT . 0 . 0 ) ,
852- } ) )
853- . await
854- . unwrap ( ) ;
792+ let content_receiver =
793+ send_proposal_to_validator_context ( & mut context, block_info ( BlockNumber ( 0 ) ) ) . await ;
855794 let fin_receiver =
856795 context. validate_proposal ( ProposalInit :: default ( ) , TIMEOUT , content_receiver) . await ;
857- content_sender. close_channel ( ) ;
858796 let proposal_commitment = fin_receiver. await . unwrap ( ) ;
859797 assert_eq ! ( proposal_commitment. 0 , STATE_DIFF_COMMITMENT . 0.0 ) ;
860798
0 commit comments