@@ -39,6 +39,29 @@ def setup_nodes(self):
39
39
self .nodes [0 ].debug_log_path .parent .mkdir ()
40
40
self .nodes [0 ].debug_log_path .touch ()
41
41
42
+ def test_dir_config (self ):
43
+ self .log .info ('Error should be emitted if config file is a directory' )
44
+ conf_path = self .nodes [0 ].datadir_path / 'bitcoin.conf'
45
+ os .rename (conf_path , conf_path .with_suffix ('.confbkp' ))
46
+ conf_path .mkdir ()
47
+ self .stop_node (0 )
48
+ self .nodes [0 ].assert_start_raises_init_error (
49
+ extra_args = ['-regtest' ],
50
+ expected_msg = f'Error: Error reading configuration file: Config file "{ conf_path } " is a directory.' ,
51
+ )
52
+ conf_path .rmdir ()
53
+ os .rename (conf_path .with_suffix ('.confbkp' ), conf_path )
54
+
55
+ self .log .debug ('Verifying includeconf directive pointing to directory is caught' )
56
+ with open (conf_path , 'a' , encoding = 'utf-8' ) as conf :
57
+ conf .write (f'includeconf={ self .nodes [0 ].datadir_path } \n ' )
58
+ self .nodes [0 ].assert_start_raises_init_error (
59
+ extra_args = ['-regtest' ],
60
+ expected_msg = f'Error: Error reading configuration file: Included config file "{ self .nodes [0 ].datadir_path } " is a directory.' ,
61
+ )
62
+
63
+ self .nodes [0 ].replace_in_config ([(f'includeconf={ self .nodes [0 ].datadir_path } ' , '' )])
64
+
42
65
def test_negated_config (self ):
43
66
self .log .info ('Disabling configuration via -noconf' )
44
67
@@ -467,6 +490,7 @@ def run_test(self):
467
490
self .test_networkactive ()
468
491
self .test_connect_with_seednode ()
469
492
493
+ self .test_dir_config ()
470
494
self .test_negated_config ()
471
495
self .test_config_file_parser ()
472
496
self .test_config_file_log ()
0 commit comments