@@ -85,7 +85,8 @@ mod tests {
8585 use commonware_parallel:: Sequential ;
8686 use commonware_resolver:: { Consumer , Delivery , Fetch , Resolver } ;
8787 use commonware_runtime:: {
88- buffer:: paged:: CacheRef , deterministic, Clock , Metrics , Quota , Runner , Supervisor as _,
88+ buffer:: paged:: CacheRef , deterministic, Clock , Metrics , Quota , Runner , Spawner ,
89+ Supervisor as _,
8990 } ;
9091 use commonware_storage:: {
9192 archive:: { immutable, prunable, Archive as _} ,
@@ -112,6 +113,38 @@ mod tests {
112113 assert_provider :: < Mailbox < S , Standard < B > > > ( ) ;
113114 }
114115
116+ #[ test_traced( "WARN" ) ]
117+ fn test_standard_block_provider_parent_fetches_by_commitment ( ) {
118+ let runner = deterministic:: Runner :: timed ( Duration :: from_secs ( 30 ) ) ;
119+ runner. start ( |mut context| async move {
120+ let Fixture { schemes, .. } =
121+ bls12381_threshold_vrf:: fixture :: < V , _ > ( & mut context, NAMESPACE , NUM_VALIDATORS ) ;
122+ let buffer = RecordingBuffer :: default ( ) ;
123+ let ( mailbox, buffer, _resolver, _actor_handle) = start_standard_actor (
124+ context. child ( "validator" ) ,
125+ "standard-provider-parent-commitment" ,
126+ ConstantProvider :: new ( schemes[ 0 ] . clone ( ) ) ,
127+ Application :: < B > :: manual_ack ( ) ,
128+ buffer,
129+ )
130+ . await ;
131+
132+ let parent = make_raw_block ( Sha256 :: hash ( b"" ) , Height :: new ( 1 ) , 100 ) ;
133+ let child = make_raw_block ( parent. digest ( ) , Height :: new ( 2 ) , 200 ) ;
134+ let subscription = context
135+ . child ( "subscribe_parent" )
136+ . spawn ( move |_| BlockProvider :: subscribe_parent ( mailbox, child) ) ;
137+
138+ context. sleep ( Duration :: from_millis ( 100 ) ) . await ;
139+ assert_eq ! (
140+ buffer. commitment_subscription_count( ) ,
141+ 1 ,
142+ "parent walkback should use the standard parent commitment"
143+ ) ;
144+ subscription. abort ( ) ;
145+ } ) ;
146+ }
147+
115148 fn assert_finalize_deterministic < H : TestHarness > (
116149 seed : u64 ,
117150 link : commonware_p2p:: simulated:: Link ,
@@ -2437,7 +2470,8 @@ mod tests {
24372470 /// other methods are no-ops.
24382471 #[ derive( Clone , Default ) ]
24392472 struct RecordingBuffer {
2440- subscriptions : Arc < Mutex < Vec < oneshot:: Sender < B > > > > ,
2473+ digest_subscriptions : Arc < Mutex < Vec < oneshot:: Sender < B > > > > ,
2474+ commitment_subscriptions : Arc < Mutex < Vec < oneshot:: Sender < B > > > > ,
24412475 sends : Arc < Mutex < Vec < BufferSend > > > ,
24422476 }
24432477
@@ -2447,7 +2481,11 @@ mod tests {
24472481 }
24482482
24492483 fn subscription_count ( & self ) -> usize {
2450- self . subscriptions . lock ( ) . len ( )
2484+ self . digest_subscriptions . lock ( ) . len ( ) + self . commitment_subscriptions . lock ( ) . len ( )
2485+ }
2486+
2487+ fn commitment_subscription_count ( & self ) -> usize {
2488+ self . commitment_subscriptions . lock ( ) . len ( )
24512489 }
24522490 }
24532491
@@ -2464,13 +2502,13 @@ mod tests {
24642502
24652503 fn subscribe_by_digest ( & self , _digest : D ) -> oneshot:: Receiver < B > {
24662504 let ( sender, receiver) = oneshot:: channel ( ) ;
2467- self . subscriptions . lock ( ) . push ( sender) ;
2505+ self . digest_subscriptions . lock ( ) . push ( sender) ;
24682506 receiver
24692507 }
24702508
24712509 fn subscribe_by_commitment ( & self , _commitment : D ) -> oneshot:: Receiver < B > {
24722510 let ( sender, receiver) = oneshot:: channel ( ) ;
2473- self . subscriptions . lock ( ) . push ( sender) ;
2511+ self . commitment_subscriptions . lock ( ) . push ( sender) ;
24742512 receiver
24752513 }
24762514
0 commit comments