No required options in TOML parsing (#2245)
This commit is contained in:
parent
6f84d60fe8
commit
c906a1c0f4
3 changed files with 59 additions and 8 deletions
|
|
@ -447,6 +447,36 @@ TEST (toml, daemon_config_deserialize_no_defaults)
|
|||
ASSERT_NE (conf.node.stat_config.log_samples_filename, defaults.node.stat_config.log_samples_filename);
|
||||
}
|
||||
|
||||
/** There should be no required values **/
|
||||
TEST (toml, daemon_config_no_required)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
// A config with no values, only categories
|
||||
ss << R"toml(
|
||||
[node]
|
||||
[node.diagnostics.txn_tracking]
|
||||
[node.httpcallback]
|
||||
[node.ipc.local]
|
||||
[node.ipc.tcp]
|
||||
[node.logging]
|
||||
[node.statistics.log]
|
||||
[node.statistics.sampling]
|
||||
[node.websocket]
|
||||
[opencl]
|
||||
[rpc]
|
||||
[rpc.child_process]
|
||||
)toml";
|
||||
|
||||
nano::tomlconfig toml;
|
||||
toml.read (ss);
|
||||
nano::daemon_config conf;
|
||||
nano::daemon_config defaults;
|
||||
conf.deserialize_toml (toml);
|
||||
|
||||
ASSERT_FALSE (toml.get_error ()) << toml.get_error ().get_message ();
|
||||
}
|
||||
|
||||
/** Deserialize an rpc config with non-default values */
|
||||
TEST (toml, rpc_config_deserialize_no_defaults)
|
||||
{
|
||||
|
|
@ -485,3 +515,24 @@ TEST (toml, rpc_config_deserialize_no_defaults)
|
|||
ASSERT_NE (conf.rpc_process.ipc_port, defaults.rpc_process.ipc_port);
|
||||
ASSERT_NE (conf.rpc_process.num_ipc_connections, defaults.rpc_process.num_ipc_connections);
|
||||
}
|
||||
|
||||
/** There should be no required values **/
|
||||
TEST (toml, rpc_config_no_required)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
// A config with no values, only categories
|
||||
ss << R"toml(
|
||||
[version]
|
||||
[process]
|
||||
[secure]
|
||||
)toml";
|
||||
|
||||
nano::tomlconfig toml;
|
||||
toml.read (ss);
|
||||
nano::rpc_config conf;
|
||||
nano::rpc_config defaults;
|
||||
conf.deserialize_toml (toml);
|
||||
|
||||
ASSERT_FALSE (toml.get_error ()) << toml.get_error ().get_message ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ nano::error nano::rpc_secure_config::serialize_toml (nano::tomlconfig & toml) co
|
|||
|
||||
nano::error nano::rpc_secure_config::deserialize_toml (nano::tomlconfig & toml)
|
||||
{
|
||||
toml.get_required<bool> ("enable", enable);
|
||||
toml.get_required<bool> ("verbose_logging", verbose_logging);
|
||||
toml.get_required<std::string> ("server_key_passphrase", server_key_passphrase);
|
||||
toml.get_required<std::string> ("server_cert_path", server_cert_path);
|
||||
toml.get_required<std::string> ("server_key_path", server_key_path);
|
||||
toml.get_required<std::string> ("server_dh_path", server_dh_path);
|
||||
toml.get_required<std::string> ("client_certs_path", client_certs_path);
|
||||
toml.get<bool> ("enable", enable);
|
||||
toml.get<bool> ("verbose_logging", verbose_logging);
|
||||
toml.get<std::string> ("server_key_passphrase", server_key_passphrase);
|
||||
toml.get<std::string> ("server_cert_path", server_cert_path);
|
||||
toml.get<std::string> ("server_key_path", server_key_path);
|
||||
toml.get<std::string> ("server_dh_path", server_dh_path);
|
||||
toml.get<std::string> ("client_certs_path", client_certs_path);
|
||||
return toml.get_error ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ nano::error nano::websocket::config::serialize_toml (nano::tomlconfig & toml) co
|
|||
nano::error nano::websocket::config::deserialize_toml (nano::tomlconfig & toml)
|
||||
{
|
||||
toml.get<bool> ("enable", enabled);
|
||||
toml.get_required<boost::asio::ip::address_v6> ("address", address);
|
||||
toml.get<boost::asio::ip::address_v6> ("address", address);
|
||||
toml.get<uint16_t> ("port", port);
|
||||
return toml.get_error ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue