refactor: Change config section and key string literals into constants (#7095)

Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
This commit is contained in:
Bart
2026-06-09 10:58:21 -04:00
committed by GitHub
parent c9769d1add
commit c552eb333f
83 changed files with 1262 additions and 1029 deletions

View File

@@ -4,11 +4,11 @@
#include <test/unit_test/SuiteJournal.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/beast/rfc2616.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/config/Constants.h>
#include <xrpl/server/Handoff.h>
#include <xrpl/server/Port.h>
#include <xrpl/server/Server.h>
@@ -396,7 +396,7 @@ public:
Env const env{
*this,
envconfig([](std::unique_ptr<Config> cfg) {
(*cfg).deprecatedClearSection("port_rpc");
(*cfg).deprecatedClearSection(Sections::kPortRpc);
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -407,8 +407,8 @@ public:
Env const env{
*this,
envconfig([](std::unique_ptr<Config> cfg) {
(*cfg).deprecatedClearSection("port_rpc");
(*cfg)["port_rpc"].set("ip", getEnvLocalhostAddr());
(*cfg).deprecatedClearSection(Sections::kPortRpc);
(*cfg)[Sections::kPortRpc].set(Keys::kIp, getEnvLocalhostAddr());
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -419,9 +419,9 @@ public:
Env const env{
*this,
envconfig([](std::unique_ptr<Config> cfg) {
(*cfg).deprecatedClearSection("port_rpc");
(*cfg)["port_rpc"].set("ip", getEnvLocalhostAddr());
(*cfg)["port_rpc"].set("port", "0");
(*cfg).deprecatedClearSection(Sections::kPortRpc);
(*cfg)[Sections::kPortRpc].set(Keys::kIp, getEnvLocalhostAddr());
(*cfg)[Sections::kPortRpc].set(Keys::kPort, "0");
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -433,7 +433,7 @@ public:
Env const env{
*this,
envconfig([](std::unique_ptr<Config> cfg) {
(*cfg)["server"].set("port", "0");
(*cfg)[Sections::kServer].set(Keys::kPort, "0");
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -445,10 +445,10 @@ public:
Env const env{
*this,
envconfig([](std::unique_ptr<Config> cfg) {
(*cfg).deprecatedClearSection("port_rpc");
(*cfg)["port_rpc"].set("ip", getEnvLocalhostAddr());
(*cfg)["port_rpc"].set("port", "8081");
(*cfg)["port_rpc"].set("protocol", "");
(*cfg).deprecatedClearSection(Sections::kPortRpc);
(*cfg)[Sections::kPortRpc].set(Keys::kIp, getEnvLocalhostAddr());
(*cfg)[Sections::kPortRpc].set(Keys::kPort, "8081");
(*cfg)[Sections::kPortRpc].set(Keys::kProtocol, "");
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -462,22 +462,22 @@ public:
*this,
envconfig([](std::unique_ptr<Config> cfg) {
cfg = std::make_unique<Config>();
cfg->overwrite(ConfigSection::nodeDatabase(), "type", "memory");
cfg->overwrite(ConfigSection::nodeDatabase(), "path", "main");
cfg->deprecatedClearSection(ConfigSection::importNodeDatabase());
cfg->legacy("database_path", "");
cfg->overwrite(Sections::kNodeDatabase, Keys::kType, "memory");
cfg->overwrite(Sections::kNodeDatabase, Keys::kPath, "main");
cfg->deprecatedClearSection(Sections::kImportNodeDatabase);
cfg->legacy(Sections::kDatabasePath, "");
cfg->setupControl(true, true, true);
(*cfg)["port_peer"].set("ip", getEnvLocalhostAddr());
(*cfg)["port_peer"].set("port", "8080");
(*cfg)["port_peer"].set("protocol", "peer");
(*cfg)["port_rpc"].set("ip", getEnvLocalhostAddr());
(*cfg)["port_rpc"].set("port", "8081");
(*cfg)["port_rpc"].set("protocol", "http,ws2");
(*cfg)["port_rpc"].set("admin", getEnvLocalhostAddr());
(*cfg)["port_ws"].set("ip", getEnvLocalhostAddr());
(*cfg)["port_ws"].set("port", "8082");
(*cfg)["port_ws"].set("protocol", "ws");
(*cfg)["port_ws"].set("admin", getEnvLocalhostAddr());
(*cfg)[Sections::kPortPeer].set(Keys::kIp, getEnvLocalhostAddr());
(*cfg)[Sections::kPortPeer].set(Keys::kPort, "8080");
(*cfg)[Sections::kPortPeer].set(Keys::kProtocol, "peer");
(*cfg)[Sections::kPortRpc].set(Keys::kIp, getEnvLocalhostAddr());
(*cfg)[Sections::kPortRpc].set(Keys::kPort, "8081");
(*cfg)[Sections::kPortRpc].set(Keys::kProtocol, "http,ws2");
(*cfg)[Sections::kPortRpc].set(Keys::kAdmin, getEnvLocalhostAddr());
(*cfg)[Sections::kPortWs].set(Keys::kIp, getEnvLocalhostAddr());
(*cfg)[Sections::kPortWs].set(Keys::kPort, "8082");
(*cfg)[Sections::kPortWs].set(Keys::kProtocol, "ws");
(*cfg)[Sections::kPortWs].set(Keys::kAdmin, getEnvLocalhostAddr());
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};
@@ -491,14 +491,14 @@ public:
*this,
envconfig([](std::unique_ptr<Config> cfg) {
cfg = std::make_unique<Config>();
cfg->overwrite(ConfigSection::nodeDatabase(), "type", "memory");
cfg->overwrite(ConfigSection::nodeDatabase(), "path", "main");
cfg->deprecatedClearSection(ConfigSection::importNodeDatabase());
cfg->legacy("database_path", "");
cfg->overwrite(Sections::kNodeDatabase, Keys::kType, "memory");
cfg->overwrite(Sections::kNodeDatabase, Keys::kPath, "main");
cfg->deprecatedClearSection(Sections::kImportNodeDatabase);
cfg->legacy(Sections::kDatabasePath, "");
cfg->setupControl(true, true, true);
(*cfg)["server"].append("port_peer");
(*cfg)["server"].append("port_rpc");
(*cfg)["server"].append("port_ws");
(*cfg)[Sections::kServer].append(Sections::kPortPeer);
(*cfg)[Sections::kServer].append(Sections::kPortRpc);
(*cfg)[Sections::kServer].append(Sections::kPortWs);
return cfg;
}),
std::make_unique<CaptureLogs>(&messages)};