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

@@ -9,10 +9,10 @@
#include <test/jtx/sig.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/basics/strHex.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/to_string.h>
#include <xrpl/protocol/KeyType.h>
#include <xrpl/protocol/Serializer.h>
@@ -20,6 +20,7 @@
#include <xrpl/server/NetworkOPs.h>
#include <memory>
#include <string>
namespace xrpl {
@@ -30,7 +31,7 @@ class AmendmentBlocked_test : public beast::unit_test::Suite
{
using namespace test::jtx;
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->loadFromString("[" SECTION_SIGNING_SUPPORT "]\ntrue");
cfg->loadFromString(std::string("[") + Sections::kSigningSupport + "]\ntrue");
return cfg;
})};
auto const gw = Account{"gateway"};

View File

@@ -6,6 +6,7 @@
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/to_string.h>
#include <xrpl/ledger/AmendmentTable.h>
@@ -276,8 +277,8 @@ class Feature_test : public beast::unit_test::Suite
using namespace test::jtx;
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
(*cfg)["port_rpc"].set("admin", "");
(*cfg)["port_ws"].set("admin", "");
(*cfg)[Sections::kPortRpc].set(Keys::kAdmin, "");
(*cfg)[Sections::kPortWs].set(Keys::kAdmin, "");
return cfg;
})};

View File

@@ -12,12 +12,12 @@
#include <test/jtx/trust.h>
#include <xrpld/app/misc/TxQ.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpld/rpc/Role.h>
#include <xrpld/rpc/detail/TransactionSign.h>
#include <xrpl/basics/contract.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_reader.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/to_string.h>
@@ -2375,8 +2375,9 @@ public:
testcase("autofill escalated fees");
using namespace test::jtx;
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->loadFromString("[" SECTION_SIGNING_SUPPORT "]\ntrue");
cfg->section("transaction_queue").set("minimum_txn_in_ledger_standalone", "3");
cfg->loadFromString(std::string("[") + Sections::kSigningSupport + "]\ntrue");
cfg->section(Sections::kTransactionQueue)
.set(Keys::kMinimumTxnInLedgerStandalone, "3");
return cfg;
})};
LoadFeeTrack const& feeTrackOuter = env.app().getFeeTrack();

View File

@@ -15,6 +15,7 @@
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/to_string.h>
#include <xrpl/protocol/ErrorCodes.h>
@@ -431,9 +432,9 @@ class LedgerRPC_test : public beast::unit_test::Suite
testcase("Ledger with Queued Transactions");
using namespace test::jtx;
auto cfg = envconfig([](std::unique_ptr<Config> cfg) {
auto& section = cfg->section("transaction_queue");
section.set("minimum_txn_in_ledger_standalone", "3");
section.set("normal_consensus_increase_percent", "0");
auto& section = cfg->section(Sections::kTransactionQueue);
section.set(Keys::kMinimumTxnInLedgerStandalone, "3");
section.set(Keys::kNormalConsensusIncreasePercent, "0");
return cfg;
});

View File

@@ -4,9 +4,9 @@
#include <test/jtx/envconfig.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/protocol/jss.h>
#include <memory>
@@ -48,7 +48,7 @@ public:
using namespace jtx;
std::string const key = "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7";
Env env{*this, envconfig([&key](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATORS).append(key);
cfg->section(Sections::kValidators).append(key);
return cfg;
})};
{

View File

@@ -8,14 +8,15 @@
#include <test/jtx/pay.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_value.h>
#include <xrpl/protocol/Seed.h>
#include <xrpl/protocol/jss.h>
#include <memory>
#include <string>
#include <utility>
namespace xrpl::test {
@@ -29,7 +30,7 @@ public:
testcase << "Overload " << (useWS ? "WS" : "HTTP") << " RPC client";
using namespace jtx;
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->loadFromString("[" SECTION_SIGNING_SUPPORT "]\ntrue");
cfg->loadFromString(std::string("[") + Sections::kSigningSupport + "]\ntrue");
return noAdmin(std::move(cfg));
})};

View File

@@ -3,9 +3,9 @@
#include <test/jtx/envconfig.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/server/NetworkOPs.h>
@@ -108,9 +108,9 @@ admin = 127.0.0.1
Env env(*this, makeValidatorConfig());
auto const& config = env.app().config();
auto const rpcPort = config["port_rpc"].get<unsigned int>("port");
auto const grpcPort = config[SECTION_PORT_GRPC].get<unsigned int>("port");
auto const wsPort = config["port_ws"].get<unsigned int>("port");
auto const rpcPort = config[Sections::kPortRpc].get<unsigned int>(Keys::kPort);
auto const grpcPort = config[Sections::kPortGrpc].get<unsigned int>(Keys::kPort);
auto const wsPort = config[Sections::kPortWs].get<unsigned int>(Keys::kPort);
BEAST_EXPECT(grpcPort);
BEAST_EXPECT(rpcPort);
BEAST_EXPECT(wsPort);

View File

@@ -21,6 +21,7 @@
#include <xrpl/basics/chrono.h>
#include <xrpl/basics/strHex.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/to_string.h>
#include <xrpl/protocol/ErrorCodes.h>
@@ -429,7 +430,7 @@ class Simulate_test : public beast::unit_test::Suite
using namespace jtx;
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->section("transaction_queue").set("minimum_txn_in_ledger_standalone", "3");
cfg->section(Sections::kTransactionQueue).set(Keys::kMinimumTxnInLedgerStandalone, "3");
return cfg;
}));

View File

@@ -18,12 +18,12 @@
#include <xrpld/app/main/LoadManager.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/basics/UnorderedContainers.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/basics/strHex.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/core/NetworkIDService.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/to_string.h>
@@ -431,9 +431,10 @@ public:
Env env{*this, singleThreadIo(envconfig(validator, "")), features};
auto& cfg = env.app().config();
if (!BEAST_EXPECT(cfg.section(SECTION_VALIDATION_SEED).empty()))
if (!BEAST_EXPECT(cfg.section(Sections::kValidationSeed).empty()))
return;
auto const parsedseed = parseBase58<Seed>(cfg.section(SECTION_VALIDATION_SEED).values()[0]);
auto const parsedseed =
parseBase58<Seed>(cfg.section(Sections::kValidationSeed).values()[0]);
if (BEAST_EXPECT(parsedseed); not parsedseed.has_value())
return;

View File

@@ -4,9 +4,9 @@
#include <test/jtx/envconfig.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/protocol/jss.h>
#include <memory>
@@ -68,7 +68,7 @@ public:
"5AqDedFv5TJa2w0i21eq3MYywLVJZnFOr7C0kw2AiTzSCjIzditQ8=";
Env env{*this, envconfig([&tokenBlob](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATOR_TOKEN).append(tokenBlob);
cfg->section(Sections::kValidatorToken).append(tokenBlob);
return cfg;
})};
{

View File

@@ -5,12 +5,12 @@
#include <xrpld/app/main/BasicApp.h>
#include <xrpld/app/misc/ValidatorSite.h>
#include <xrpld/core/Config.h>
#include <xrpld/core/ConfigSections.h>
#include <xrpl/basics/UnorderedContainers.h>
#include <xrpl/basics/chrono.h>
#include <xrpl/basics/strHex.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/json/json_value.h>
#include <xrpl/protocol/KeyType.h>
#include <xrpl/protocol/PublicKey.h>
@@ -90,7 +90,7 @@ public:
*this,
envconfig([&keys](std::unique_ptr<Config> cfg) {
for (auto const& key : keys)
cfg->section(SECTION_VALIDATORS).append(key);
cfg->section(Sections::kValidators).append(key);
return cfg;
}),
};
@@ -200,8 +200,8 @@ public:
Env env{
*this,
envconfig([&](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
cfg->section(Sections::kValidatorListSites).append(siteURI);
cfg->section(Sections::kValidatorListKeys)
.append(strHex(server->publisherPublic()));
return cfg;
}),
@@ -260,8 +260,8 @@ public:
Env env{
*this,
envconfig([&](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
cfg->section(Sections::kValidatorListSites).append(siteURI);
cfg->section(Sections::kValidatorListKeys)
.append(strHex(server->publisherPublic()));
return cfg;
}),
@@ -323,8 +323,8 @@ public:
Env env{
*this,
envconfig([&](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
cfg->section(Sections::kValidatorListSites).append(siteURI);
cfg->section(Sections::kValidatorListKeys)
.append(strHex(server->publisherPublic()));
return cfg;
}),
@@ -416,8 +416,8 @@ public:
Env env{
*this,
envconfig([&](std::unique_ptr<Config> cfg) {
cfg->section(SECTION_VALIDATOR_LIST_SITES).append(siteURI);
cfg->section(SECTION_VALIDATOR_LIST_KEYS)
cfg->section(Sections::kValidatorListSites).append(siteURI);
cfg->section(Sections::kValidatorListKeys)
.append(strHex(server->publisherPublic()));
return cfg;
}),