Fix CI unit tests (#5196)

- Add retries for rpc client
- Add dynamic port allocation for rpc servers
This commit is contained in:
Olek
2025-01-28 10:45:59 -05:00
committed by GitHub
parent b6e3453f49
commit 50b8f19cb5
31 changed files with 293 additions and 146 deletions

View File

@@ -24,10 +24,13 @@
#include <xrpl/basics/contract.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/server/Port.h>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <fstream>
#include <iostream>
#include <regex>
namespace ripple {
namespace detail {
@@ -140,12 +143,15 @@ public:
path subDir,
path const& dbPath,
path const& validatorsFile,
bool useCounter = true)
bool useCounter = true,
std::string confContents = "")
: FileDirGuard(
test,
std::move(subDir),
path(Config::configFileName),
configContents(dbPath.string(), validatorsFile.string()),
confContents.empty()
? configContents(dbPath.string(), validatorsFile.string())
: confContents,
useCounter)
, dataDir_(dbPath)
{
@@ -1068,6 +1074,27 @@ trustthesevalidators.gov
BEAST_EXPECT(wss.admin_nets_v4.size() + wss.admin_nets_v6.size() == 1);
}
void
testZeroPort()
{
auto const contents = std::regex_replace(
detail::configContents("", ""),
std::regex("port\\s*=\\s*\\d+"),
"port = 0");
try
{
detail::RippledCfgGuard const cfg(
*this, "testPort", "", "", true, contents);
BEAST_EXPECT(false);
}
catch (std::exception const& ex)
{
BEAST_EXPECT(std::string_view(ex.what()).starts_with(
"Invalid value '0' for key 'port'"));
}
}
void
testWhitespace()
{
@@ -1478,6 +1505,7 @@ r.ripple.com:51235
testSetup(false);
testSetup(true);
testPort();
testZeroPort();
testWhitespace();
testColons();
testComments();