mirror of https://github.com/oxen-io/lokinet
Use 'undeclared handler' for multi-valued 'add-node' config option
This commit is contained in:
parent
feacde7864
commit
c5ff672c79
|
@ -386,15 +386,17 @@ namespace llarp
|
|||
void
|
||||
BootstrapConfig::defineConfigOptions(Configuration& conf)
|
||||
{
|
||||
// TODO: multi-value
|
||||
/*
|
||||
if(key == "add-node")
|
||||
{
|
||||
routers.emplace_back(val.begin(), val.end());
|
||||
}
|
||||
*/
|
||||
(void)conf;
|
||||
// throw std::runtime_error("FIXME");
|
||||
conf.addUndeclaredHandler("bootstrap", [&](string_view, string_view name, string_view value) {
|
||||
if (name != "add-node")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
routers.emplace_back(str(value));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -313,3 +313,20 @@ TEST_CASE("Configuration undeclared handler wrong section", "[config]")
|
|||
REQUIRE_THROWS_WITH(config.addConfigValue("argle", "bar", "val"), "no declared section [argle]");
|
||||
}
|
||||
|
||||
TEST_CASE("Configuration undeclared handler duplicate names", "[config]")
|
||||
{
|
||||
llarp::Configuration config;
|
||||
|
||||
int count = 0;
|
||||
|
||||
config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) {
|
||||
count++;
|
||||
});
|
||||
|
||||
REQUIRE_NOTHROW(config.addConfigValue("foo", "k", "v"));
|
||||
REQUIRE_NOTHROW(config.addConfigValue("foo", "k", "v"));
|
||||
REQUIRE_NOTHROW(config.addConfigValue("foo", "k", "v"));
|
||||
|
||||
REQUIRE(count == 3);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue