@@ -157,28 +157,33 @@ pub mod scenarios {
157
157
MockIO :: eprint( "if you wish to be included as a permissioned candidate." ) ,
158
158
] )
159
159
}
160
-
161
- pub fn create_temp_chain_spec ( ) -> MockIO {
162
- MockIO :: Group ( vec ! [ MockIO :: new_tmp_dir( ) ] )
163
- }
164
160
}
165
161
166
162
#[ test]
167
163
fn 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
+ ] ) ;
182
187
183
188
let result =
184
189
GenerateKeysCmd :: < MockRuntime > {
@@ -329,14 +334,14 @@ mod generate_network_key {
329
334
MockIO :: run_command( & format!( "mkdir -p {DATA_PATH}/network" ) , "irrelevant" ) ,
330
335
MockIO :: run_command(
331
336
& format!(
332
- "<mock executable> key generate-node-key --chain path/to/chain-spec .json --file {}" ,
333
- network_key_file( )
337
+ "<mock executable> key generate-node-key --chain {}/chain_spec .json --file {}" ,
338
+ DATA_PATH , network_key_file( )
334
339
) ,
335
340
"irrelevant" ,
336
341
) ,
337
342
] ) ;
338
343
339
- let result = generate_network_key ( & default_config ( ) , "path/to/chain-spec .json", & context) ;
344
+ let result = generate_network_key ( & default_config ( ) , & format ! ( "{}/chain_spec .json", DATA_PATH ) , & context) ;
340
345
341
346
assert ! ( result. is_ok( ) ) ;
342
347
}
@@ -353,7 +358,7 @@ mod generate_network_key {
353
358
) ,
354
359
] ) ;
355
360
356
- let result = generate_network_key ( & default_config ( ) , "irrelevant .json", & context) ;
361
+ let result = generate_network_key ( & default_config ( ) , & format ! ( "{}/chain_spec .json", DATA_PATH ) , & context) ;
357
362
358
363
assert ! ( result. is_ok( ) ) ;
359
364
}
@@ -373,14 +378,14 @@ mod generate_network_key {
373
378
MockIO :: run_command( & format!( "mkdir -p {DATA_PATH}/network" ) , "irrelevant" ) ,
374
379
MockIO :: run_command(
375
380
& 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( )
378
383
) ,
379
384
"irrelevant" ,
380
385
) ,
381
386
] ) ;
382
387
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) ;
384
389
385
390
assert ! ( result. is_ok( ) ) ;
386
391
}
0 commit comments