MCPcopy Create free account
hub / github.com/SeismicSystems/summit / test_subscribe_basic_block_delivery

Function test_subscribe_basic_block_delivery

syncer/src/lib.rs:559–611  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

557
558 #[test_traced("WARN")]
559 fn test_subscribe_basic_block_delivery() {
560 let runner = deterministic::Runner::timed(Duration::from_secs(60));
561 runner.start(|mut context| async move {
562 let mut oracle = setup_network(context.clone(), NZUsize!(1));
563 let Fixture {
564 participants,
565 schemes,
566 ..
567 } = bls12381_threshold::<V, _>(&mut context, NUM_VALIDATORS);
568
569 let mut actors = Vec::new();
570 for (i, validator) in participants.iter().enumerate() {
571 let (_application, actor, _processed_height) = setup_validator(
572 context.with_label(&format!("validator_{i}")),
573 &mut oracle,
574 validator.clone(),
575 ConstantProvider::new(schemes[i].clone()),
576 )
577 .await;
578 actors.push(actor);
579 }
580 let mut actor = actors[0].clone();
581
582 setup_network_links(&mut oracle, &participants, LINK).await;
583
584 let parent = Sha256::hash(b"");
585 let block = B::new::<Sha256>(parent, Height::new(1), 1);
586 let commitment = block.digest();
587
588 let subscription_rx = actor
589 .subscribe(Some(Round::new(Epoch::new(0), View::new(1))), commitment)
590 .await;
591
592 actor
593 .verified(Round::new(Epoch::new(0), View::new(1)), block.clone())
594 .await;
595
596 let proposal = Proposal {
597 round: Round::new(Epoch::new(0), View::new(1)),
598 parent: View::new(0),
599 payload: commitment,
600 };
601 let notarization = make_notarization(proposal.clone(), &schemes, QUORUM);
602 actor.report(Activity::Notarization(notarization)).await;
603
604 let finalization = make_finalization(proposal, &schemes, QUORUM);
605 actor.report(Activity::Finalization(finalization)).await;
606
607 let received_block = subscription_rx.await.unwrap();
608 assert_eq!(received_block.digest(), block.digest());
609 assert_eq!(received_block.height, Height::new(1));
610 })
611 }
612
613 #[test_traced("WARN")]
614 fn test_subscribe_multiple_subscriptions() {

Callers

nothing calls this directly

Calls 12

setup_networkFunction · 0.85
setup_validatorFunction · 0.85
setup_network_linksFunction · 0.85
make_notarizationFunction · 0.85
iterMethod · 0.80
pushMethod · 0.80
verifiedMethod · 0.80
make_finalizationFunction · 0.70
startMethod · 0.45
digestMethod · 0.45
subscribeMethod · 0.45
reportMethod · 0.45

Tested by

no test coverage detected