refactor: Replace all old instances of Config with New Config (#1627)

Fixes #1184 
Previous PR's found [here](https://github.com/XRPLF/clio/pull/1593) and
[here](https://github.com/XRPLF/clio/pull/1544)
This commit is contained in:
Peter Chen
2024-12-16 15:33:32 -08:00
committed by GitHub
parent b53cfd0ec1
commit 3c4903a339
103 changed files with 1624 additions and 898 deletions

View File

@@ -19,7 +19,9 @@
#include "rpc/common/impl/APIVersionParser.hpp"
#include "util/LoggerFixtures.hpp"
#include "util/config/Config.hpp"
#include "util/newconfig/ConfigDefinition.hpp"
#include "util/newconfig/ConfigValue.hpp"
#include "util/newconfig/Types.hpp"
#include <boost/json/parse.hpp>
#include <fmt/core.h>
@@ -29,6 +31,7 @@ constexpr static auto DEFAULT_API_VERSION = 5u;
constexpr static auto MIN_API_VERSION = 2u;
constexpr static auto MAX_API_VERSION = 10u;
using namespace util::config;
using namespace rpc::impl;
namespace json = boost::json;
@@ -93,18 +96,13 @@ TEST_F(RPCAPIVersionTest, ReturnsParsedVersionIfAllPreconditionsAreMet)
TEST_F(RPCAPIVersionTest, GetsValuesFromConfigCorrectly)
{
util::Config const cfg{json::parse(fmt::format(
R"({{
"min": {},
"max": {},
"default": {}
}})",
MIN_API_VERSION,
MAX_API_VERSION,
DEFAULT_API_VERSION
))};
ClioConfigDefinition cfg{
{"api_version.min", ConfigValue{ConfigType::Integer}.defaultValue(MIN_API_VERSION)},
{"api_version.max", ConfigValue{ConfigType::Integer}.defaultValue(MAX_API_VERSION)},
{"api_version.default", ConfigValue{ConfigType::Integer}.defaultValue(DEFAULT_API_VERSION)}
};
ProductionAPIVersionParser const configuredParser{cfg};
ProductionAPIVersionParser const configuredParser{cfg.getObject("api_version")};
{
auto ver = configuredParser.parse(json::parse(R"({"api_version": 2})").as_object());