mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-25 08:00:22 +00:00
Merge remote-tracking branch 'XRPLF/develop' into ximinez/online-delete-gaps
* XRPLF/develop: (22 commits) test: Add null check unit test for `Oracle::aggregatePrice` (7306) ci: Patch conan recipe for Nix to be able to use on macOS (7532) ci: Run sanitizers on release builds too (7527) fix: Correct hybrid offer deletion on credential expiry (6843) ci: Make sanitizer flags lists in the profile, not a string (7449) ci: Make configurations launch on certain event types (7447) fix: Add [[maybe_unused]] to fix320Enabled for assert=OFF builds (7446) ci: Add `gh` and `file` to nix packages (7444) fix: Disable transaction invariants (7409) perf: Dispatch "hasInvalidAmount()" on type tag instead of dynamic_cast (7402) refactor: Retire fixUniversalNumber amendment (5962) test: Do not create data directory for memory databases (7323) ci: Launch upload-conan-deps on profile change (7442) fix: Fix Number comparison operator (7406) feat: Use C++ 23 standard (7431) refactor: Introduce XRPL_ASSERT_IF for amendment-gated assertions (7378) refactor: Change config section and key string literals into constants (7095) refactor: Use `std::move` and `std::string_view` where possible (7424) refactor: Use const function arguments where possible (7423) ci: Use XRPLF/actions build-multiarch-image workflow (7428) ...
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
#include <test/jtx/amount.h>
|
||||
|
||||
#include <xrpld/core/Config.h>
|
||||
#include <xrpld/core/ConfigSections.h>
|
||||
|
||||
#include <xrpl/config/Constants.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
@@ -29,33 +30,33 @@ setupConfigForUnitTests(Config& cfg)
|
||||
// The Beta API (currently v2) is always available to tests
|
||||
cfg.betaRpcApi = true;
|
||||
|
||||
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[PORT_PEER].set("ip", getEnvLocalhostAddr());
|
||||
cfg[Sections::kServer].append(Sections::kPortPeer);
|
||||
cfg[Sections::kPortPeer].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
|
||||
// Using port 0 asks the operating system to allocate an unused port, which
|
||||
// can be obtained after a "bind" call.
|
||||
// Works for all system (Linux, Windows, Unix, Mac).
|
||||
// Check https://man7.org/linux/man-pages/man7/ip.7.html
|
||||
// "ip_local_port_range" section for more info
|
||||
cfg[PORT_PEER].set("port", "0");
|
||||
cfg[PORT_PEER].set("protocol", "peer");
|
||||
cfg[Sections::kPortPeer].set(Keys::kPort, "0");
|
||||
cfg[Sections::kPortPeer].set(Keys::kProtocol, "peer");
|
||||
|
||||
cfg["server"].append(PORT_RPC);
|
||||
cfg[PORT_RPC].set("ip", getEnvLocalhostAddr());
|
||||
cfg[PORT_RPC].set("admin", getEnvLocalhostAddr());
|
||||
cfg[PORT_RPC].set("port", "0");
|
||||
cfg[PORT_RPC].set("protocol", "http,ws2");
|
||||
cfg[Sections::kServer].append(Sections::kPortRpc);
|
||||
cfg[Sections::kPortRpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
cfg[Sections::kPortRpc].set(Keys::kAdmin, getEnvLocalhostAddr());
|
||||
cfg[Sections::kPortRpc].set(Keys::kPort, "0");
|
||||
cfg[Sections::kPortRpc].set(Keys::kProtocol, "http,ws2");
|
||||
|
||||
cfg["server"].append(PORT_WS);
|
||||
cfg[PORT_WS].set("ip", getEnvLocalhostAddr());
|
||||
cfg[PORT_WS].set("admin", getEnvLocalhostAddr());
|
||||
cfg[PORT_WS].set("port", "0");
|
||||
cfg[PORT_WS].set("protocol", "ws");
|
||||
cfg[Sections::kServer].append(Sections::kPortWs);
|
||||
cfg[Sections::kPortWs].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
cfg[Sections::kPortWs].set(Keys::kAdmin, getEnvLocalhostAddr());
|
||||
cfg[Sections::kPortWs].set(Keys::kPort, "0");
|
||||
cfg[Sections::kPortWs].set(Keys::kProtocol, "ws");
|
||||
cfg.sslVerify = false;
|
||||
}
|
||||
|
||||
@@ -64,44 +65,44 @@ namespace jtx {
|
||||
std::unique_ptr<Config>
|
||||
online_delete(std::unique_ptr<Config> cfg, std::uint32_t deleteInterval)
|
||||
{
|
||||
cfg->ledgerHistory = deleteInterval;
|
||||
auto& section = cfg->section(ConfigSection::nodeDatabase());
|
||||
section.set("online_delete", std::to_string(deleteInterval));
|
||||
cfg->ledgerHistory = kDeleteInterval;
|
||||
auto& section = cfg->section(Sections::kNodeDatabase);
|
||||
section.set(Keys::kOnlineDelete, std::to_string(kDeleteInterval));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
noAdmin(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;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
secureGateway(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
(*cfg)[PORT_RPC].set("admin", "");
|
||||
(*cfg)[PORT_WS].set("admin", "");
|
||||
(*cfg)[PORT_RPC].set("secure_gateway", getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortRpc].set(Keys::kAdmin, "");
|
||||
(*cfg)[Sections::kPortWs].set(Keys::kAdmin, "");
|
||||
(*cfg)[Sections::kPortRpc].set(Keys::kSecureGateway, getEnvLocalhostAddr());
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
adminLocalnet(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
(*cfg)[PORT_RPC].set("admin", "127.0.0.0/8");
|
||||
(*cfg)[PORT_WS].set("admin", "127.0.0.0/8");
|
||||
(*cfg)[Sections::kPortRpc].set(Keys::kAdmin, "127.0.0.0/8");
|
||||
(*cfg)[Sections::kPortWs].set(Keys::kAdmin, "127.0.0.0/8");
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
secureGatewayLocalnet(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
(*cfg)[PORT_RPC].set("admin", "");
|
||||
(*cfg)[PORT_WS].set("admin", "");
|
||||
(*cfg)[PORT_RPC].set("secure_gateway", "127.0.0.0/8");
|
||||
(*cfg)[PORT_WS].set("secure_gateway", "127.0.0.0/8");
|
||||
(*cfg)[Sections::kPortRpc].set(Keys::kAdmin, "");
|
||||
(*cfg)[Sections::kPortWs].set(Keys::kAdmin, "");
|
||||
(*cfg)[Sections::kPortRpc].set(Keys::kSecureGateway, "127.0.0.0/8");
|
||||
(*cfg)[Sections::kPortWs].set(Keys::kSecureGateway, "127.0.0.0/8");
|
||||
return cfg;
|
||||
}
|
||||
std::unique_ptr<Config>
|
||||
@@ -117,7 +118,7 @@ std::unique_ptr<Config>
|
||||
validator(std::unique_ptr<Config> cfg, std::string const& seed)
|
||||
{
|
||||
// If the config has valid validation keys then we run as a validator.
|
||||
cfg->section(SECTION_VALIDATION_SEED)
|
||||
cfg->section(Sections::kValidationSeed)
|
||||
.append(std::vector<std::string>{seed.empty() ? kDefaultSeed : seed});
|
||||
return cfg;
|
||||
}
|
||||
@@ -125,20 +126,20 @@ validator(std::unique_ptr<Config> cfg, std::string const& seed)
|
||||
std::unique_ptr<Config>
|
||||
addGrpcConfig(std::unique_ptr<Config> cfg)
|
||||
{
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ip", getEnvLocalhostAddr());
|
||||
(*cfg)[SECTION_PORT_GRPC].set("port", "0");
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kPort, "0");
|
||||
return cfg;
|
||||
}
|
||||
|
||||
std::unique_ptr<Config>
|
||||
addGrpcConfigWithSecureGateway(std::unique_ptr<Config> cfg, std::string const& secureGateway)
|
||||
{
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ip", getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
|
||||
// Check https://man7.org/linux/man-pages/man7/ip.7.html
|
||||
// "ip_local_port_range" section for using 0 ports
|
||||
(*cfg)[SECTION_PORT_GRPC].set("port", "0");
|
||||
(*cfg)[SECTION_PORT_GRPC].set("secure_gateway", secureGateway);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kPort, "0");
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSecureGateway, secureGateway);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -148,10 +149,10 @@ addGrpcConfigWithTLS(
|
||||
std::string const& certPath,
|
||||
std::string const& keyPath)
|
||||
{
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ip", getEnvLocalhostAddr());
|
||||
(*cfg)[SECTION_PORT_GRPC].set("port", "0");
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_cert", certPath);
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_key", keyPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kPort, "0");
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslCert, certPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslKey, keyPath);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -162,11 +163,11 @@ addGrpcConfigWithTLSAndClientCA(
|
||||
std::string const& keyPath,
|
||||
std::string const& clientCAPath)
|
||||
{
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ip", getEnvLocalhostAddr());
|
||||
(*cfg)[SECTION_PORT_GRPC].set("port", "0");
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_cert", certPath);
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_key", keyPath);
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_client_ca", clientCAPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kPort, "0");
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslCert, certPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslKey, keyPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslClientCa, clientCAPath);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -177,11 +178,11 @@ addGrpcConfigWithTLSAndCertChain(
|
||||
std::string const& keyPath,
|
||||
std::string const& certChainPath)
|
||||
{
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ip", getEnvLocalhostAddr());
|
||||
(*cfg)[SECTION_PORT_GRPC].set("port", "0");
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_cert", certPath);
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_key", keyPath);
|
||||
(*cfg)[SECTION_PORT_GRPC].set("ssl_cert_chain", certChainPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kIp, getEnvLocalhostAddr());
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kPort, "0");
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslCert, certPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslKey, keyPath);
|
||||
(*cfg)[Sections::kPortGrpc].set(Keys::kSslCertChain, certChainPath);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -191,13 +192,13 @@ makeConfig(
|
||||
std::map<std::string, std::string> extraVoting)
|
||||
{
|
||||
auto p = test::jtx::envconfig();
|
||||
auto& section = p->section("transaction_queue");
|
||||
section.set("ledgers_in_queue", "2");
|
||||
section.set("minimum_queue_size", "2");
|
||||
section.set("min_ledgers_to_compute_size_limit", "3");
|
||||
section.set("max_ledger_counts_to_store", "100");
|
||||
section.set("retry_sequence_percent", "25");
|
||||
section.set("normal_consensus_increase_percent", "0");
|
||||
auto& section = p->section(Sections::kTransactionQueue);
|
||||
section.set(Keys::kLedgersInQueue, "2");
|
||||
section.set(Keys::kMinimumQueueSize, "2");
|
||||
section.set(Keys::kMinLedgersToComputeSizeLimit, "3");
|
||||
section.set(Keys::kMaxLedgerCountsToStore, "100");
|
||||
section.set(Keys::kRetrySequencePercent, "25");
|
||||
section.set(Keys::kNormalConsensusIncreasePercent, "0");
|
||||
|
||||
for (auto const& [k, v] : extraTxQ)
|
||||
section.set(k, v);
|
||||
@@ -206,14 +207,14 @@ makeConfig(
|
||||
// a FeeVote
|
||||
if (!extraVoting.empty())
|
||||
{
|
||||
auto& votingSection = p->section("voting");
|
||||
auto& votingSection = p->section(Sections::kVoting);
|
||||
for (auto const& [k, v] : extraVoting)
|
||||
{
|
||||
votingSection.set(k, v);
|
||||
}
|
||||
|
||||
// In order for the vote to occur, we must run as a validator
|
||||
p->section("validation_seed").legacy("shUwVw52ofnCUX5m7kPTKzJdr4HEH");
|
||||
p->section(Sections::kValidationSeed).legacy("shUwVw52ofnCUX5m7kPTKzJdr4HEH");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user