@@ -28,7 +28,6 @@ use tokio::process::Command;
2828#[ tokio:: test]
2929async fn execute_block_works ( ) {
3030 let port = 45789 ;
31- let ws_url = format ! ( "ws://localhost:{}" , port) ;
3231
3332 // Spawn a dev node.
3433 let _ = std:: thread:: spawn ( move || {
@@ -46,7 +45,10 @@ async fn execute_block_works() {
4645 // Wait some time to ensure the node is warmed up.
4746 std:: thread:: sleep ( Duration :: from_secs ( 90 ) ) ;
4847
48+ // Test passing --at
4949 common:: run_with_timeout ( Duration :: from_secs ( 60 ) , async move {
50+ let ws_url = format ! ( "ws://localhost:{}" , port) ;
51+
5052 fn execute_block ( ws_url : & str , at : Hash ) -> tokio:: process:: Child {
5153 Command :: new ( cargo_bin ( "try-runtime" ) )
5254 . stdout ( std:: process:: Stdio :: piped ( ) )
@@ -83,5 +85,41 @@ async fn execute_block_works() {
8385 . status
8486 . success( ) ) ;
8587 } )
88+ . await ;
89+
90+ // Test not passing --at
91+ common:: run_with_timeout ( Duration :: from_secs ( 60 ) , async move {
92+ let ws_url = format ! ( "ws://localhost:{}" , port) ;
93+
94+ fn execute_block ( ws_url : & str ) -> tokio:: process:: Child {
95+ Command :: new ( cargo_bin ( "try-runtime" ) )
96+ . stdout ( std:: process:: Stdio :: piped ( ) )
97+ . stderr ( std:: process:: Stdio :: piped ( ) )
98+ . arg ( "--runtime=existing" )
99+ . args ( [ "execute-block" ] )
100+ . args ( [ "live" , format ! ( "--uri={}" , ws_url) . as_str ( ) ] )
101+ . kill_on_drop ( true )
102+ . spawn ( )
103+ . unwrap ( )
104+ }
105+
106+ // Try to execute the block.
107+ let mut block_execution = execute_block ( & ws_url) ;
108+ let expected_output = r".*Block #(\d+) successfully executed" ;
109+ let re = Regex :: new ( expected_output) . unwrap ( ) ;
110+ let matched =
111+ common:: wait_for_stream_pattern_match ( block_execution. stderr . take ( ) . unwrap ( ) , re) . await ;
112+
113+ // Assert that the block-execution process has executed a block.
114+ assert ! ( matched. is_ok( ) ) ;
115+
116+ // Assert that the block-execution exited succesfully
117+ assert ! ( block_execution
118+ . wait_with_output( )
119+ . await
120+ . unwrap( )
121+ . status
122+ . success( ) ) ;
123+ } )
86124 . await
87125}
0 commit comments