mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
refactor: Remove null setting check in GetSetting()
Also rename the "result_complete" variable in GetSettingsList() to "done" to be more consistent with GetSetting(). This change doesn't affect current behavior but could be useful in the future to support dynamically changing settings at runtime and adding new settings sources, because it lets high priority sources reset settings back to default (see test). By removing a special case for null, this change also helps merge code treat settings values more like black boxes, and interfere less with settings parsing and retrieval.
This commit is contained in:
@@ -45,6 +45,19 @@ BOOST_AUTO_TEST_CASE(Simple)
|
||||
CheckValues(settings2, R"("val2")", R"(["val2","val3"])");
|
||||
}
|
||||
|
||||
// Confirm that a high priority setting overrides a lower priority setting even
|
||||
// if the high priority setting is null. This behavior is useful for a high
|
||||
// priority setting source to be able to effectively reset any setting back to
|
||||
// its default value.
|
||||
BOOST_AUTO_TEST_CASE(NullOverride)
|
||||
{
|
||||
util::Settings settings;
|
||||
settings.command_line_options["name"].push_back("value");
|
||||
BOOST_CHECK_EQUAL(R"("value")", GetSetting(settings, "section", "name", false, false).write().c_str());
|
||||
settings.forced_settings["name"] = {};
|
||||
BOOST_CHECK_EQUAL(R"(null)", GetSetting(settings, "section", "name", false, false).write().c_str());
|
||||
}
|
||||
|
||||
// Test different ways settings can be merged, and verify results. This test can
|
||||
// be used to confirm that updates to settings code don't change behavior
|
||||
// unintentionally.
|
||||
|
||||
Reference in New Issue
Block a user