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

@@ -3,6 +3,7 @@
#include <xrpl/basics/chrono.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/config/Constants.h>
#include <xrpl/core/HashRouter.h>
#include <chrono>
@@ -274,9 +275,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// non-default
auto& h = cfg.section("hashrouter");
h.set("hold_time", "600");
h.set("relay_time", "15");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "600");
h.set(Keys::kRelayTime, "15");
auto const setup = setupHashRouter(cfg);
BEAST_EXPECT(setup.holdTime == 600s);
BEAST_EXPECT(setup.relayTime == 15s);
@@ -284,9 +285,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// equal
auto& h = cfg.section("hashrouter");
h.set("hold_time", "400");
h.set("relay_time", "400");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "400");
h.set(Keys::kRelayTime, "400");
auto const setup = setupHashRouter(cfg);
BEAST_EXPECT(setup.holdTime == 400s);
BEAST_EXPECT(setup.relayTime == 400s);
@@ -294,9 +295,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// wrong order
auto& h = cfg.section("hashrouter");
h.set("hold_time", "60");
h.set("relay_time", "120");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "60");
h.set(Keys::kRelayTime, "120");
try
{
setupHashRouter(cfg);
@@ -313,9 +314,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// too small hold
auto& h = cfg.section("hashrouter");
h.set("hold_time", "10");
h.set("relay_time", "120");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "10");
h.set(Keys::kRelayTime, "120");
try
{
setupHashRouter(cfg);
@@ -333,9 +334,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// too small relay
auto& h = cfg.section("hashrouter");
h.set("hold_time", "500");
h.set("relay_time", "6");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "500");
h.set(Keys::kRelayTime, "6");
try
{
setupHashRouter(cfg);
@@ -352,9 +353,9 @@ class HashRouter_test : public beast::unit_test::Suite
{
Config cfg;
// garbage
auto& h = cfg.section("hashrouter");
h.set("hold_time", "alice");
h.set("relay_time", "bob");
auto& h = cfg.section(Sections::kHashrouter);
h.set(Keys::kHoldTime, "alice");
h.set(Keys::kRelayTime, "bob");
auto const setup = setupHashRouter(cfg);
// The set function ignores values that don't convert, so the
// defaults are left unchanged