mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge #15335: Fix lack of warning of unrecognized section names
1a7ba84e11 Fix lack of warning of unrecognized section names (Akio Nakamura)
Pull request description:
In #14708, It was introduced that to warn when unrecognized section names are exist in the config file.
But ```m_config_sections.clear()``` in ```ArgsManager::ReadConfigStream()``` is called every time when reading each configuration file, so it can warn about only last reading file if ```includeconf``` exists.
This PR fix lack of warning by collecting all section names by moving ```m_config_sections.clear()``` to ```ArgsManager::ReadConfigFiles()``` .
Also add a test code to confirm this situation.
Tree-SHA512: 26aa0cbe3e4ae2e58cbe73d4492ee5cf465fd4c3e5df2c8ca7e282b627df9e637267af1e3816386b1dc6db2398b31936925ce0e432219fec3a9b3398f01e3e65
This commit is contained in:
@@ -41,12 +41,20 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
|
||||
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
|
||||
|
||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||
conf.write('testnot.datadir=1\n[testnet]\n')
|
||||
self.restart_node(0)
|
||||
self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.')
|
||||
inc_conf_file2_path = os.path.join(self.nodes[0].datadir, 'include2.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_file2_path))
|
||||
|
||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||
conf.write('testnot.datadir=1\n')
|
||||
with open(inc_conf_file2_path, 'w', encoding='utf-8') as conf:
|
||||
conf.write('[testnet]\n')
|
||||
self.restart_node(0)
|
||||
self.nodes[0].stop_node(expected_stderr='Warning: ' + inc_conf_file_path + ':1 Section [testnot] is not recognized.' + os.linesep + 'Warning: ' + inc_conf_file2_path + ':1 Section [testnet] is not recognized.')
|
||||
|
||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||
conf.write('') # clear
|
||||
with open(inc_conf_file2_path, 'w', encoding='utf-8') as conf:
|
||||
conf.write('') # clear
|
||||
|
||||
def run_test(self):
|
||||
|
||||
Reference in New Issue
Block a user