@@ -157,28 +157,33 @@ pub mod scenarios {
157157 MockIO :: eprint( "if you wish to be included as a permissioned candidate." ) ,
158158 ] )
159159 }
160-
161- pub fn create_temp_chain_spec ( ) -> MockIO {
162- MockIO :: Group ( vec ! [ MockIO :: new_tmp_dir( ) ] )
163- }
164160}
165161
166162#[ test]
167163fn happy_path ( ) {
168- let mock_context = MockIOContext :: new ( ) . with_expected_io ( vec ! [
169- scenarios:: show_intro( ) ,
170- MockIO :: enewline( ) ,
171- scenarios:: create_temp_chain_spec( ) ,
172- scenarios:: prompt_all_config_fields( ) ,
173- MockIO :: enewline( ) ,
174- scenarios:: generate_all_spo_keys( AURA_KEY , GRANDPA_KEY , CROSS_CHAIN_KEY ) ,
175- scenarios:: write_key_file( AURA_KEY , GRANDPA_KEY , CROSS_CHAIN_KEY ) ,
176- MockIO :: enewline( ) ,
177- scenarios:: generate_network_key( ) ,
178- MockIO :: enewline( ) ,
179- MockIO :: eprint( "🚀 All done!" ) ,
180- MockIO :: delete_file( "/tmp/MockIOContext_tmp_dir/chain-spec.json" ) ,
181- ] ) ;
164+ let mock_context = MockIOContext :: new ( )
165+ . with_json_file (
166+ RESOURCES_CONFIG_FILE_PATH ,
167+ serde_json:: json!( {
168+ "substrate_node_base_path" : DATA_PATH ,
169+ } ) ,
170+ )
171+ . with_expected_io ( vec ! [
172+ scenarios:: show_intro( ) ,
173+ MockIO :: enewline( ) ,
174+ MockIO :: new_tmp_dir( ) ,
175+ MockIO :: eprint( & format!(
176+ "🛠️ Loaded node base path from config ({RESOURCES_CONFIG_FILE_PATH}): {DATA_PATH}"
177+ ) ) ,
178+ MockIO :: enewline( ) ,
179+ scenarios:: generate_all_spo_keys( AURA_KEY , GRANDPA_KEY , CROSS_CHAIN_KEY ) ,
180+ scenarios:: write_key_file( AURA_KEY , GRANDPA_KEY , CROSS_CHAIN_KEY ) ,
181+ MockIO :: enewline( ) ,
182+ scenarios:: generate_network_key( ) ,
183+ MockIO :: enewline( ) ,
184+ MockIO :: eprint( "🚀 All done!" ) ,
185+ MockIO :: delete_file( "/tmp/MockIOContext_tmp_dir/chain-spec.json" ) ,
186+ ] ) ;
182187
183188 let result =
184189 GenerateKeysCmd :: < MockRuntime > {
@@ -373,14 +378,14 @@ mod generate_network_key {
373378 MockIO :: run_command( & format!( "mkdir -p {DATA_PATH}/network" ) , "irrelevant" ) ,
374379 MockIO :: run_command(
375380 & format!(
376- "<mock executable> key generate-node-key --chain path/to/chain-spec .json --file {}" ,
377- network_key_file( )
381+ "<mock executable> key generate-node-key --chain {}/chain_spec .json --file {}" ,
382+ DATA_PATH , network_key_file( )
378383 ) ,
379384 "irrelevant" ,
380385 ) ,
381386 ] ) ;
382387
383- let result = generate_network_key ( & default_config ( ) , "path/to/chain-spec .json", & context) ;
388+ let result = generate_network_key ( & default_config ( ) , & format ! ( "{}/chain_spec .json", DATA_PATH ) , & context) ;
384389
385390 assert ! ( result. is_ok( ) ) ;
386391 }
0 commit comments