Skip to content

Commit eb202ea

Browse files
MarcoFalkelaanwj
authored andcommitted
test: Add test for config file parsing errors
Github-Pull: #14105 Rebased-From: ed2332a Tree-SHA512: 17fa88a2848f1c9c9c8a127b5ea4c45761ce8e06a609dd40f8e90bb9117d88c9d2c81e752c9c0f1a44ecadbb5bedd2973bc4548da2a6d463c789797191e85ab1
1 parent 83aafd5 commit eb202ea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/functional/feature_config_args.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,29 @@ def set_test_params(self):
1414
self.setup_clean_chain = True
1515
self.num_nodes = 1
1616

17+
def test_config_file_parser(self):
18+
# Assume node is stopped
19+
20+
inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
21+
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
22+
conf.write('includeconf={}\n'.format(inc_conf_file_path))
23+
24+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
25+
conf.write('-dash=1\n')
26+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 1: -dash=1, options in configuration file must be specified without leading -')
27+
28+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
29+
conf.write('nono\n')
30+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 1: nono, if you intended to specify a negated option, use nono=1 instead')
31+
32+
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
33+
conf.write('') # clear
34+
1735
def run_test(self):
1836
self.stop_node(0)
37+
38+
self.test_config_file_parser()
39+
1940
# Remove the -datadir argument so it doesn't override the config file
2041
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]
2142

0 commit comments

Comments
 (0)