mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-21 19:18:22 +00:00
Compare commits
39
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
857c8bb809 | ||
|
|
9733f0c724 | ||
|
|
7b9ee47294 | ||
|
|
e145fdb745 | ||
|
|
1d3d5804fa | ||
|
|
4a670f2bb1 | ||
|
|
a863d352c4 | ||
|
|
3920c05258 | ||
|
|
b66666059b | ||
|
|
917e9d3251 | ||
|
|
8c4dcc2919 | ||
|
|
2c18745ad2 | ||
|
|
a2d5aaeba0 | ||
|
|
4ede7f9444 | ||
|
|
5f63a715cb | ||
|
|
8514bf6824 | ||
|
|
8a07170f78 | ||
|
|
d6751b9323 | ||
|
|
9db9761824 | ||
|
|
b433bd3437 | ||
|
|
e53368580e | ||
|
|
8e91253b79 | ||
|
|
c3f1a54ad8 | ||
|
|
3345c9521a | ||
|
|
f64a939b2d | ||
|
|
2b2e6be6b2 | ||
|
|
65cacb3a60 | ||
|
|
a4fe2969b9 | ||
|
|
7edbf8dc15 | ||
|
|
4c77acb295 | ||
|
|
9dc71bd737 | ||
|
|
4ea8284a68 | ||
|
|
9ab82b1481 | ||
|
|
478286c823 | ||
|
|
6c8e7a5397 | ||
|
|
3a46004c0e | ||
|
|
c7b0b91f2c | ||
|
|
17c128cd10 | ||
|
|
9c65cecac7 |
No files matched your search
@@ -31,6 +31,12 @@ on:
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
unittest_args:
|
||||
description: "Additional arguments to pass to rippled when running tests"
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
cmake_target:
|
||||
description: "The CMake target to build."
|
||||
required: true
|
||||
@@ -358,6 +364,7 @@ jobs:
|
||||
working-directory: ${{ runner.os == 'Windows' && format('{0}/{1}', env.BUILD_DIR, inputs.build_type) || env.BUILD_DIR }}
|
||||
env:
|
||||
BUILD_NPROC: ${{ steps.nproc.outputs.nproc }}
|
||||
UNITTEST_ARGS: ${{ inputs.unittest_args }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
# Coverage builds are slower due to instrumentation; use fewer parallel jobs to avoid flakiness
|
||||
|
||||
@@ -45,6 +45,7 @@ jobs:
|
||||
build_type: ${{ matrix.build_type }}
|
||||
ccache_enabled: ${{ inputs.ccache_enabled }}
|
||||
cmake_args: ${{ matrix.cmake_args }}
|
||||
unittest_args: ${{ matrix.unittest_args }}
|
||||
cmake_target: ${{ matrix.cmake_target }}
|
||||
runs_on: ${{ toJSON(matrix.architecture.runner) }}
|
||||
image: ${{ matrix.image || '' }}
|
||||
|
||||
@@ -275,10 +275,6 @@ if(xrpld)
|
||||
patch_nix_binary(xrpld)
|
||||
if(tests)
|
||||
target_compile_definitions(xrpld PUBLIC ENABLE_TESTS)
|
||||
target_compile_definitions(
|
||||
xrpld
|
||||
PRIVATE UNIT_TEST_REFERENCE_FEE=${UNIT_TEST_REFERENCE_FEE}
|
||||
)
|
||||
endif()
|
||||
target_include_directories(
|
||||
xrpld
|
||||
|
||||
@@ -23,12 +23,6 @@ option(assert "Enables asserts, even in release builds" OFF)
|
||||
option(xrpld "Build xrpld" ON)
|
||||
|
||||
option(tests "Build tests" ON)
|
||||
if(tests)
|
||||
# This setting allows making a separate workflow to test fees other than default 10
|
||||
if(NOT UNIT_TEST_REFERENCE_FEE)
|
||||
set(UNIT_TEST_REFERENCE_FEE "10" CACHE STRING "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(benchmark "Build benchmarks" ON)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
@@ -22,6 +23,7 @@ namespace beast::unit_test {
|
||||
class Runner
|
||||
{
|
||||
std::string arg_;
|
||||
std::optional<std::int64_t> referenceFee_;
|
||||
bool default_ = false;
|
||||
bool failed_ = false;
|
||||
bool cond_ = false;
|
||||
@@ -57,6 +59,26 @@ public:
|
||||
return arg_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the reference fee (in drops) for tests.
|
||||
*
|
||||
* If provided, this value is used in every suite that does not override it.
|
||||
*/
|
||||
void
|
||||
referenceFee(std::int64_t fee)
|
||||
{
|
||||
referenceFee_ = fee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reference fee, if any.
|
||||
*/
|
||||
[[nodiscard]] std::optional<std::int64_t> const&
|
||||
referenceFee() const
|
||||
{
|
||||
return referenceFee_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the specified suite.
|
||||
* @return `true` if any conditions failed.
|
||||
|
||||
@@ -308,6 +308,18 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the reference fee associated with the runner.
|
||||
*/
|
||||
std::optional<std::int64_t>
|
||||
referenceFee() const
|
||||
{
|
||||
assert(runner_);
|
||||
if (runner_ == nullptr)
|
||||
return {};
|
||||
return runner_->referenceFee();
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED
|
||||
* @return `true` if the test condition indicates success(a false value)
|
||||
|
||||
@@ -4835,13 +4835,7 @@ private:
|
||||
FeatureBitset const all{testableAmendments()};
|
||||
|
||||
{
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = XRPAmount(1);
|
||||
return cfg;
|
||||
}),
|
||||
all);
|
||||
Env env(*this, all, XRPAmount(1));
|
||||
fund(env, gw_, {alice_}, XRP(20'000), {USD(10'000)});
|
||||
AMM amm(env, gw_, XRP(10'000), USD(10'000));
|
||||
for (auto i = 0; i < kMaxDeletableAmmTrustLines + 10; ++i)
|
||||
@@ -4893,13 +4887,7 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = XRPAmount(1);
|
||||
return cfg;
|
||||
}),
|
||||
all);
|
||||
Env env(*this, all, XRPAmount(1));
|
||||
fund(env, gw_, {alice_}, XRP(20'000), {USD(10'000)});
|
||||
AMM amm(env, gw_, XRP(10'000), USD(10'000));
|
||||
for (auto i = 0; i < (kMaxDeletableAmmTrustLines * 2) + 10; ++i)
|
||||
|
||||
@@ -984,7 +984,7 @@ class FeeVote_test : public beast::unit_test::Suite
|
||||
Env env(*this, testableAmendments() - featureSmartEscrow);
|
||||
|
||||
// establish what the current fees are
|
||||
BEAST_EXPECT(env.current()->fees().base == XRPAmount{UNIT_TEST_REFERENCE_FEE});
|
||||
BEAST_EXPECT(env.current()->fees().base == env.app().config().fees.referenceFee);
|
||||
BEAST_EXPECT(env.current()->fees().reserve == XRPAmount{200'000'000});
|
||||
BEAST_EXPECT(env.current()->fees().increment == XRPAmount{50'000'000});
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
@@ -36,8 +37,6 @@ class LedgerMaster_test : public beast::unit_test::Suite
|
||||
using namespace jtx;
|
||||
return envconfig([&](std::unique_ptr<Config> cfg) {
|
||||
cfg->networkId = networkID;
|
||||
// This test relies on ledger hash so must lock it to fee 10.
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
});
|
||||
}
|
||||
@@ -50,7 +49,8 @@ class LedgerMaster_test : public beast::unit_test::Suite
|
||||
using namespace test::jtx;
|
||||
using namespace std::literals;
|
||||
|
||||
test::jtx::Env env{*this, makeNetworkConfig(11111)};
|
||||
// This test relies on ledger hash so must lock it to fee 10.
|
||||
test::jtx::Env env{*this, makeNetworkConfig(11111), XRPAmount(10)};
|
||||
|
||||
auto const alice = Account("alice");
|
||||
env.fund(XRP(1000), alice);
|
||||
|
||||
@@ -3042,9 +3042,7 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
|
||||
Account const alice{"alice"};
|
||||
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env{*this, std::move(cfg), features};
|
||||
Env env{*this, features, XRPAmount(10)};
|
||||
MPTTester mptAlice(env, alice);
|
||||
|
||||
mptAlice.create();
|
||||
|
||||
@@ -193,11 +193,14 @@ struct Regression_test : public beast::unit_test::Suite
|
||||
{
|
||||
testcase("Autofilled fee should use the escalated fee");
|
||||
using namespace jtx;
|
||||
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->section(Sections::kTransactionQueue).set(Keys::kMinimumTxnInLedgerStandalone, "3");
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
}));
|
||||
Env env(
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->section(Sections::kTransactionQueue)
|
||||
.set(Keys::kMinimumTxnInLedgerStandalone, "3");
|
||||
return cfg;
|
||||
}),
|
||||
XRPAmount(10));
|
||||
EnvSs envs(env);
|
||||
|
||||
auto const alice = Account("alice");
|
||||
|
||||
@@ -1262,8 +1262,7 @@ public:
|
||||
testcase("tie breaking");
|
||||
|
||||
auto cfg = makeConfig({{Keys::kMinimumTxnInLedgerStandalone, "4"}});
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env(*this, std::move(cfg));
|
||||
Env env(*this, std::move(cfg), XRPAmount(10));
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
@@ -2730,13 +2729,11 @@ public:
|
||||
using namespace jtx;
|
||||
testcase("full queue gap handling");
|
||||
|
||||
auto cfg = makeConfig({
|
||||
{Keys::kMinimumTxnInLedgerStandalone, "1"},
|
||||
{Keys::kLedgersInQueue, "10"},
|
||||
{Keys::kMaximumTxnPerAccount, "11"},
|
||||
});
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env(*this, std::move(cfg));
|
||||
auto cfg = makeConfig(
|
||||
{{Keys::kMinimumTxnInLedgerStandalone, "1"},
|
||||
{Keys::kLedgersInQueue, "10"},
|
||||
{Keys::kMaximumTxnPerAccount, "11"}});
|
||||
Env env(*this, std::move(cfg), XRPAmount(10));
|
||||
|
||||
auto const baseFee = env.current()->fees().base.drops();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <random>
|
||||
#include <ranges>
|
||||
@@ -61,8 +62,8 @@ class PerfLog_test : public beast::unit_test::Suite
|
||||
|
||||
// We're only using Env for its Journal. That Journal gives better
|
||||
// coverage in unit tests.
|
||||
test::jtx::Env env_{*this, test::jtx::envconfig(), nullptr, beast::Severity::Disabled};
|
||||
beast::Journal j_{env_.app().getJournal("PerfLog_test")};
|
||||
std::optional<test::jtx::Env> env_;
|
||||
std::optional<beast::Journal> j_;
|
||||
|
||||
struct Fixture
|
||||
{
|
||||
@@ -221,7 +222,7 @@ public:
|
||||
|
||||
{
|
||||
// Verify a PerfLog creates its file when constructed.
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
BEAST_EXPECT(!exists(fixture.logFile()));
|
||||
|
||||
auto const perfLog{fixture.perfLog(WithFile::Yes)};
|
||||
@@ -233,7 +234,7 @@ public:
|
||||
// Create a file where PerfLog wants to put its directory.
|
||||
// Make sure that PerfLog tries to shutdown the server since it
|
||||
// can't open its file.
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
if (!BEAST_EXPECT(!exists(fixture.logDir())))
|
||||
return;
|
||||
|
||||
@@ -268,7 +269,7 @@ public:
|
||||
// since it can't open its file.
|
||||
using std::filesystem::perms;
|
||||
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
if (!BEAST_EXPECT(!exists(fixture.logDir())))
|
||||
return;
|
||||
|
||||
@@ -325,7 +326,7 @@ public:
|
||||
{
|
||||
// Exercise the rpc interfaces of PerfLog.
|
||||
// Start up the PerfLog that we'll use for testing.
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
auto perfLog{fixture.perfLog(withFile)};
|
||||
perfLog->start();
|
||||
|
||||
@@ -523,7 +524,7 @@ public:
|
||||
|
||||
// Exercise the jobs interfaces of PerfLog.
|
||||
// Start up the PerfLog that we'll use for testing.
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
auto perfLog{fixture.perfLog(withFile)};
|
||||
perfLog->start();
|
||||
|
||||
@@ -846,7 +847,7 @@ public:
|
||||
// the PerLog behaves as well as possible if an invalid ID is passed.
|
||||
|
||||
// Start up the PerfLog that we'll use for testing.
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
auto perfLog{fixture.perfLog(withFile)};
|
||||
perfLog->start();
|
||||
|
||||
@@ -985,7 +986,7 @@ public:
|
||||
// the interface and see that it doesn't crash.
|
||||
using namespace std::filesystem;
|
||||
|
||||
Fixture fixture{env_.app(), j_};
|
||||
Fixture fixture{env_->app(), *j_};
|
||||
BEAST_EXPECT(!exists(fixture.logDir()));
|
||||
|
||||
auto perfLog{fixture.perfLog(withFile)};
|
||||
@@ -1043,13 +1044,13 @@ public:
|
||||
{
|
||||
testcase("Caller's range need not outlive the PerfLog");
|
||||
|
||||
Fixture const fixture{env_.app(), j_};
|
||||
Fixture const fixture{env_->app(), *j_};
|
||||
|
||||
std::unique_ptr<perf::PerfLog> perfLog;
|
||||
{
|
||||
std::vector<NullTerminatedView> const names{kMethodNames.begin(), kMethodNames.end()};
|
||||
perf::PerfLog::Setup const setup{.perfLog = "", .logInterval = fixture.logInterval()};
|
||||
perfLog = perf::makePerfLog(setup, env_.app(), names, j_, [] {});
|
||||
perfLog = perf::makePerfLog(setup, env_->app(), names, *j_, [] {});
|
||||
}
|
||||
|
||||
perfLog->start();
|
||||
@@ -1065,6 +1066,9 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
env_.emplace(*this, test::jtx::envconfig(), nullptr, beast::Severity::Disabled);
|
||||
j_.emplace(env_->app().getJournal("PerfLog_test"));
|
||||
|
||||
testFileCreation();
|
||||
testRPC(WithFile::No);
|
||||
testRPC(WithFile::Yes);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
@@ -18,8 +19,8 @@ class ClosureCounter_test : public beast::unit_test::Suite
|
||||
{
|
||||
// We're only using Env for its Journal. That Journal gives better
|
||||
// coverage in unit tests.
|
||||
test::jtx::Env env_{*this, jtx::envconfig(), nullptr, beast::Severity::Disabled};
|
||||
beast::Journal j_{env_.app().getJournal("ClosureCounter_test")};
|
||||
std::optional<test::jtx::Env> env_;
|
||||
std::optional<beast::Journal> j_;
|
||||
|
||||
void
|
||||
testConstruction()
|
||||
@@ -259,7 +260,7 @@ class ClosureCounter_test : public beast::unit_test::Suite
|
||||
|
||||
// Join with 0 count should not stall.
|
||||
using namespace std::chrono_literals;
|
||||
voidCounter.join("testWrap", 1ms, j_);
|
||||
voidCounter.join("testWrap", 1ms, *j_);
|
||||
|
||||
// Wrapping a closure after join() should return std::nullopt.
|
||||
BEAST_EXPECT(voidCounter.wrap([]() {}) == std::nullopt);
|
||||
@@ -280,7 +281,7 @@ class ClosureCounter_test : public beast::unit_test::Suite
|
||||
std::thread localThread([&voidCounter, &threadExited, this] {
|
||||
// Should stall after calling join.
|
||||
using namespace std::chrono_literals;
|
||||
voidCounter.join("testWaitOnJoin", 1ms, j_);
|
||||
voidCounter.join("testWaitOnJoin", 1ms, *j_);
|
||||
threadExited.store(true);
|
||||
});
|
||||
|
||||
@@ -310,6 +311,9 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
env_.emplace(*this, jtx::envconfig(), nullptr, beast::Severity::Disabled);
|
||||
j_.emplace(env_->app().getJournal("ClosureCounter_test"));
|
||||
|
||||
testConstruction();
|
||||
testArgs();
|
||||
testWrap();
|
||||
|
||||
+83
-16
@@ -194,7 +194,8 @@ private:
|
||||
beast::unit_test::Suite& suite,
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs,
|
||||
beast::Severity thresh);
|
||||
beast::Severity thresh,
|
||||
std::optional<XRPAmount> referenceFee);
|
||||
~AppBundle();
|
||||
};
|
||||
|
||||
@@ -215,7 +216,7 @@ public:
|
||||
* and takes ownership the passed Config pointer. Features will be enabled
|
||||
* according to rules described below (see next constructor).
|
||||
*
|
||||
* @param suite the current unit_test::suite
|
||||
* @param suite the current unit_test::Suite
|
||||
* @param config The desired Config - ownership will be taken by moving
|
||||
* the pointer. See envconfig and related functions for common config
|
||||
* tweaks.
|
||||
@@ -227,9 +228,15 @@ public:
|
||||
std::unique_ptr<Config> config,
|
||||
FeatureBitset features,
|
||||
std::unique_ptr<Logs> logs = nullptr,
|
||||
beast::Severity thresh = beast::Severity::Error)
|
||||
std::optional<beast::Severity> thresh = std::nullopt,
|
||||
std::optional<XRPAmount> referenceFee = std::nullopt)
|
||||
: test(suite)
|
||||
, bundle_(suite, std::move(config), std::move(logs), thresh)
|
||||
, bundle_(
|
||||
suite,
|
||||
std::move(config),
|
||||
std::move(logs),
|
||||
thresh.value_or(beast::Severity::Error),
|
||||
referenceFee)
|
||||
, journal{bundle_.app->getJournal("Env")}
|
||||
{
|
||||
memoize(Account::kMaster);
|
||||
@@ -240,22 +247,45 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create Env with default config and specified
|
||||
* features.
|
||||
* @brief Create Env with default config, specified
|
||||
* features, log handler, and reference fee.
|
||||
*
|
||||
* This constructor will create an Env with the standard Env configuration
|
||||
* (from envconfig()) and features explicitly specified. Use
|
||||
* with_only_features(...) or supported_features_except(...) to create a
|
||||
* collection of features appropriate for passing here.
|
||||
*
|
||||
* @param suite the current unit_test::suite
|
||||
* @param args collection of features
|
||||
* @param suite the current unit_test::Suite
|
||||
* @param features collection of features
|
||||
* @param logs log handler
|
||||
* @param referenceFee non-default reference fee
|
||||
*
|
||||
*/
|
||||
Env(beast::unit_test::Suite& suite,
|
||||
FeatureBitset features,
|
||||
std::unique_ptr<Logs> logs = nullptr)
|
||||
: Env(suite, envconfig(), features, std::move(logs))
|
||||
std::unique_ptr<Logs> logs,
|
||||
std::optional<XRPAmount> referenceFee = std::nullopt)
|
||||
: Env(suite, envconfig(), features, std::move(logs), std::nullopt, referenceFee)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief Create Env with default config, specified
|
||||
* features, and reference fee.
|
||||
*
|
||||
* This constructor will create an Env with the standard Env configuration
|
||||
* (from envconfig()) and features explicitly specified. Use
|
||||
* with_only_features(...) or supported_features_except(...) to create a
|
||||
* collection of features appropriate for passing here.
|
||||
*
|
||||
* @param suite the current unit_test::Suite
|
||||
* @param features collection of features
|
||||
* @param referenceFee non-default reference fee
|
||||
*
|
||||
*/
|
||||
Env(beast::unit_test::Suite& suite,
|
||||
FeatureBitset features,
|
||||
std::optional<XRPAmount> referenceFee = std::nullopt)
|
||||
: Env(suite, envconfig(), features, nullptr, std::nullopt, referenceFee)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -266,7 +296,7 @@ public:
|
||||
* and takes ownership the passed Config pointer. All supported amendments
|
||||
* are enabled by this version of the constructor.
|
||||
*
|
||||
* @param suite the current unit_test::suite
|
||||
* @param suite the current unit_test::Suite
|
||||
* @param config The desired Config - ownership will be taken by moving
|
||||
* the pointer. See envconfig and related functions for common config
|
||||
* tweaks.
|
||||
@@ -274,8 +304,43 @@ public:
|
||||
Env(beast::unit_test::Suite& suite,
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs = nullptr,
|
||||
beast::Severity thresh = beast::Severity::Error)
|
||||
: Env(suite, std::move(config), testableAmendments(), std::move(logs), thresh)
|
||||
std::optional<beast::Severity> thresh = std::nullopt,
|
||||
std::optional<XRPAmount> referenceFee = std::nullopt)
|
||||
: Env(suite, std::move(config), testableAmendments(), std::move(logs), thresh, referenceFee)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create Env using suite, Config pointer, and reference fee.
|
||||
*
|
||||
* This constructor will create an Env with the specified configuration
|
||||
* and takes ownership the passed Config pointer. All supported amendments
|
||||
* are enabled by this version of the constructor.
|
||||
*
|
||||
* @param suite the current unit_test::Suite
|
||||
* @param config The desired Config - ownership will be taken by moving
|
||||
* the pointer. See envconfig and related functions for common config
|
||||
* tweaks.
|
||||
* @param referenceFee Optional reference fee to use in fee settings.
|
||||
*/
|
||||
Env(beast::unit_test::Suite& suite,
|
||||
std::unique_ptr<Config> config,
|
||||
std::optional<XRPAmount> referenceFee)
|
||||
: Env(suite, std::move(config), testableAmendments(), nullptr, std::nullopt, referenceFee)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create Env with the current test suite and a referenceFee
|
||||
*
|
||||
* This constructor will create an Env with the standard
|
||||
* test Env configuration (from envconfig()) and all supported
|
||||
* amendments enabled.
|
||||
*
|
||||
* @param suite the current unit_test::Suite
|
||||
*/
|
||||
Env(beast::unit_test::Suite& suite, std::optional<XRPAmount> referenceFee)
|
||||
: Env(suite, envconfig(), referenceFee)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -286,10 +351,12 @@ public:
|
||||
* test Env configuration (from envconfig()) and all supported
|
||||
* amendments enabled.
|
||||
*
|
||||
* @param suite the current unit_test::suite
|
||||
* @param suite the current unit_test::Suite
|
||||
*/
|
||||
Env(beast::unit_test::Suite& suite, beast::Severity thresh = beast::Severity::Error)
|
||||
: Env(suite, envconfig(), nullptr, thresh)
|
||||
Env(beast::unit_test::Suite& suite,
|
||||
beast::Severity thresh = beast::Severity::Error,
|
||||
std::optional<XRPAmount> referenceFee = std::nullopt)
|
||||
: Env(suite, envconfig(), nullptr, thresh, referenceFee)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
#include <xrpl/server/NetworkOPs.h>
|
||||
|
||||
@@ -73,7 +74,8 @@ Env::AppBundle::AppBundle(
|
||||
beast::unit_test::Suite& suite,
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs,
|
||||
beast::Severity thresh)
|
||||
beast::Severity thresh,
|
||||
std::optional<XRPAmount> referenceFee)
|
||||
: AppBundle()
|
||||
{
|
||||
using beast::Severity;
|
||||
@@ -89,6 +91,14 @@ Env::AppBundle::AppBundle(
|
||||
}
|
||||
auto tk = std::make_unique<ManualTimeKeeper>();
|
||||
timeKeeper = tk.get();
|
||||
if (referenceFee)
|
||||
{
|
||||
config->fees.referenceFee = *referenceFee;
|
||||
}
|
||||
else if (auto const fee = suite.referenceFee())
|
||||
{
|
||||
config->fees.referenceFee = *fee;
|
||||
}
|
||||
// Hack so we don't have to call Config::setup
|
||||
HTTPClient::initializeSSLContext(
|
||||
config->sslVerifyDir, config->sslVerifyFile, config->sslVerify, debugLog());
|
||||
|
||||
@@ -24,7 +24,7 @@ setupConfigForUnitTests(Config& cfg)
|
||||
// Reserves held at pre-2021 mainnet values; many tests carry balance
|
||||
// expectations built on them. Extension limits are deliberately unset --
|
||||
// tests inherit the FeeSetup defaults, or set [voting].
|
||||
cfg.fees.referenceFee = UNIT_TEST_REFERENCE_FEE;
|
||||
cfg.fees.referenceFee = XRPAmount(10);
|
||||
cfg.fees.accountReserve = XRP(200).value().xrp().drops();
|
||||
cfg.fees.ownerReserve = XRP(50).value().xrp().drops();
|
||||
|
||||
|
||||
@@ -780,9 +780,9 @@ protected:
|
||||
void
|
||||
printPeers(std::string const& msg, std::uint16_t validator = 0)
|
||||
{
|
||||
auto peers = network_.overlay().getPeers(network_.validator(validator));
|
||||
std::cout << msg << " "
|
||||
<< "num peers " << (int)network_.overlay().getNumPeers() << std::endl;
|
||||
auto peers = network_->overlay().getPeers(network_->validator(validator));
|
||||
std::cout << msg << " " << "num peers " << (int)network_->overlay().getNumPeers()
|
||||
<< std::endl;
|
||||
for (auto& [k, v] : peers)
|
||||
std::cout << k << ":" << (int)std::get<reduce_relay::PeerState>(v) << " ";
|
||||
std::cout << std::endl;
|
||||
@@ -841,8 +841,8 @@ protected:
|
||||
};
|
||||
time_point<ManualClock> lastCheck = ManualClock::now();
|
||||
|
||||
network_.reset();
|
||||
network_.propagate([&](Link& link, MessageSPtr m) {
|
||||
network_->reset();
|
||||
network_->propagate([&](Link& link, MessageSPtr m) {
|
||||
auto& validator = link.validator();
|
||||
auto now = ManualClock::now();
|
||||
|
||||
@@ -859,7 +859,7 @@ protected:
|
||||
|
||||
if (squelched)
|
||||
{
|
||||
auto const selected = network_.overlay().getSelected(validator);
|
||||
auto const selected = network_->overlay().getSelected(validator);
|
||||
str << " selected: ";
|
||||
for (auto const s : selected)
|
||||
str << s << " ";
|
||||
@@ -869,10 +869,10 @@ protected:
|
||||
<< " random, squelched, validator: " << validator.id()
|
||||
<< " peers: " << str.str() << std::endl;
|
||||
}
|
||||
auto const countingState = network_.overlay().isCountingState(validator);
|
||||
auto const countingState = network_->overlay().isCountingState(validator);
|
||||
BEAST_EXPECT(
|
||||
countingState == false &&
|
||||
selected.size() == env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
selected.size() == env_->app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
}
|
||||
|
||||
// Trigger Link Down or Peer Disconnect event
|
||||
@@ -888,13 +888,13 @@ protected:
|
||||
events[event].time = now;
|
||||
if (event == EventType::LinkDown)
|
||||
{
|
||||
network_.enableLink(validator.id(), link.peerId(), false);
|
||||
network_->enableLink(validator.id(), link.peerId(), false);
|
||||
events[event].isSelected =
|
||||
network_.overlay().isSelected(validator, link.peerId());
|
||||
network_->overlay().isSelected(validator, link.peerId());
|
||||
}
|
||||
else
|
||||
{
|
||||
events[event].isSelected = network_.isSelected(link.peerId());
|
||||
events[event].isSelected = network_->isSelected(link.peerId());
|
||||
}
|
||||
};
|
||||
auto const r = randInt(0, 1000);
|
||||
@@ -907,8 +907,8 @@ protected:
|
||||
if (events[EventType::PeerDisconnected].state == State::On)
|
||||
{
|
||||
auto& event = events[EventType::PeerDisconnected];
|
||||
bool const allCounting = network_.allCounting(event.peer);
|
||||
network_.overlay().deletePeer(
|
||||
bool const allCounting = network_->allCounting(event.peer);
|
||||
network_->overlay().deletePeer(
|
||||
event.peer, [&](PublicKey const& v, PeerWPtr const& peerPtr) {
|
||||
if (event.isSelected)
|
||||
sendSquelch(v, peerPtr, {});
|
||||
@@ -926,7 +926,7 @@ protected:
|
||||
event.isSelected = false;
|
||||
event.handledCnt += handled;
|
||||
event.handled = false;
|
||||
network_.onDisconnectPeer(event.peer);
|
||||
network_->onDisconnectPeer(event.peer);
|
||||
}
|
||||
|
||||
auto& event = events[EventType::LinkDown];
|
||||
@@ -944,17 +944,17 @@ protected:
|
||||
bool mustHandle = false;
|
||||
if (event.state == State::On && BEAST_EXPECT(event.key))
|
||||
{
|
||||
event.isSelected = network_.overlay().isSelected(*event.key, event.peer);
|
||||
auto peers = network_.overlay().getPeers(*event.key);
|
||||
event.isSelected = network_->overlay().isSelected(*event.key, event.peer);
|
||||
auto peers = network_->overlay().getPeers(*event.key);
|
||||
auto const d = reduce_relay::epoch<milliseconds>(now).count() -
|
||||
std::get<3>(peers[event.peer]);
|
||||
mustHandle = event.isSelected &&
|
||||
d > milliseconds(reduce_relay::kIdled).count() &&
|
||||
network_.overlay().inState(*event.key, reduce_relay::PeerState::Squelched) >
|
||||
0 &&
|
||||
network_->overlay().inState(
|
||||
*event.key, reduce_relay::PeerState::Squelched) > 0 &&
|
||||
peers.contains(event.peer);
|
||||
}
|
||||
network_.overlay().deleteIdlePeers([&](PublicKey const& v, PeerWPtr const& ptr) {
|
||||
network_->overlay().deleteIdlePeers([&](PublicKey const& v, PeerWPtr const& ptr) {
|
||||
event.handled = true;
|
||||
if (mustHandle && v == event.key)
|
||||
{
|
||||
@@ -976,7 +976,7 @@ protected:
|
||||
event.isSelected = false;
|
||||
event.handledCnt += handled;
|
||||
event.handled = false;
|
||||
network_.enableLink(event.validator, event.peer, true);
|
||||
network_->enableLink(event.validator, event.peer, true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -997,7 +997,7 @@ protected:
|
||||
bool
|
||||
checkCounting(PublicKey const& validator, bool isCountingState)
|
||||
{
|
||||
auto const countingState = network_.overlay().isCountingState(validator);
|
||||
auto const countingState = network_->overlay().isCountingState(validator);
|
||||
BEAST_EXPECT(countingState == isCountingState);
|
||||
return countingState == isCountingState;
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ protected:
|
||||
propagateAndSquelch(bool log, bool purge = true, bool resetClock = true)
|
||||
{
|
||||
int n = 0;
|
||||
network_.propagate(
|
||||
network_->propagate(
|
||||
[&](Link& link, MessageSPtr message) {
|
||||
std::uint16_t squelched = 0;
|
||||
link.send(
|
||||
@@ -1066,7 +1066,7 @@ protected:
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
squelched ==
|
||||
kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
kMaxPeers - env_->app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
n++;
|
||||
}
|
||||
},
|
||||
@@ -1074,10 +1074,10 @@ protected:
|
||||
reduce_relay::kMaxMessageThreshold + 2,
|
||||
purge,
|
||||
resetClock);
|
||||
auto const selected = network_.overlay().getSelected(network_.validator(0));
|
||||
BEAST_EXPECT(selected.size() == env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
auto const selected = network_->overlay().getSelected(network_->validator(0));
|
||||
BEAST_EXPECT(selected.size() == env_->app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
BEAST_EXPECT(n == 1); // only one selection round
|
||||
auto const res = checkCounting(network_.validator(0), false);
|
||||
auto const res = checkCounting(network_->validator(0), false);
|
||||
BEAST_EXPECT(res);
|
||||
return n == 1 && res;
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ protected:
|
||||
bool resetClock = true)
|
||||
{
|
||||
bool squelched = false;
|
||||
network_.propagate(
|
||||
network_->propagate(
|
||||
[&](Link& link, MessageSPtr message) {
|
||||
link.send(
|
||||
message,
|
||||
@@ -1107,7 +1107,7 @@ protected:
|
||||
nMessages,
|
||||
purge,
|
||||
resetClock);
|
||||
auto const res = checkCounting(network_.validator(0), countingState);
|
||||
auto const res = checkCounting(network_->validator(0), countingState);
|
||||
return !squelched && res;
|
||||
}
|
||||
|
||||
@@ -1120,7 +1120,7 @@ protected:
|
||||
{
|
||||
doTest("New Peer", log, [this](bool log) {
|
||||
BEAST_EXPECT(propagateAndSquelch(log, true, false));
|
||||
network_.addPeer();
|
||||
network_->addPeer();
|
||||
BEAST_EXPECT(propagateNoSquelch(log, 1, true, false, false));
|
||||
});
|
||||
}
|
||||
@@ -1135,14 +1135,14 @@ protected:
|
||||
doTest("Selected Peer Disconnects", log, [this](bool log) {
|
||||
ManualClock::advance(seconds(601));
|
||||
BEAST_EXPECT(propagateAndSquelch(log, true, false));
|
||||
auto const id = network_.overlay().getSelectedPeer(network_.validator(0));
|
||||
auto const id = network_->overlay().getSelectedPeer(network_->validator(0));
|
||||
std::uint16_t unsquelched = 0;
|
||||
network_.overlay().deletePeer(
|
||||
network_->overlay().deletePeer(
|
||||
id, [&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
|
||||
BEAST_EXPECT(
|
||||
unsquelched ==
|
||||
kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
BEAST_EXPECT(checkCounting(network_.validator(0), true));
|
||||
kMaxPeers - env_->app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
BEAST_EXPECT(checkCounting(network_->validator(0), true));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1158,13 +1158,13 @@ protected:
|
||||
BEAST_EXPECT(propagateAndSquelch(log, true, false));
|
||||
ManualClock::advance(reduce_relay::kIdled + seconds(1));
|
||||
std::uint16_t unsquelched = 0;
|
||||
network_.overlay().deleteIdlePeers(
|
||||
network_->overlay().deleteIdlePeers(
|
||||
[&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
|
||||
auto const peers = network_.overlay().getPeers(network_.validator(0));
|
||||
auto const peers = network_->overlay().getPeers(network_->validator(0));
|
||||
BEAST_EXPECT(
|
||||
unsquelched ==
|
||||
kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
BEAST_EXPECT(checkCounting(network_.validator(0), true));
|
||||
kMaxPeers - env_->app().config().vpReduceRelaySquelchMaxSelectedPeers);
|
||||
BEAST_EXPECT(checkCounting(network_->validator(0), true));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1177,17 +1177,17 @@ protected:
|
||||
doTest("Squelched Peer Disconnects", log, [this](bool log) {
|
||||
ManualClock::advance(seconds(601));
|
||||
BEAST_EXPECT(propagateAndSquelch(log, true, false));
|
||||
auto peers = network_.overlay().getPeers(network_.validator(0));
|
||||
auto const peers = network_->overlay().getPeers(network_->validator(0));
|
||||
auto const it = std::ranges::find_if(peers, [&](auto it) {
|
||||
return std::get<reduce_relay::PeerState>(it.second) ==
|
||||
reduce_relay::PeerState::Squelched;
|
||||
});
|
||||
assert(it != peers.end());
|
||||
std::uint16_t unsquelched = 0;
|
||||
network_.overlay().deletePeer(
|
||||
network_->overlay().deletePeer(
|
||||
it->first, [&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
|
||||
BEAST_EXPECT(unsquelched == 0);
|
||||
BEAST_EXPECT(checkCounting(network_.validator(0), false));
|
||||
BEAST_EXPECT(checkCounting(network_->validator(0), false));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1332,9 +1332,9 @@ vp_base_squelch_max_selected_peers=2
|
||||
ManualClock::reset();
|
||||
auto const createSlots =
|
||||
[&](bool baseSquelchEnabled) -> reduce_relay::Slots<ManualClock> {
|
||||
env_.app().config().vpReduceRelayBaseSquelchEnable = baseSquelchEnabled;
|
||||
env_->app().config().vpReduceRelayBaseSquelchEnable = baseSquelchEnabled;
|
||||
return reduce_relay::Slots<ManualClock>(
|
||||
env_.app(), network_.overlay(), env_.app().config());
|
||||
env_->app(), network_->overlay(), env_->app().config());
|
||||
};
|
||||
// base squelching must not be ready if squelching is disabled
|
||||
BEAST_EXPECT(!createSlots(false).baseSquelchReady());
|
||||
@@ -1358,32 +1358,32 @@ vp_base_squelch_max_selected_peers=2
|
||||
testInternalHashRouter(bool log)
|
||||
{
|
||||
doTest("Duplicate Message", log, [&](bool log) {
|
||||
network_.reset();
|
||||
network_->reset();
|
||||
// update message count for the same peer/validator
|
||||
std::int16_t const nMessages = 5;
|
||||
for (int i = 0; i < nMessages; i++)
|
||||
{
|
||||
UInt256 const key(i);
|
||||
network_.overlay().updateSlotAndSquelch(
|
||||
key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {
|
||||
network_->overlay().updateSlotAndSquelch(
|
||||
key, network_->validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {
|
||||
});
|
||||
}
|
||||
auto peers = network_.overlay().getPeers(network_.validator(0));
|
||||
auto peers = network_->overlay().getPeers(network_->validator(0));
|
||||
// first message changes Slot state to Counting and is not counted,
|
||||
// hence '-1'.
|
||||
BEAST_EXPECT(std::get<1>(peers[0]) == (nMessages - 1));
|
||||
// add duplicate
|
||||
UInt256 const key(nMessages - 1);
|
||||
network_.overlay().updateSlotAndSquelch(
|
||||
key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
|
||||
network_->overlay().updateSlotAndSquelch(
|
||||
key, network_->validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
|
||||
// confirm the same number of messages
|
||||
peers = network_.overlay().getPeers(network_.validator(0));
|
||||
peers = network_->overlay().getPeers(network_->validator(0));
|
||||
BEAST_EXPECT(std::get<1>(peers[0]) == (nMessages - 1));
|
||||
// advance the clock
|
||||
ManualClock::advance(reduce_relay::kIdled + seconds(1));
|
||||
network_.overlay().updateSlotAndSquelch(
|
||||
key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
|
||||
peers = network_.overlay().getPeers(network_.validator(0));
|
||||
network_->overlay().updateSlotAndSquelch(
|
||||
key, network_->validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
|
||||
peers = network_->overlay().getPeers(network_->validator(0));
|
||||
// confirm message number increased
|
||||
BEAST_EXPECT(std::get<1>(peers[0]) == nMessages);
|
||||
});
|
||||
@@ -1413,7 +1413,7 @@ vp_base_squelch_max_selected_peers=2
|
||||
|
||||
auto const run = [&](int npeers) {
|
||||
handler.maxDuration = 0;
|
||||
reduce_relay::Slots<ManualClock> slots(env_.app(), handler, env_.app().config());
|
||||
reduce_relay::Slots<ManualClock> slots(env_->app(), handler, env_->app().config());
|
||||
// 1st message from a new peer switches the slot
|
||||
// to counting state and resets the counts of all peers +
|
||||
// MAX_MESSAGE_THRESHOLD + 1 messages to reach the threshold
|
||||
@@ -1488,10 +1488,10 @@ vp_base_squelch_max_selected_peers=2
|
||||
<< "[compression]\n"
|
||||
<< "1\n";
|
||||
c.loadFromString(str.str());
|
||||
env_.app().config().vpReduceRelayBaseSquelchEnable =
|
||||
env_->app().config().vpReduceRelayBaseSquelchEnable =
|
||||
c.vpReduceRelayBaseSquelchEnable;
|
||||
|
||||
env_.app().config().compression = c.compression;
|
||||
env_->app().config().compression = c.compression;
|
||||
};
|
||||
auto const handshake = [&](int outboundEnable, int inboundEnable) {
|
||||
beast::ip::Address const addr = boost::asio::ip::make_address("172.1.1.100");
|
||||
@@ -1499,10 +1499,10 @@ vp_base_squelch_max_selected_peers=2
|
||||
setEnv(outboundEnable);
|
||||
auto request = xrpl::makeRequest(
|
||||
true,
|
||||
env_.app().config().compression,
|
||||
env_->app().config().compression,
|
||||
false,
|
||||
env_.app().config().txReduceRelayEnable,
|
||||
env_.app().config().vpReduceRelayBaseSquelchEnable);
|
||||
env_->app().config().txReduceRelayEnable,
|
||||
env_->app().config().vpReduceRelayBaseSquelchEnable);
|
||||
HttpRequestType httpRequest;
|
||||
httpRequest.version(request.version());
|
||||
httpRequest.base() = request.base();
|
||||
@@ -1517,7 +1517,7 @@ vp_base_squelch_max_selected_peers=2
|
||||
|
||||
setEnv(inboundEnable);
|
||||
auto const httpResp = xrpl::makeResponse(
|
||||
true, httpRequest, addr, addr, UInt256{1}, 1, {1, 0}, env_.app());
|
||||
true, httpRequest, addr, addr, UInt256{1}, 1, {1, 0}, env_->app());
|
||||
// outbound is enabled if the response's header has the feature
|
||||
// enabled and the peer's configuration is enabled
|
||||
auto const outboundEnabled =
|
||||
@@ -1531,23 +1531,20 @@ vp_base_squelch_max_selected_peers=2
|
||||
});
|
||||
}
|
||||
|
||||
jtx::Env env_;
|
||||
Network network_;
|
||||
std::optional<jtx::Env> env_;
|
||||
std::optional<Network> network_;
|
||||
|
||||
public:
|
||||
reduce_relay_test()
|
||||
: env_(*this, jtx::envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->vpReduceRelayBaseSquelchEnable = true;
|
||||
cfg->vpReduceRelaySquelchMaxSelectedPeers = 6;
|
||||
return cfg;
|
||||
}))
|
||||
, network_(env_.app())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
env_.emplace(*this, jtx::envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->vpReduceRelayBaseSquelchEnable = true;
|
||||
cfg->vpReduceRelaySquelchMaxSelectedPeers = 6;
|
||||
return cfg;
|
||||
}));
|
||||
network_.emplace(env_->app());
|
||||
|
||||
bool const log = false;
|
||||
testConfig(log);
|
||||
testInitialRound(log);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <xrpl/protocol/SeqProxy.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
@@ -134,10 +135,7 @@ class AccountTx_test : public beast::unit_test::Suite
|
||||
testcase("Parameters APIv" + std::to_string(apiVersion));
|
||||
using namespace test::jtx;
|
||||
|
||||
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
}));
|
||||
Env env(*this, XRPAmount(10));
|
||||
Account const a1{"A1"};
|
||||
env.fund(XRP(10000), a1);
|
||||
env.close();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <test/jtx/WSClient.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/balance.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
#include <test/jtx/mpt.h>
|
||||
#include <test/jtx/pay.h>
|
||||
#include <test/jtx/sendmax.h>
|
||||
@@ -19,10 +18,10 @@
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::test {
|
||||
|
||||
@@ -205,9 +204,7 @@ class DeliveredAmount_test : public beast::unit_test::Suite
|
||||
|
||||
for (bool const afterSwitchTime : {true, false})
|
||||
{
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env(*this, std::move(cfg));
|
||||
Env env(*this, XRPAmount(10));
|
||||
env.fund(XRP(10000), alice, bob, carol, gw);
|
||||
env.trust(usd(1000), alice, bob, carol);
|
||||
if (afterSwitchTime)
|
||||
@@ -296,9 +293,7 @@ class DeliveredAmount_test : public beast::unit_test::Suite
|
||||
|
||||
for (bool const afterSwitchTime : {true, false})
|
||||
{
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env(*this, std::move(cfg));
|
||||
Env env(*this, XRPAmount(10));
|
||||
env.fund(XRP(10000), alice, bob, carol, gw);
|
||||
env.trust(usd(1000), alice, bob, carol);
|
||||
if (afterSwitchTime)
|
||||
|
||||
@@ -3517,10 +3517,7 @@ public:
|
||||
// "b" (not in the ledger) is rDg53Haik2475DJx8bjMDSDPj4VX7htaMd.
|
||||
// "c" (phantom signer) is rPcNzota6B8YBokhYtcTNqQVCngtbnWfux.
|
||||
|
||||
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
}));
|
||||
Env env(*this, XRPAmount(10));
|
||||
env.fund(XRP(100000), a, ed, g);
|
||||
env.close();
|
||||
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class LedgerClosed_test : public beast::unit_test::Suite
|
||||
@@ -22,9 +19,7 @@ public:
|
||||
using namespace test::jtx;
|
||||
|
||||
// This test relies on ledger hash so must lock it to fee 10.
|
||||
auto p = envconfig();
|
||||
p->fees.referenceFee = 10;
|
||||
Env env{*this, std::move(p), FeatureBitset{}};
|
||||
Env env{*this, FeatureBitset{}, XRPAmount{10}};
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <xrpl/protocol/STXChainBridge.h>
|
||||
#include <xrpl/protocol/SeqProxy.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -596,9 +597,7 @@ class LedgerEntry_test : public beast::unit_test::Suite
|
||||
testcase("AccountRoot");
|
||||
using namespace test::jtx;
|
||||
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env{*this, std::move(cfg)};
|
||||
Env env{*this, XRPAmount(10)};
|
||||
|
||||
Account const alice{"alice"};
|
||||
env.fund(XRP(10000), alice);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/TxFlags.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <cstdint>
|
||||
@@ -400,10 +401,8 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
testcase("Lookup ledger");
|
||||
using namespace test::jtx;
|
||||
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env{*this, std::move(cfg), FeatureBitset{}}; // hashes requested below
|
||||
// assume no amendments
|
||||
Env env{*this, FeatureBitset{}, XRPAmount(10)}; // hashes requested below
|
||||
// assume no amendments
|
||||
env.fund(XRP(10000), "alice");
|
||||
env.close();
|
||||
env.fund(XRP(10000), "bob");
|
||||
@@ -578,8 +577,7 @@ class LedgerRPC_test : public beast::unit_test::Suite
|
||||
return cfg;
|
||||
});
|
||||
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env(*this, std::move(cfg));
|
||||
Env env(*this, std::move(cfg), XRPAmount(10));
|
||||
|
||||
json::Value jv;
|
||||
jv[jss::ledger_index] = "current";
|
||||
|
||||
@@ -5,15 +5,17 @@
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::rpc {
|
||||
|
||||
@@ -153,10 +155,8 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
auto cfg = envconfig();
|
||||
cfg->fees.referenceFee = 10;
|
||||
Env env{*this, std::move(cfg), FeatureBitset{}}; // the hashes being checked below
|
||||
// assume no amendments
|
||||
Env env{*this, FeatureBitset{}, XRPAmount(10)}; // the hashes being checked below
|
||||
// assume no amendments
|
||||
Account const gw{"gateway"};
|
||||
auto const usd = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
@@ -310,11 +310,13 @@ public:
|
||||
{
|
||||
using namespace test::jtx;
|
||||
using namespace std::chrono_literals;
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
cfg->nodeSize = 0;
|
||||
return cfg;
|
||||
})};
|
||||
Env env{
|
||||
*this,
|
||||
envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->nodeSize = 0;
|
||||
return cfg;
|
||||
}),
|
||||
XRPAmount(10)};
|
||||
Account const gw{"gateway"};
|
||||
auto const usd = gw["USD"];
|
||||
env.fund(XRP(100000), gw);
|
||||
|
||||
@@ -330,11 +330,7 @@ public:
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace jtx;
|
||||
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
cfg = singleThreadIo(std::move(cfg));
|
||||
return cfg;
|
||||
}));
|
||||
Env env(*this, envconfig(singleThreadIo), nullptr, std::nullopt, XRPAmount(10));
|
||||
auto wsc = makeWSClient(env.app().config());
|
||||
json::Value stream{json::ValueType::Object};
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/amount.h>
|
||||
#include <test/jtx/envconfig.h>
|
||||
#include <test/jtx/offer.h>
|
||||
#include <test/jtx/pay.h>
|
||||
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/unit_test/suite.h>
|
||||
@@ -15,6 +12,7 @@
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/protocol/ApiVersion.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -30,10 +28,7 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
{
|
||||
testcase("Invalid request params");
|
||||
using namespace test::jtx;
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
})};
|
||||
Env env{*this, XRPAmount(10)};
|
||||
|
||||
{
|
||||
// no params
|
||||
@@ -188,10 +183,7 @@ class TransactionEntry_test : public beast::unit_test::Suite
|
||||
{
|
||||
testcase("Basic request API version " + std::to_string(apiVersion));
|
||||
using namespace test::jtx;
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
})};
|
||||
Env env{*this, XRPAmount(10)};
|
||||
|
||||
auto const checkTx = [this, &env, apiVersion](
|
||||
int index,
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
#include <xrpl/protocol/serialize.h>
|
||||
|
||||
@@ -766,10 +767,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
using namespace test::jtx;
|
||||
using std::to_string;
|
||||
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
})};
|
||||
Env env{*this, XRPAmount(10)};
|
||||
Account const alice{"alice"};
|
||||
Account const alie{"alie"};
|
||||
Account const gw{"gw"};
|
||||
@@ -846,10 +844,7 @@ class Transaction_test : public beast::unit_test::Suite
|
||||
using namespace test::jtx;
|
||||
using std::to_string;
|
||||
|
||||
Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
|
||||
cfg->fees.referenceFee = 10;
|
||||
return cfg;
|
||||
})};
|
||||
Env env{*this, XRPAmount(10)};
|
||||
Account const alice{"alice"};
|
||||
Account const gw{"gw"};
|
||||
auto const usd{gw["USD"]};
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -264,6 +265,7 @@ static int
|
||||
runUnitTests(
|
||||
std::string const& pattern,
|
||||
std::string const& argument,
|
||||
std::optional<std::int64_t> referenceFee,
|
||||
bool quiet,
|
||||
bool log,
|
||||
bool child,
|
||||
@@ -283,6 +285,8 @@ runUnitTests(
|
||||
|
||||
MultiRunnerChild childRunner{numJobs, quiet, log};
|
||||
childRunner.arg(argument);
|
||||
if (referenceFee)
|
||||
childRunner.referenceFee(*referenceFee);
|
||||
MultiSelector const pred(pattern);
|
||||
auto const anyFailed = childRunner.runMulti(pred) || anyMissing(childRunner, pred);
|
||||
|
||||
@@ -340,6 +344,8 @@ runUnitTests(
|
||||
// child
|
||||
MultiRunnerChild runner{numJobs, quiet, log};
|
||||
runner.arg(argument);
|
||||
if (referenceFee)
|
||||
runner.referenceFee(*referenceFee);
|
||||
auto const anyFailed = runner.runMulti(MultiSelector(pattern));
|
||||
|
||||
if (anyFailed)
|
||||
@@ -430,6 +436,10 @@ run(int argc, char* const* argv)
|
||||
"argument is handled individually by any suite that accesses it -- "
|
||||
"as such, it typically only make sense to provide this when running "
|
||||
"a single suite.")(
|
||||
"unittest-fee",
|
||||
po::value<std::int64_t>(),
|
||||
"Supplies a reference fee (in drops) to unit tests. If provided, this "
|
||||
"value is used in every suite that does not override it.")(
|
||||
"unittest-ipv6", "Use IPv6 localhost when running unittests (default is IPv4).")(
|
||||
"unittest-log",
|
||||
"Force unit test log message output. Only useful in combination with "
|
||||
@@ -535,9 +545,12 @@ run(int argc, char* const* argv)
|
||||
if (vm.contains("unittest"))
|
||||
{
|
||||
std::string argument;
|
||||
std::optional<std::int64_t> referenceFee;
|
||||
|
||||
if (vm.contains("unittest-arg"))
|
||||
argument = vm["unittest-arg"].as<std::string>();
|
||||
if (vm.contains("unittest-fee") != 0u)
|
||||
referenceFee = vm["unittest-fee"].as<std::int64_t>();
|
||||
|
||||
std::size_t numJobs = 1;
|
||||
bool unittestChild = false;
|
||||
@@ -548,6 +561,7 @@ run(int argc, char* const* argv)
|
||||
return runUnitTests(
|
||||
vm["unittest"].as<std::string>(),
|
||||
argument,
|
||||
referenceFee,
|
||||
vm.contains("quiet"),
|
||||
vm.contains("unittest-log"),
|
||||
unittestChild,
|
||||
@@ -558,13 +572,13 @@ run(int argc, char* const* argv)
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
|
||||
if (vm.contains("unittest-jobs"))
|
||||
if ((vm.contains("unittest-jobs") != 0u) || (vm.contains("unittest-arg") != 0u) ||
|
||||
(vm.contains("unittest-fee") != 0u) || (vm.contains("unittest-log") != 0u) ||
|
||||
(vm.contains("unittest-ipv6") != 0u))
|
||||
{
|
||||
// unittest jobs only makes sense with `unittest`
|
||||
std::cerr << "xrpld: '--unittest-jobs' specified without "
|
||||
"'--unittest'.\n";
|
||||
std::cerr << "To run the unit tests the '--unittest' option must "
|
||||
"be present.\n";
|
||||
std::cerr << "xrpld: unittest-related parameter specified without '--unittest'.\n";
|
||||
std::cerr << "To run the unit tests the '--unittest' option must be present.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user