Compare commits

...
Author SHA1 Message Date
Ed Hennis 857c8bb809 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (53 commits)
  test: Check error consistently in rpc handlers (8604)
  chore: Fix an issue that breaks CLion (8619)
  feat: Add TransactionProposal invariants for Cosign (8130)
  ci: Fix release/staging branches running conditions (8615)
  fix: Assorted MPT/DEX offer related fixes - 1  (8468)
  fix: Check vault share freeze at MPT strand endpoints (8478)
  fix: Allow IOU rounding in Clawback invariant balance check (8475)
  refactor: Optimize the binary layout of Number (8550)
  refactor: Migrate handlers to rpc-spec (D) (8573)
  feat: Handle Smart Escrow's Bytecode, Data and Gas fields (8215)
  fix: Refuse to walk an invalid SHAMap in getMissingNodes (8086)
  fix: Refuse to make an invalid SHAMap or Ledger immutable (8085)
  fix: Report a node the sync path refuses as invalid data (8084)
  fix: Make the SHAMap sync-path state atomic (8083)
  docs: Add todo comment for key rotation zkproof (8589)
  fix: Judge a header's account hash on both acquisition routes (8476)
  fix: Signal every InboundLedger failure found in local data (8082)
  refactor: Add a reusable peer harness for acquisition tests (8310)
  refactor: TxQ (8064)
  fix: Reject a zero credential ID in deposit_authorized (8533)
  ...
2026-10-19 16:54:27 -04:00
Ed Hennis 9733f0c724 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  refactor: Expose a SHAMapAddNode verdict as counts (8080)
  refactor: Use DepositPreauthEntry everywhere (8364)
  chore: [DEPENDABOT] bump cxx from 1.0.202 to 1.0.203 in /crates in the rust-dependencies group (8564)
  chore: Fix readability-trailing-comma (8545)
  ci: [DEPENDABOT] bump the github-actions group across 1 directory with 2 updates (8562)
  chore: Fix misc-const-correctness (8546)
  chore: Update XRPLF/actions to use pip from python3.14 explicitly (8560)
2026-10-12 17:26:00 -04:00
Ed Hennis 7b9ee47294 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  chore: Bump version to 3.4.1 and make pkg_release 2
  build: Reduce number of conan logs (8548)
  chore: Fix readability-redundant-lambda-parameter-list (8544)
  fix: Reject Batch inner txs with the wrong wrapper (fixBatchV1_2)
  ci: Update Nexus packaging URL
  fix: Assorted integer-arithmetic hardening in the payment engine and ledger helpers
  fix: Change mpt subscription msg type back to `transaction` (8539)
  chore: Update clang-tidy image to v23 (8536)
  feat: Integrate Permissioned Domain & Credential Checks for Lending Protocol (6517)
  refactor: Group binaries in subdirectories (8535)
  chore: Split multiple-in-one into individual tests (8025)
  refactor: Migrate handlers to rpc-spec (B) (8484)
  build: Use images with Clang 23 except for clang-tidy (8530)
  chore: Update pre-commit hooks and image (8528)
  fix: Fix MPT partial payment overflow (8302)
2026-10-09 20:19:03 -04:00
Ed Hennis e145fdb745 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (211 commits)
  build: Use LLVM 23 (8522)
  refactor: Extract escrow lock helpers and paychan test helpers (7882)
  fix: Validate vetoed parameter type in feature RPC (7583)
  refactor: Use CheckEntry everywhere (8349)
  build: Make conan retry with Conan Center's source backups (8524)
  refactor: Use AmendmentsEntry everywhere (8368)
  chore: Update docker images; link Conan-built tools with a static runtime (8520)
  refactor: Use NegativeUNLEntry everywhere (8365)
  build: Make clang-tools custom in Nix, to match what's being built (8521)
  refactor: Migrate handlers to rpc-spec (A) (8345)
  test: Declare, not define, entry instantiations in SLEBase test (8357)
  test: Add more tests for granular permissions (8459)
  fix: Enforce that MPT issuance flags are never cleared (8152)
  feat: Allow lending transactions in Batch (8244)
  feat: Add full support for all objects in `ledger_entry` (6319)
  build: Define XRPL_ASAN, XRPL_TSAN, and XRPL_UBSAN compile definitions (8483)
  refactor: Use LedgerHashesEntry everywhere (8369)
  refactor: Use EscrowEntry everywhere (8354)
  chore: Update nix flake file (8479)
  refactor: Use FeeSettingsEntry everywhere (8370)
  ...
2026-10-07 12:01:29 -04:00
Ed Hennis 1d3d5804fa Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (136 commits)
  feat: Add a new closed ended vault to extend SAV (7921)
  build: Respect lld linker if it gets auto-selected (8011)
  test: Fix LoanBatch broker cover rates and schedule overflow (7967)
  test: Verify private-vault DEX permissions survive domain loss (7937)
  refactor: Drop unnecessary associateAsset calls from loan delete paths (7986)
  refactor: Replace `boost::filesystem` with `std::filesystem` across the codebase (7012)
  fix: Assorted MPT/DEX fixes (7299)
  refactor: Replace Boost trim and to_lower with libxrpl helpers (7995)
  build: Fix GCC 14 compilation (7981)
  fix: Validate account/ident type in gateway_balances (7655)
  build: Reimagine linker warnings in different scenarios (7974)
  chore: Gtest migration followups second pass (7888)
  fix: Validate buy/sell flag in nft RPC input (7725)
  fix: Prevent silent zero AMM clawbacks due to integer MPT rounding (7704)
  chore: Mark unreachable branches in Confidential Transfer with UNREACHABLE (7903)
  fix: Allow OverrideFreeze to bypass individual/deep freeze on AMM trust lines (6959)
  fix: Validate account_lines peer field type (7728)
  build: Install conan configuration/profiles inside Nix devshell (7997)
  fix: Add zero keylet check in credential (7971)
  refactor: Remove operator!= overloads that C++20 synthesizes (7994)
  ...
2026-08-12 16:51:04 -04:00
Ed Hennis 4a670f2bb1 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (121 commits)
  fix: Re-store nodes missing from both backends during online_delete rotation (7763)
  fix: Add amendment sponsor for AccountRootsDeletedClean (7801)
  fix: Update base_uint and test changes released in 3.1.3 (7570)
  fix: Handle rounding just above kMaxRep more accurately (7389)
  fix: Document and assert "after" is never null in invariants (7354)
  ci: Run full matrix only on `Ready to merge` or `Full CI build` labeled PRs (7689)
  fix: Strengthen Clawback invariant checks for MPT balances (7285)
  test: Add unit tests for IP address related functions (7744)
  ci: Add Rust to Nix docker image (7571)
  docs: Add more information about pre-commit hooks and how to set them up (7802)
  test: Add JSON array size tests (7592)
  chore: Enable most readability checks (7772)
  ci: Do not run conflict checker when label is applied (7774)
  chore: Run clang_tidy_check with `pass_filenames: false` from pre-commit (7800)
  feat: Add delegate filter param for account_tx RPC (6126)
  refactor: Move `jss.h` `include` out of `Indexes.h` (7799)
  test: Add tests for check doxygen style (7795)
  style: Add pre-commit hook to check doxygen style (7794)
  style: Unify style for all Doxygen comments (7776)
  fix: Improve Number addition/subtraction rounding (7369)
  ...
2026-07-14 20:48:53 -04:00
Ed Hennis a863d352c4 Fix some clang-tidy issues 2026-06-12 14:05:59 -04:00
Ed Hennis 3920c05258 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (46 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)
  ...
2026-06-12 12:33:50 -04:00
Ed Hennis b66666059b Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop: (35 commits)
  ci: Run PR title and description checks on staging and release branches (7331)
  style: Run shfmt on workflows, actions and markdown bash code (7333)
  release: Bump version to 3.2.0-rc2 (7348)
  refactor: Enable support for `fixCleanup3_2_0` amendment (7347)
  release: Bump version to 3.2.0-rc1 (7335)
  fix: Fix a rounding error at the `Number::maxRep` cusp (7051)
  ci: Only push docker images in XRPLF/rippled (7330)
  ci: [DEPENDABOT] bump docker/setup-buildx-action from 4.0.0 to 4.1.0 (7322)
  ci: [DEPENDABOT] bump codecov/codecov-action from 6.0.0 to 6.0.1 (7321)
  ci: [DEPENDABOT] bump docker/build-push-action from 7.1.0 to 7.2.0 (7320)
  ci: [DEPENDABOT] bump docker/metadata-action from 6.0.0 to 6.1.0 (7319)
  ci: [DEPENDABOT] bump docker/login-action from 4.1.0 to 4.2.0 (7318)
  fix: Update `clang-tidy` to include `src/tests` directory header check (7307)
  chore: Pin Python packages for codegen using uv (7329)
  style: Use shfmt instead of bashate (7326)
  fix: Fix edge-case where vault-depositor may get stuck (7139)
  fix: Fix `VaultInvariant` and `VaultDeposit` precision bugs at IOU scale boundaries (7272)
  ci: Add clang to nix images (7308)
  fix: Include management-fee delta in doOverpayment assertion (7039)
  fix: Fix clang-tidy pre-commit hook to locate compile_commands.json from repo root (7325)
  ...
2026-05-28 23:51:28 -04:00
Ed Hennis 917e9d3251 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  docs: Add --parallel flag to cmake build commands in BUILD.md (7302)
  fix: Fix wrong hybrid offer orderbook placement and update `LedgerStateFix` to amend `ExchangeRate` meta (7087)
  style: More clang-tidy identifier renaming (7290)
  fix: Update pDEX invariant firing under a valid offer deletion (7118)
  fix: Fix multisign and signfor to check for delegate (7064)
  refactor: Fix `sfGeneric` and `sfInvalid` field names (7300)
  docs: Fix some comments to improve readability (7122)
  feat: Propagate underlying MPT flags to vault shares (7077)
2026-05-21 14:29:06 +01:00
Ed Hennis 8c4dcc2919 Merge branch 'develop' into ximinez/vault-test 2026-05-19 16:53:59 -04:00
Ed Hennis 2c18745ad2 Merge branch 'develop' into ximinez/vault-test 2026-05-19 10:15:40 -04:00
Ed Hennis a2d5aaeba0 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  fix: Set default peering port to 2459 (6848)
  fix: Use account ledger entry when canceling token escrows (6171)
  refactor: Rename `account_` to `accountID_` (7284)
  ci: Add Linux package builds (DEB + RPM) to CI (6639)
  refactor: Clean up comments post-clang-tidy changes (7283)
  release: Set version to 3.3.0-b0 (7280)
  refactor: Rename static constants (7120)
  refactor: Use `isFlag` where possible instead of bitwise math (7278)
  ci: Update XRPLF/actions (7281)
2026-05-19 14:48:57 +01:00
Ed Hennis 4ede7f9444 Merge branch 'develop' into ximinez/vault-test 2026-05-14 20:39:30 -04:00
Ed Hennis 5f63a715cb Merge branch 'develop' into ximinez/vault-test 2026-05-14 10:48:45 -04:00
Ed Hennis 8514bf6824 Merge branch 'develop' into ximinez/vault-test 2026-05-13 12:04:04 -04:00
Ed Hennis 8a07170f78 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  ci: Limit nproc on Linux builds temporarily (7132)
  fix: Use transaction sequence numbers in permissioned domains (7129)
  fix: Improve json parsing of currency issuers (7110)
  refactor: Fill txJson based on apiVersion (7109)
  fix: Fix touchy "funds are conserved" assertion in LoanPay (6231) (6967)
  refactor: Remove erroneous base_uint ctor from container (7123)
  ci: Make `Show test failure summary` work with no build dir (7124)
  refactor: Replace `featureInvariantsV1_1` with `fixCleanup3_2_0` (7116)
  chore: Upgrade mako version (7108)
  refactor: Use more scoped enums (7086)
  fix: Prevent stale AuthAccounts from persisting after `tfTwoAssetIfEmpty` re-initialization (6996)
2026-05-12 20:04:09 -04:00
Ed Hennis d6751b9323 Merge branch 'develop' into ximinez/vault-test 2026-05-07 18:10:26 -04:00
Ed Hennis 9db9761824 Merge branch 'develop' into ximinez/vault-test 2026-05-07 14:18:52 -04:00
Ed Hennis b433bd3437 Merge branch 'develop' into ximinez/vault-test 2026-05-07 13:28:55 -04:00
Ed Hennis e53368580e Merge branch 'develop' into ximinez/vault-test 2026-05-06 22:34:46 -04:00
Ed Hennis 8e91253b79 Merge branch 'develop' into ximinez/vault-test 2026-05-06 14:18:24 -04:00
Ed Hennis c3f1a54ad8 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  fix: Fix regressions in `server_definitions` (7008)
  chore: Do not duplicate sanitizer flags (7058)
  ci: Run pre-commit on diff in clang-tidy workflow (7078)
  ci: Use XRPLF/create-issue (7076)
  ci: Rewrite clang-tidy workflow(s) in a reusable manner (7062)
  chore: Ignore identifier-naming update in git blame (7066)
  refactor: Enable clang-tidy `readability-identifier-naming` check (6571)
2026-05-05 19:06:50 -04:00
Ed Hennis 3345c9521a Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  refactor: Revert certain `Throw`s by `LogicError`s (7036)
  ci: Rename print-env -> print-build-env (7061)
  fix: Gate -mcmodel flags to x86_64 in sanitizer builds (7049)
  fix: Prevents overwriting a bool value in an invariant (6609)
  fix: Address code review comments regarding `boost::coroutine2` (6977)
  refactor: Apply various minor improvements and corrections (7045)
  fix: Store `Delegate` object in delegating and authorized account directories for proper deletion (6681)
  ci: Use print-env from XRPLF/actions (7052)
  fix: Make assorted RPC fixes (6529)
  chore: Enable clang-tidy v21 new checks (7031)
2026-05-01 14:00:52 -04:00
Ed Hennis f64a939b2d Merge branch 'develop' into ximinez/vault-test 2026-04-28 16:31:38 -04:00
Ed Hennis 2b2e6be6b2 Merge branch 'develop' into ximinez/vault-test 2026-04-25 14:46:06 -04:00
Ed Hennis 65cacb3a60 Merge branch 'develop' into ximinez/vault-test 2026-04-23 15:56:25 -04:00
Ed Hennis a4fe2969b9 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  chore: Add pre-commit hook to fix include style (6995)
  feat: Add `--definitions` flag and artifact (6858)
2026-04-22 23:44:45 -04:00
Ed Hennis 7edbf8dc15 Merge branch 'develop' into ximinez/vault-test 2026-04-22 14:49:25 -04:00
Ed Hennis 4c77acb295 Merge branch 'develop' into ximinez/vault-test 2026-04-22 13:10:57 -04:00
Ed Hennis 9dc71bd737 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  chore: Add -fix to clang-tidy invocation (6990)
  chore: Remove empty Taker.h (6984)
  chore: Enable clang-tidy modernize checks (6975)
  ci: Upload clang-tidy git diff (6983)
  fix: Add rounding to Vault invariants (6217) (6955)
2026-04-21 19:27:25 -04:00
Ed Hennis 4ea8284a68 Merge branch 'develop' into ximinez/vault-test 2026-04-20 17:49:59 -04:00
Ed Hennis 9ab82b1481 Merge branch 'develop' into ximinez/vault-test 2026-04-20 15:45:16 -04:00
Ed Hennis 478286c823 Merge branch 'develop' into ximinez/vault-test 2026-04-20 11:39:21 -04:00
Ed Hennis 6c8e7a5397 Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  chore: Enable clang-tidy include cleaner (6947)
  fix: Change AMMClawback return code to tecNO_PERMISSION (6946)
  ci: [DEPENDABOT] bump actions/upload-pages-artifact from 4.0.0 to 5.0.0 (6927)
  ci: [DEPENDABOT] bump actions/upload-artifact from 7.0.0 to 7.0.1 (6928)
  chore: Enable clang-tidy readability checks (6930)
2026-04-17 18:16:07 -04:00
Ed Hennis 3a46004c0e Merge branch 'develop' into ximinez/vault-test 2026-04-16 13:44:49 -04:00
Ed Hennis c7b0b91f2c Merge remote-tracking branch 'XRPLF/develop' into ximinez/vault-test
* XRPLF/develop:
  chore: Move codegen venv setup into build stage (6617)
2026-04-15 19:07:54 -04:00
Ed Hennis 17c128cd10 Merge branch 'develop' into ximinez/vault-test 2026-04-15 14:29:08 -04:00
Ed Hennis 9c65cecac7 Add command line unittest-fee
- Remove the cmake UNIT_TEST_REFERENCE_FEE setting
  - Replaced by --unittest-fee runtime param
2026-04-13 19:54:40 -04:00
29 changed files with 300 additions and 219 deletions

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 || '' }}
-4
View File
@@ -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
-6
View File
@@ -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)
+22
View File
@@ -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.
+12
View File
@@ -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)
+2 -14
View File
@@ -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)
+1 -1
View File
@@ -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});
+3 -3
View File
@@ -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);
+1 -3
View File
@@ -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();
+8 -5
View File
@@ -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");
+6 -9
View File
@@ -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();
+15 -11
View File
@@ -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);
+8 -4
View File
@@ -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
View File
@@ -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)
{
}
+11 -1
View File
@@ -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());
+1 -1
View File
@@ -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();
+68 -71
View File
@@ -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);
+2 -4
View File
@@ -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 -8
View File
@@ -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)
+1 -4
View File
@@ -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();
+1 -6
View File
@@ -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);
+2 -3
View File
@@ -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);
+4 -6
View File
@@ -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";
+12 -10
View File
@@ -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);
+1 -5
View File
@@ -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};
+3 -11
View File
@@ -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,
+3 -8
View File
@@ -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"]};
+19 -5
View File
@@ -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;
}