@@ -39,6 +39,29 @@ def setup_nodes(self):
3939 self .nodes [0 ].debug_log_path .parent .mkdir ()
4040 self .nodes [0 ].debug_log_path .touch ()
4141
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+
4265 def test_negated_config (self ):
4366 self .log .info ('Disabling configuration via -noconf' )
4467
@@ -467,6 +490,7 @@ def run_test(self):
467490 self .test_networkactive ()
468491 self .test_connect_with_seednode ()
469492
493+ self .test_dir_config ()
470494 self .test_negated_config ()
471495 self .test_config_file_parser ()
472496 self .test_config_file_log ()
0 commit comments