@@ -262,16 +262,18 @@ mod tests {
262
262
263
263
#[ tokio:: test]
264
264
async fn validating_chain_send_feedbacks ( ) {
265
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
265
+ let chain = CertificateChainBuilder :: new ( )
266
266
. with_total_certificates ( 3 )
267
267
. with_certificates_per_epoch ( 1 )
268
268
. build ( ) ;
269
269
let last_certificate_hash = chain. first ( ) . unwrap ( ) . hash . clone ( ) ;
270
270
271
271
let feedback_receiver = Arc :: new ( StackFeedbackReceiver :: new ( ) ) ;
272
272
let certificate_client = CertificateClientTestBuilder :: default ( )
273
- . config_aggregator_client_mock ( |mock| mock. expect_certificate_chain ( chain. clone ( ) ) )
274
- . with_genesis_verification_key ( verifier. to_verification_key ( ) )
273
+ . config_aggregator_client_mock ( |mock| {
274
+ mock. expect_certificate_chain ( chain. certificates_chained . clone ( ) )
275
+ } )
276
+ . with_genesis_verification_key ( chain. genesis_verifier . to_verification_key ( ) )
275
277
. add_feedback_receiver ( feedback_receiver. clone ( ) )
276
278
. build ( ) ;
277
279
@@ -287,14 +289,12 @@ mod tests {
287
289
let mut vec = vec ! [ MithrilEvent :: CertificateChainValidationStarted {
288
290
certificate_chain_validation_id: id. to_string( ) ,
289
291
} ] ;
290
- vec. extend (
291
- chain
292
- . into_iter ( )
293
- . map ( |c| MithrilEvent :: CertificateValidated {
294
- certificate_chain_validation_id : id. to_string ( ) ,
295
- certificate_hash : c. hash ,
296
- } ) ,
297
- ) ;
292
+ vec. extend ( chain. certificates_chained . into_iter ( ) . map ( |c| {
293
+ MithrilEvent :: CertificateValidated {
294
+ certificate_chain_validation_id : id. to_string ( ) ,
295
+ certificate_hash : c. hash ,
296
+ }
297
+ } ) ) ;
298
298
vec. push ( MithrilEvent :: CertificateChainValidated {
299
299
certificate_chain_validation_id : id. to_string ( ) ,
300
300
} ) ;
@@ -306,15 +306,17 @@ mod tests {
306
306
307
307
#[ tokio:: test]
308
308
async fn verify_chain_return_certificate_with_given_hash ( ) {
309
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
309
+ let chain = CertificateChainBuilder :: new ( )
310
310
. with_total_certificates ( 3 )
311
311
. with_certificates_per_epoch ( 1 )
312
312
. build ( ) ;
313
313
let last_certificate_hash = chain. first ( ) . unwrap ( ) . hash . clone ( ) ;
314
314
315
315
let certificate_client = CertificateClientTestBuilder :: default ( )
316
- . config_aggregator_client_mock ( |mock| mock. expect_certificate_chain ( chain. clone ( ) ) )
317
- . with_genesis_verification_key ( verifier. to_verification_key ( ) )
316
+ . config_aggregator_client_mock ( |mock| {
317
+ mock. expect_certificate_chain ( chain. certificates_chained . clone ( ) )
318
+ } )
319
+ . with_genesis_verification_key ( chain. genesis_verifier . to_verification_key ( ) )
318
320
. build ( ) ;
319
321
320
322
let certificate = certificate_client
@@ -359,7 +361,7 @@ mod tests {
359
361
360
362
#[ tokio:: test]
361
363
async fn genesis_certificates_verification_result_is_not_cached ( ) {
362
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
364
+ let chain = CertificateChainBuilder :: new ( )
363
365
. with_total_certificates ( 1 )
364
366
. with_certificates_per_epoch ( 1 )
365
367
. build ( ) ;
@@ -369,7 +371,7 @@ mod tests {
369
371
let cache = Arc :: new ( MemoryCertificateVerifierCache :: new ( TimeDelta :: hours ( 1 ) ) ) ;
370
372
let verifier = build_verifier_with_cache (
371
373
|_mock| { } ,
372
- verifier . to_verification_key ( ) ,
374
+ chain . genesis_verifier . to_verification_key ( ) ,
373
375
cache. clone ( ) ,
374
376
) ;
375
377
@@ -394,7 +396,7 @@ mod tests {
394
396
395
397
#[ tokio:: test]
396
398
async fn non_genesis_certificates_verification_result_is_cached ( ) {
397
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
399
+ let chain = CertificateChainBuilder :: new ( )
398
400
. with_total_certificates ( 2 )
399
401
. with_certificates_per_epoch ( 1 )
400
402
. build ( ) ;
@@ -405,7 +407,7 @@ mod tests {
405
407
let cache = Arc :: new ( MemoryCertificateVerifierCache :: new ( TimeDelta :: hours ( 1 ) ) ) ;
406
408
let verifier = build_verifier_with_cache (
407
409
|mock| mock. expect_certificate_chain ( vec ! [ genesis_certificate. clone( ) ] ) ,
408
- verifier . to_verification_key ( ) ,
410
+ chain . genesis_verifier . to_verification_key ( ) ,
409
411
cache. clone ( ) ,
410
412
) ;
411
413
@@ -428,7 +430,7 @@ mod tests {
428
430
#[ tokio:: test]
429
431
async fn verification_of_first_certificate_of_a_chain_should_always_fetch_it_from_network ( )
430
432
{
431
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
433
+ let chain = CertificateChainBuilder :: new ( )
432
434
. with_total_certificates ( 2 )
433
435
. with_certificates_per_epoch ( 1 )
434
436
. build ( ) ;
@@ -440,10 +442,10 @@ mod tests {
440
442
) ;
441
443
let certificate_client = CertificateClientTestBuilder :: default ( )
442
444
. config_aggregator_client_mock ( |mock| {
443
- // Expect to first certificate to be fetched from the network
444
- mock. expect_certificate_chain ( chain. clone ( ) ) ;
445
+ // Expect to fetch the first certificate from the network
446
+ mock. expect_certificate_chain ( chain. certificates_chained . clone ( ) ) ;
445
447
} )
446
- . with_genesis_verification_key ( verifier . to_verification_key ( ) )
448
+ . with_genesis_verification_key ( chain . genesis_verifier . to_verification_key ( ) )
447
449
. with_verifier_cache ( cache. clone ( ) )
448
450
. build ( ) ;
449
451
@@ -466,7 +468,7 @@ mod tests {
466
468
// | n°3 | 2 | n°2 | Yes | No |
467
469
// | n°2 | 2 | n°1 | Yes | No |
468
470
// | n°1 | 1 | None (genesis) | Yes | Yes |
469
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
471
+ let chain = CertificateChainBuilder :: new ( )
470
472
. with_total_certificates ( 6 )
471
473
. with_certificates_per_epoch ( 3 )
472
474
. with_certificate_chaining_method ( CertificateChainingMethod :: Sequential )
@@ -503,7 +505,7 @@ mod tests {
503
505
. config_aggregator_client_mock ( |mock| {
504
506
mock. expect_certificate_chain ( certificates_that_must_be_fully_verified) ;
505
507
} )
506
- . with_genesis_verification_key ( verifier . to_verification_key ( ) )
508
+ . with_genesis_verification_key ( chain . genesis_verifier . to_verification_key ( ) )
507
509
. with_verifier_cache ( cache)
508
510
. build ( ) ;
509
511
@@ -515,7 +517,7 @@ mod tests {
515
517
516
518
#[ tokio:: test]
517
519
async fn verify_chain_return_certificate_with_cache ( ) {
518
- let ( chain, verifier ) = CertificateChainBuilder :: new ( )
520
+ let chain = CertificateChainBuilder :: new ( )
519
521
. with_total_certificates ( 5 )
520
522
. with_certificates_per_epoch ( 1 )
521
523
. build ( ) ;
@@ -531,7 +533,7 @@ mod tests {
531
533
[ chain[ 0 ..3 ] . to_vec ( ) , vec ! [ chain. last( ) . unwrap( ) . clone( ) ] ] . concat ( ) ,
532
534
)
533
535
} )
534
- . with_genesis_verification_key ( verifier . to_verification_key ( ) )
536
+ . with_genesis_verification_key ( chain . genesis_verifier . to_verification_key ( ) )
535
537
. with_verifier_cache ( Arc :: new ( cache) )
536
538
. build ( ) ;
537
539
0 commit comments