File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
crates/services/consensus_module/poa/src/service_test Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -506,3 +506,32 @@ async fn interval_trigger_even_if_queued_tx_events() {
506506 } ) ;
507507 block_creation_waiter. notified ( ) . await ;
508508}
509+
510+ #[ tokio:: test]
511+ async fn open_trigger__produce_blocks_in_time ( ) {
512+ // Given
513+ let open_time = Duration :: from_secs ( 10 ) ;
514+ let offset = Duration :: from_secs ( 1 ) ;
515+ let mut ctx = DefaultContext :: new ( Config {
516+ trigger : Trigger :: Open { period : open_time } ,
517+ signer : SignMode :: Key ( test_signing_key ( ) ) ,
518+ metrics : false ,
519+ ..Default :: default ( )
520+ } )
521+ . await ;
522+ let expected_block_time = ctx. now ( ) . 0 . checked_add ( open_time. as_secs ( ) ) . unwrap ( ) ;
523+
524+ // When
525+ time:: sleep ( offset) . await ;
526+ ctx. advance_time_with_tokio ( ) ;
527+ let receive_before_closed = ctx. block_import . try_recv ( ) ;
528+
529+ time:: sleep ( open_time) . await ;
530+ let receive_after_open = ctx. block_import . try_recv ( ) ;
531+
532+ // Then
533+ assert ! ( receive_before_closed. is_err( ) ) ;
534+ assert ! ( receive_after_open. is_ok( ) ) ;
535+ let block_time = receive_after_open. unwrap ( ) . entity . header ( ) . time ( ) ;
536+ assert_eq ! ( block_time. 0 , expected_block_time) ;
537+ }
You can’t perform that action at this time.
0 commit comments