@@ -552,17 +552,15 @@ mod test {
552552 ] ) ;
553553 let ( leader_state, agg_job_init_req) =
554554 t. produce_agg_job_req ( & DapAggregationParam :: Empty , reports) ;
555- let ( _agg_span, mut agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
555+ let ( _agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
556556
557- let AggregationJobResp :: Ready { transitions } = & mut agg_job_resp else {
558- panic ! ( "expected a ready response, got processing" )
559- } ;
557+ let mut agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
560558
561559 // Helper sends transitions out of order.
562- transitions. swap ( 0 , 1 ) ;
560+ agg_job_resp . transitions . swap ( 0 , 1 ) ;
563561
564562 assert_matches ! (
565- t. consume_agg_job_resp_expect_err( leader_state, agg_job_resp) ,
563+ t. consume_agg_job_resp_expect_err( leader_state, agg_job_resp, ) ,
566564 DapError :: Abort ( DapAbort :: InvalidMessage { .. } )
567565 ) ;
568566 }
@@ -577,15 +575,13 @@ mod test {
577575 ] ) ;
578576 let ( leader_state, agg_job_init_req) =
579577 t. produce_agg_job_req ( & DapAggregationParam :: Empty , reports) ;
580- let ( _agg_span, mut agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
578+ let ( _agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
581579
582- let AggregationJobResp :: Ready { transitions } = & mut agg_job_resp else {
583- panic ! ( "expected a ready response, got processing" )
584- } ;
580+ let mut agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
585581
586582 // Helper sends a transition twice.
587- let repeated_transition = transitions[ 0 ] . clone ( ) ;
588- transitions. push ( repeated_transition) ;
583+ let repeated_transition = agg_job_resp . transitions [ 0 ] . clone ( ) ;
584+ agg_job_resp . transitions . push ( repeated_transition) ;
589585
590586 assert_matches ! (
591587 t. consume_agg_job_resp_expect_err( leader_state, agg_job_resp) ,
@@ -604,13 +600,12 @@ mod test {
604600 ] ) ;
605601 let ( leader_state, agg_job_init_req) =
606602 t. produce_agg_job_req ( & DapAggregationParam :: Empty , reports) ;
607- let ( _agg_span, mut agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
603+ let ( _agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
604+
605+ let mut agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
608606
609- let AggregationJobResp :: Ready { transitions } = & mut agg_job_resp else {
610- panic ! ( "expected a ready response, got processing" )
611- } ;
612607 // Helper sent a transition with an unrecognized report ID.
613- transitions. push ( Transition {
608+ agg_job_resp . transitions . push ( Transition {
614609 report_id : ReportId ( rng. gen ( ) ) ,
615610 var : TransitionVar :: Continued ( b"whatever" . to_vec ( ) ) ,
616611 } ) ;
@@ -628,14 +623,13 @@ mod test {
628623 let reports = t. produce_reports ( vec ! [ DapMeasurement :: U32Vec ( vec![ 1 ; 10 ] ) ] ) ;
629624 let ( leader_state, agg_job_init_req) =
630625 t. produce_agg_job_req ( & DapAggregationParam :: Empty , reports) ;
631- let ( _helper_agg_span, mut agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
626+ let ( _helper_agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
627+
628+ let mut agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
632629
633- let AggregationJobResp :: Ready { transitions } = & mut agg_job_resp else {
634- panic ! ( "expected a ready response, got processing" )
635- } ;
636630 // Helper sent a transition with an unrecognized report ID. Simulate this by flipping the
637631 // first bit of the report ID.
638- transitions[ 0 ] . report_id . 0 [ 0 ] ^= 1 ;
632+ agg_job_resp . transitions [ 0 ] . report_id . 0 [ 0 ] ^= 1 ;
639633
640634 assert_matches ! (
641635 t. consume_agg_job_resp_expect_err( leader_state, agg_job_resp) ,
@@ -660,6 +654,7 @@ mod test {
660654
661655 let ( leader_agg_span, helper_agg_span) = {
662656 let ( helper_agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
657+ let agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
663658 let leader_agg_span = t. consume_agg_job_resp ( leader_state, agg_job_resp) ;
664659
665660 ( leader_agg_span, helper_agg_span)
@@ -713,12 +708,11 @@ mod test {
713708 . collect :: < Vec < _ > > ( ) ;
714709 let ( helper_agg_span, agg_job_resp) = t. handle_agg_job_req ( agg_job_init_req) ;
715710
716- let AggregationJobResp :: Ready { transitions } = & agg_job_resp else {
717- panic ! ( "expected a ready response, got processing" )
718- } ;
711+ let agg_job_resp = agg_job_resp. unwrap_ready ( ) ;
712+
719713 assert_eq ! ( 2 , helper_agg_span. report_count( ) ) ;
720- assert_eq ! ( 3 , transitions. len( ) ) ;
721- for ( transition, prep_init_id) in zip ( transitions, prep_init_ids) {
714+ assert_eq ! ( 3 , agg_job_resp . transitions. len( ) ) ;
715+ for ( transition, prep_init_id) in zip ( & agg_job_resp . transitions , prep_init_ids) {
722716 assert_eq ! ( transition. report_id, prep_init_id) ;
723717 }
724718
0 commit comments