Skip to content

Commit

Permalink
test: Add test for config file parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke authored and laanwj committed Sep 6, 2018
1 parent a66c0f7 commit ed2332a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,29 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def test_config_file_parser(self):
# Assume node is stopped

inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
conf.write('includeconf={}\n'.format(inc_conf_file_path))

with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
conf.write('-dash=1\n')
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 -')

with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
conf.write('nono\n')
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')

with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
conf.write('') # clear

def run_test(self):
self.stop_node(0)

self.test_config_file_parser()

# Remove the -datadir argument so it doesn't override the config file
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]

Expand Down

0 comments on commit ed2332a

Please sign in to comment.