@@ -145,7 +145,7 @@ impl TestRunner {
145145 let leader_bearer_token = hex:: encode ( rng. gen :: < [ u8 ; 16 ] > ( ) ) ;
146146 let collector_bearer_token = hex:: encode ( rng. gen :: < [ u8 ; 16 ] > ( ) ) ;
147147 let t = Self {
148- global_config,
148+ global_config,
149149 task_id,
150150 now,
151151 task_config,
@@ -219,6 +219,8 @@ impl TestRunner {
219219 //
220220 // First, delete the data from the previous test.
221221 t. internal_delete_all ( & t. batch_interval ( ) ) . await . unwrap ( ) ;
222+ println ! ( "Task_config.not_before: {}" , t. task_config. not_before) ;
223+ println ! ( "t.task_id: {:}" , t. task_id) ;
222224
223225 // Configure the Leader with the task.
224226 let leader_add_task_cmd = json ! ( {
@@ -309,9 +311,127 @@ impl TestRunner {
309311 ) ;
310312
311313 println ! ( "############ starting test ############" ) ;
314+
312315 t
313316 }
314317
318+ pub async fn setup_endpoints ( & self , task_id : & TaskId , version : DapVersion ) {
319+ // Configure the endpoints.
320+ //
321+ // First, delete the data from the previous test.
322+ self . internal_delete_all ( & self . batch_interval ( ) ) . await . unwrap ( ) ;
323+ println ! ( "Task_config.not_before: {}" , self . task_config. not_before) ;
324+ println ! ( "self.task_id: {:}" , self . task_id) ;
325+
326+ let vdaf_verify_key_base64url = encode_base64url ( self . task_config . vdaf_verify_key . as_ref ( ) ) ;
327+
328+ let ( batch_mode, max_batch_size) = match self . task_config . query {
329+ DapBatchMode :: TimeInterval => ( 1 , None ) ,
330+ DapBatchMode :: LeaderSelected { max_batch_size } => ( 2 , Some ( max_batch_size) ) ,
331+ } ;
332+
333+ let collector_hpke_config_base64url =
334+ encode_base64url ( self . collector_hpke_receiver . config . get_encoded ( ) . unwrap ( ) ) ;
335+
336+ let vdaf = json ! ( {
337+ "type" : "Prio2" ,
338+ "dimension" : assert_matches!(
339+ self . task_config. vdaf,
340+ VdafConfig :: Prio2 { dimension } => format!( "{dimension}" )
341+ ) ,
342+ } ) ;
343+ // Configure the Leader with the task.
344+ let leader_add_task_cmd = json ! ( {
345+ "task_id" : task_id. to_base64url( ) ,
346+ "leader" : self . leader_url,
347+ "helper" : self . helper_url,
348+ "vdaf" : vdaf. clone( ) ,
349+ "leader_authentication_token" : self . leader_bearer_token. clone( ) ,
350+ "collector_authentication_token" : self . collector_bearer_token. clone( ) ,
351+ "role" : "leader" ,
352+ "vdaf_verify_key" : vdaf_verify_key_base64url,
353+ "batch_mode" : batch_mode,
354+ "min_batch_size" : self . task_config. min_batch_size,
355+ "max_batch_size" : max_batch_size,
356+ "time_precision" : self . task_config. time_precision,
357+ "collector_hpke_config" : collector_hpke_config_base64url. clone( ) ,
358+ "task_expiration" : self . task_config. not_after,
359+ "task_commencement" : self . task_config. not_before,
360+ } ) ;
361+ let add_task_path = format ! ( "{}/internal/test/add_task" , version. as_ref( ) ) ;
362+ let res: InternalTestCommandResult = self
363+ . leader_post_internal ( & add_task_path, & leader_add_task_cmd)
364+ . await
365+ . unwrap ( ) ;
366+ assert_eq ! (
367+ res. status, "success" ,
368+ "response status: {}, error: {:?}" ,
369+ res. status, res. error
370+ ) ;
371+
372+ // Configure the Helper with the task.
373+ let helper_add_task_cmd = json ! ( {
374+ "task_id" : task_id. to_base64url( ) ,
375+ "leader" : self . leader_url,
376+ "helper" : self . helper_url,
377+ "vdaf" : vdaf. clone( ) ,
378+ "leader_authentication_token" : self . leader_bearer_token. clone( ) ,
379+ "role" : "helper" ,
380+ "vdaf_verify_key" : vdaf_verify_key_base64url,
381+ "batch_mode" : batch_mode,
382+ "min_batch_size" : self . task_config. min_batch_size,
383+ "max_batch_size" : max_batch_size,
384+ "time_precision" : self . task_config. time_precision,
385+ "collector_hpke_config" : collector_hpke_config_base64url. clone( ) ,
386+ "task_expiration" : self . task_config. not_after,
387+ "task_commencement" : self . task_config. not_before,
388+ } ) ;
389+ let res: InternalTestCommandResult = self
390+ . helper_post_internal ( & add_task_path, & helper_add_task_cmd)
391+ . await
392+ . unwrap ( ) ;
393+ assert_eq ! (
394+ res. status, "success" ,
395+ "response status: {}, error: {:?}" ,
396+ res. status, res. error
397+ ) ;
398+
399+ let gen_config = || {
400+ HpkeReceiverConfig :: gen ( 0 , HpkeKemId :: X25519HkdfSha256 )
401+ . expect ( "failed to generate receiver config" )
402+ } ;
403+ let res: InternalTestCommandResult = self
404+ . helper_post_internal (
405+ & format ! ( "{version}/internal/test/add_hpke_config" ) ,
406+ & gen_config ( ) ,
407+ )
408+ . await
409+ . unwrap ( ) ;
410+
411+ assert_eq ! (
412+ res. status, "success" ,
413+ "response status: {}, error {:?}" ,
414+ res. status, res. error
415+ ) ;
416+
417+ let res: InternalTestCommandResult = self
418+ . leader_post_internal (
419+ & format ! ( "{version}/internal/test/add_hpke_config" ) ,
420+ & gen_config ( ) ,
421+ )
422+ . await
423+ . unwrap ( ) ;
424+
425+ assert_eq ! (
426+ res. status, "success" ,
427+ "response status: {}, error {:?}" ,
428+ res. status, res. error
429+ ) ;
430+
431+ println ! ( "############ starting test ############" ) ;
432+ }
433+
434+
315435 pub fn http_client ( & self ) -> & reqwest:: Client {
316436 & self . http_client
317437 }
@@ -352,6 +472,29 @@ impl TestRunner {
352472 ] )
353473 }
354474
475+ pub async fn get_hpke_configs_task_id (
476+ & self ,
477+ _version : DapVersion ,
478+ client : & reqwest:: Client ,
479+ task_id : & TaskId
480+ ) -> anyhow:: Result < [ HpkeConfig ; 2 ] > {
481+ let raw_leader_hpke_config = get_raw_hpke_config ( client, task_id. as_ref ( ) , & self . leader_url , "leader" , & self . version ) . await ?;
482+ let raw_helper_hpke_config = get_raw_hpke_config ( client, task_id. as_ref ( ) , & self . helper_url , "helper" , & self . version ) . await ?;
483+
484+ let mut leader_hpke_config_list = HpkeConfigList :: get_decoded ( & raw_leader_hpke_config) ?;
485+ let mut helper_hpke_config_list = HpkeConfigList :: get_decoded ( & raw_helper_hpke_config) ?;
486+ if leader_hpke_config_list. hpke_configs . len ( ) != 1
487+ || helper_hpke_config_list. hpke_configs . len ( ) != 1
488+ {
489+ panic ! ( "only a length 1 HpkeConfList is currently supported by the test suite" )
490+ }
491+ Ok ( [
492+ leader_hpke_config_list. hpke_configs . pop ( ) . unwrap ( ) ,
493+ helper_hpke_config_list. hpke_configs . pop ( ) . unwrap ( ) ,
494+ ] )
495+ }
496+
497+
355498 pub async fn leader_get_raw_hpke_config (
356499 & self ,
357500 client : & reqwest:: Client ,
0 commit comments