@@ -41,10 +41,7 @@ mod tests {
4141 } ;
4242 use commonware_macros:: { select, test_traced} ;
4343 use commonware_p2p:: simulated:: { Link , Network , Oracle , Receiver , Sender } ;
44- use commonware_runtime:: {
45- deterministic:: { Context , Executor } ,
46- Clock , Metrics , Runner ,
47- } ;
44+ use commonware_runtime:: { deterministic, Clock , Metrics , Runner } ;
4845 use std:: { collections:: BTreeMap , time:: Duration } ;
4946
5047 // Number of messages to cache per sender
@@ -63,11 +60,11 @@ mod tests {
6360 type Registrations = BTreeMap < PublicKey , ( Sender < PublicKey > , Receiver < PublicKey > ) > ;
6461
6562 async fn initialize_simulation (
66- context : Context ,
63+ context : deterministic :: Context ,
6764 num_peers : u32 ,
6865 success_rate : f64 ,
6966 ) -> ( Vec < PublicKey > , Registrations , Oracle < PublicKey > ) {
70- let ( network, mut oracle) = Network :: < Context , PublicKey > :: new (
67+ let ( network, mut oracle) = Network :: < deterministic :: Context , PublicKey > :: new (
7168 context. with_label ( "network" ) ,
7269 commonware_p2p:: simulated:: Config {
7370 max_size : 1024 * 1024 ,
@@ -109,7 +106,7 @@ mod tests {
109106 }
110107
111108 fn spawn_peer_engines (
112- context : Context ,
109+ context : deterministic :: Context ,
113110 registrations : & mut Registrations ,
114111 ) -> BTreeMap < PublicKey , Mailbox < Sha256Digest , TestMessage > > {
115112 let mut mailboxes = BTreeMap :: < PublicKey , Mailbox < Sha256Digest , TestMessage > > :: new ( ) ;
@@ -135,8 +132,8 @@ mod tests {
135132
136133 #[ test_traced]
137134 fn test_broadcast ( ) {
138- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 5 ) ) ;
139- runner. start ( async move {
135+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 5 ) ) ;
136+ runner. start ( |context| async move {
140137 let ( peers, mut registrations, _oracle) =
141138 initialize_simulation ( context. clone ( ) , 4 , 1.0 ) . await ;
142139 let mailboxes = spawn_peer_engines ( context. clone ( ) , & mut registrations) ;
@@ -162,8 +159,8 @@ mod tests {
162159
163160 #[ test_traced]
164161 fn test_self_retrieval ( ) {
165- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 5 ) ) ;
166- runner. start ( async move {
162+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 5 ) ) ;
163+ runner. start ( |context| async move {
167164 // Initialize simulation with 1 peer
168165 let ( peers, mut registrations, _oracle) =
169166 initialize_simulation ( context. clone ( ) , 1 , 1.0 ) . await ;
@@ -208,8 +205,8 @@ mod tests {
208205
209206 #[ test_traced]
210207 fn test_packet_loss ( ) {
211- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 30 ) ) ;
212- runner. start ( async move {
208+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 30 ) ) ;
209+ runner. start ( |context| async move {
213210 let ( peers, mut registrations, _oracle) =
214211 initialize_simulation ( context. clone ( ) , 10 , 0.1 ) . await ;
215212 let mailboxes = spawn_peer_engines ( context. clone ( ) , & mut registrations) ;
@@ -249,8 +246,8 @@ mod tests {
249246
250247 #[ test_traced]
251248 fn test_get_cached ( ) {
252- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 5 ) ) ;
253- runner. start ( async move {
249+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 5 ) ) ;
250+ runner. start ( |context| async move {
254251 let ( peers, mut registrations, _oracle) =
255252 initialize_simulation ( context. clone ( ) , 2 , 1.0 ) . await ;
256253 let mailboxes = spawn_peer_engines ( context. clone ( ) , & mut registrations) ;
@@ -277,8 +274,8 @@ mod tests {
277274
278275 #[ test_traced]
279276 fn test_get_nonexistent ( ) {
280- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 5 ) ) ;
281- runner. start ( async move {
277+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 5 ) ) ;
278+ runner. start ( |context| async move {
282279 let ( peers, mut registrations, _oracle) =
283280 initialize_simulation ( context. clone ( ) , 2 , 1.0 ) . await ;
284281 let mailboxes = spawn_peer_engines ( context. clone ( ) , & mut registrations) ;
@@ -310,8 +307,8 @@ mod tests {
310307
311308 #[ test_traced]
312309 fn test_cache_eviction_single_peer ( ) {
313- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 5 ) ) ;
314- runner. start ( async move {
310+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 5 ) ) ;
311+ runner. start ( |context| async move {
315312 let ( peers, mut registrations, _oracle) =
316313 initialize_simulation ( context. clone ( ) , 2 , 1.0 ) . await ;
317314 let mailboxes = spawn_peer_engines ( context. clone ( ) , & mut registrations) ;
@@ -347,8 +344,8 @@ mod tests {
347344
348345 #[ test_traced]
349346 fn test_cache_eviction_multi_peer ( ) {
350- let ( runner, context , _ ) = Executor :: timed ( Duration :: from_secs ( 10 ) ) ;
351- runner. start ( async move {
347+ let runner = deterministic :: Runner :: timed ( Duration :: from_secs ( 10 ) ) ;
348+ runner. start ( |context| async move {
352349 // Initialize simulation with 3 peers
353350 let ( peers, mut registrations, _oracle) =
354351 initialize_simulation ( context. clone ( ) , 3 , 1.0 ) . await ;
0 commit comments