Skip to content

Commit fa48405

Browse files
author
MarcoFalke
committed
Warn on unknown rw_settings
1 parent 862fde8 commit fa48405

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/util/system.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,14 @@ bool ArgsManager::ReadSettingsFile(std::vector<std::string>* errors)
426426
SaveErrors(read_errors, errors);
427427
return false;
428428
}
429+
for (const auto& setting : m_settings.rw_settings) {
430+
std::string section;
431+
std::string key = setting.first;
432+
(void)InterpretOption(section, key, /* value */ {}); // Split setting key into section and argname
433+
if (!GetArgFlags('-' + key)) {
434+
LogPrintf("Ignoring unknown rw_settings value %s\n", setting.first);
435+
}
436+
}
429437
return true;
430438
}
431439

test/functional/feature_settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,25 @@ def run_test(self):
3030

3131
# Assert settings are parsed and logged
3232
with settings.open("w") as fp:
33-
json.dump({"string": "string", "num": 5, "bool": True, "null": None, "list": [6,7]}, fp)
33+
json.dump({"string": "string", "num": 5, "bool": True, "null": None, "list": [6, 7]}, fp)
3434
with node.assert_debug_log(expected_msgs=[
35+
'Ignoring unknown rw_settings value bool',
36+
'Ignoring unknown rw_settings value list',
37+
'Ignoring unknown rw_settings value null',
38+
'Ignoring unknown rw_settings value num',
39+
'Ignoring unknown rw_settings value string',
3540
'Setting file arg: string = "string"',
3641
'Setting file arg: num = 5',
3742
'Setting file arg: bool = true',
3843
'Setting file arg: null = null',
39-
'Setting file arg: list = [6,7]']):
44+
'Setting file arg: list = [6,7]',
45+
]):
4046
self.start_node(0)
4147
self.stop_node(0)
4248

4349
# Assert settings are unchanged after shutdown
4450
with settings.open() as fp:
45-
assert_equal(json.load(fp), {"string": "string", "num": 5, "bool": True, "null": None, "list": [6,7]})
51+
assert_equal(json.load(fp), {"string": "string", "num": 5, "bool": True, "null": None, "list": [6, 7]})
4652

4753
# Test invalid json
4854
with settings.open("w") as fp:

0 commit comments

Comments
 (0)