Compare commits

...
15 Commits
Author SHA1 Message Date
Bart aac17f588a release: Bump version to 3.2.0-b2 2026-03-30 14:52:51 -04:00
Ayaz Salikhov cbc09b2999 ci: Only publish docs in public repos (#6687) 2026-03-30 14:52:09 -04:00
Alex KremerandCopilot 453d94da17 chore: Enable remaining clang-tidy performance checks (#6648)
Co-authored-by: Copilot <[email protected]>
2026-03-30 14:52:09 -04:00
JingchenandBart b36aedb4d5 refactor: Address PR comments after the modularisation PRs (#6389)
Signed-off-by: JCW <[email protected]>
Co-authored-by: Bart <[email protected]>
2026-03-30 14:52:09 -04:00
Alex Kremer 18540c97a5 chore: Fix clang-tidy header filter (#6686) 2026-03-30 14:52:08 -04:00
dependabot[bot] 8e3d87fce3 ci: [DEPENDABOT] bump actions/deploy-pages from 4.0.5 to 5.0.0 (#6684)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-30 14:52:08 -04:00
dependabot[bot] b83dc9aa16 ci: [DEPENDABOT] bump codecov/codecov-action from 5.5.3 to 6.0.0 (#6685)
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-30 14:52:08 -04:00
Pratik MankawdeandClaude Opus 4.6 0c76bf991a fix: Guard Coro::resume() against completed coroutines (#6608)
Signed-off-by: Pratik Mankawde <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-03-30 14:52:08 -04:00
Vito Tumas 29aba28f5b refactor: Split LoanInvariant into LoanBrokerInvariant and LoanInvariant (#6674) 2026-03-30 14:52:08 -04:00
Ayaz Salikhov b3f14c4052 ci: Don't publish docs on release branches (#6673) 2026-03-30 14:52:08 -04:00
JingchenandEd Hennis e26624dcd1 refactor: Make function naming in ServiceRegistry consistent (#6390)
Signed-off-by: JCW <[email protected]>
Co-authored-by: Ed Hennis <[email protected]>
2026-03-30 14:52:08 -04:00
Valentin Balaschenko 885f7b8c33 chore: Shorten job names to stay within Linux 15-char thread limit (#6669) 2026-03-30 14:52:07 -04:00
Vito Tumas dcf973bc50 fix: Improve loan invariant message (#6668) 2026-03-30 14:52:07 -04:00
Ayaz Salikhov 68596f60d8 ci: Upload artifacts only in public repositories (#6670) 2026-03-30 14:52:07 -04:00
Bart aac64d3b85 Update version (#6672) 2026-03-26 09:50:04 -04:00
192 changed files with 1339 additions and 1250 deletions

No files matched your search

+54 -52
View File
@@ -1,4 +1,6 @@
---
# This entire group of checks was applied to all cpp files but not all header files.
# ---
Checks: "-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
@@ -8,26 +10,26 @@ Checks: "-*,
bugprone-chained-comparison,
bugprone-compare-pointer-to-member-virtual-function,
bugprone-copy-constructor-init,
bugprone-crtp-constructor-accessibility,
# bugprone-crtp-constructor-accessibility, # has issues
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-empty-catch,
# bugprone-empty-catch, # has issues
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-inaccurate-erase,
bugprone-inc-dec-in-conditions,
bugprone-incorrect-enable-if,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
# bugprone-forward-declaration-namespace, # has issues
# bugprone-inaccurate-erase,
# bugprone-inc-dec-in-conditions,
# bugprone-incorrect-enable-if,
# bugprone-incorrect-roundings,
# bugprone-infinite-loop,
# bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
# bugprone-macro-parentheses, # has issues
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multi-level-implicit-pointer-conversion,
# bugprone-multi-level-implicit-pointer-conversion, # has issues
bugprone-multiple-new-in-one-expression,
bugprone-multiple-statement-macro,
bugprone-no-escape,
@@ -37,13 +39,13 @@ Checks: "-*,
bugprone-pointer-arithmetic-on-polymorphic-object,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-reserved-identifier,
bugprone-return-const-ref-from-parameter,
# bugprone-reserved-identifier, # has issues
# bugprone-return-const-ref-from-parameter, # has issues
bugprone-shared-ptr-array-mismatch,
bugprone-signal-handler,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
# bugprone-sizeof-expression, # has issues
bugprone-spuriously-wake-up-functions,
bugprone-standalone-empty,
bugprone-string-constructor,
@@ -60,7 +62,7 @@ Checks: "-*,
bugprone-suspicious-string-compare,
bugprone-suspicious-stringview-data-usage,
bugprone-swapped-arguments,
bugprone-switch-missing-default-case,
# bugprone-switch-missing-default-case, # has issues
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
@@ -71,61 +73,66 @@ Checks: "-*,
bugprone-unhandled-self-assignment,
bugprone-unique-ptr-array-mismatch,
bugprone-unsafe-functions,
bugprone-use-after-move,
# bugprone-use-after-move, # has issues
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-unused-local-non-trivial-variable,
bugprone-virtual-near-miss,
cppcoreguidelines-init-variables,
cppcoreguidelines-misleading-capture-default-by-value,
# cppcoreguidelines-init-variables, # has issues
# cppcoreguidelines-misleading-capture-default-by-value, # has issues
cppcoreguidelines-no-suspend-with-lock,
cppcoreguidelines-pro-type-member-init,
# cppcoreguidelines-pro-type-member-init, # has issues
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-rvalue-reference-param-not-moved,
cppcoreguidelines-use-default-member-init,
cppcoreguidelines-virtual-class-destructor,
# cppcoreguidelines-rvalue-reference-param-not-moved, # has issues
# cppcoreguidelines-use-default-member-init, # has issues
# cppcoreguidelines-virtual-class-destructor, # has issues
hicpp-ignored-remove-result,
misc-definitions-in-headers,
# misc-definitions-in-headers, # has issues
misc-header-include-cycle,
misc-misplaced-const,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
# misc-throw-by-value-catch-by-reference, # has issues
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-trivially-destructible,
readability-avoid-nested-conditional-operator,
readability-avoid-return-with-void-value,
readability-braces-around-statements,
readability-const-return-type,
readability-container-contains,
readability-container-size-empty,
readability-convert-member-functions-to-static,
# readability-avoid-nested-conditional-operator, # has issues
# readability-avoid-return-with-void-value, # has issues
# readability-braces-around-statements, # has issues
# readability-const-return-type, # has issues
# readability-container-contains, # has issues
# readability-container-size-empty, # has issues
# readability-convert-member-functions-to-static, # has issues
readability-duplicate-include,
readability-else-after-return,
readability-enum-initial-value,
readability-implicit-bool-conversion,
readability-make-member-function-const,
readability-math-missing-parentheses,
# readability-else-after-return, # has issues
# readability-enum-initial-value, # has issues
# readability-implicit-bool-conversion, # has issues
# readability-make-member-function-const, # has issues
# readability-math-missing-parentheses, # has issues
readability-misleading-indentation,
readability-non-const-parameter,
readability-redundant-casting,
readability-redundant-declaration,
readability-redundant-inline-specifier,
readability-redundant-member-init,
# readability-redundant-casting, # has issues
# readability-redundant-declaration, # has issues
# readability-redundant-inline-specifier, # has issues
# readability-redundant-member-init, # has issues
readability-redundant-string-init,
readability-reference-to-constructed-temporary,
readability-simplify-boolean-expr,
readability-static-definition-in-anonymous-namespace,
readability-suspicious-call-argument,
# readability-simplify-boolean-expr, # has issues
# readability-static-definition-in-anonymous-namespace, # has issues
# readability-suspicious-call-argument, # has issues
readability-use-std-min-max
"
# ---
# checks that have some issues that need to be resolved:
# other checks that have issues that need to be resolved:
#
# llvm-namespace-comment,
# misc-const-correctness,
@@ -134,7 +141,7 @@ Checks: "-*,
#
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
# readability-identifier-naming,
# readability-identifier-naming, # https://github.com/XRPLF/rippled/pull/6571
#
# modernize-concat-nested-namespaces,
# modernize-pass-by-value,
@@ -148,12 +155,6 @@ Checks: "-*,
# modernize-use-starts-ends-with,
# modernize-use-std-numbers,
# modernize-use-using,
#
# performance-faster-string-find,
# performance-for-range-copy,
# performance-inefficient-vector-operation,
# performance-move-const-arg,
# performance-no-automatic-move,
# ---
#
CheckOptions:
@@ -195,5 +196,6 @@ CheckOptions:
bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc
# misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*;.*ranges_lower_bound\.h;time.h;stdlib.h;__chrono/.*;fmt/chrono.h;boost/uuid/uuid_hash.hpp'
#
# HeaderFilterRegex: '^.*/(src|tests)/.*\.(h|hpp)$'
HeaderFilterRegex: '^.*/(test|xrpl|xrpld)/.*\.(h|hpp)$'
ExcludeHeaderFilterRegex: '^.*/protocol_autogen/.*\.(h|hpp)$'
WarningsAsErrors: "*"
@@ -21,6 +21,7 @@ libxrpl.protocol > xrpl.json
libxrpl.protocol > xrpl.protocol
libxrpl.protocol_autogen > xrpl.protocol_autogen
libxrpl.rdb > xrpl.basics
libxrpl.rdb > xrpl.core
libxrpl.rdb > xrpl.rdb
libxrpl.resource > xrpl.basics
libxrpl.resource > xrpl.json
@@ -184,7 +185,6 @@ xrpl.conditions > xrpl.basics
xrpl.conditions > xrpl.protocol
xrpl.core > xrpl.basics
xrpl.core > xrpl.json
xrpl.core > xrpl.ledger
xrpl.core > xrpl.protocol
xrpl.json > xrpl.basics
xrpl.ledger > xrpl.basics
+3 -4
View File
@@ -6,7 +6,6 @@ on:
push:
branches:
- "develop"
- "release*"
paths:
- ".github/workflows/publish-docs.yml"
- "*.md"
@@ -82,13 +81,13 @@ jobs:
cmake --build . --target docs --parallel ${BUILD_NPROC}
- name: Create documentation artifact
if: ${{ github.event_name == 'push' }}
if: ${{ github.event.repository.visibility == 'public' && github.event_name == 'push' }}
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
with:
path: ${{ env.BUILD_DIR }}/docs/html
deploy:
if: ${{ github.event_name == 'push' }}
if: ${{ github.event.repository.visibility == 'public' && github.event_name == 'push' }}
needs: build
runs-on: ubuntu-latest
permissions:
@@ -100,4 +99,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
@@ -199,7 +199,7 @@ jobs:
fi
- name: Upload the binary (Linux)
if: ${{ github.repository == 'XRPLF/rippled' && runner.os == 'Linux' }}
if: ${{ github.event.repository.visibility == 'public' && runner.os == 'Linux' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: xrpld-${{ inputs.config_name }}
@@ -298,7 +298,7 @@ jobs:
- name: Upload coverage report
if: ${{ github.repository == 'XRPLF/rippled' && !inputs.build_only && env.COVERAGE_ENABLED == 'true' }}
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
disable_search: true
disable_telem: true
@@ -83,7 +83,7 @@ jobs:
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" ${TARGETS} 2>&1 | tee clang-tidy-output.txt
- name: Upload clang-tidy output
if: steps.run_clang_tidy.outcome != 'success'
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: clang-tidy-results
+13 -3
View File
@@ -70,14 +70,24 @@ JobQueue::Coro::resume()
running_ = true;
}
{
std::lock_guard lock(jq_.m_mutex);
std::lock_guard lk(jq_.m_mutex);
--jq_.nSuspend_;
}
auto saved = detail::getLocalValues().release();
detail::getLocalValues().reset(&lvs_);
std::lock_guard lock(mutex_);
XRPL_ASSERT(static_cast<bool>(coro_), "xrpl::JobQueue::Coro::resume : is runnable");
coro_();
// A late resume() can arrive after the coroutine has already completed.
// This is an expected (if rare) outcome of the race condition documented
// in JobQueue.h:354-377 where post() schedules a resume job before the
// coroutine yields — the mutex serializes access, but by the time this
// resume() acquires the lock the coroutine may have already run to
// completion. Calling operator() on a completed boost::coroutine2 is
// undefined behavior, so we must check and skip invoking the coroutine
// body if it has already completed.
if (coro_)
{
coro_();
}
detail::getLocalValues().release();
detail::getLocalValues().reset(saved);
std::lock_guard lk(mutex_run_);
+6 -4
View File
@@ -99,8 +99,8 @@ public:
Effects:
The coroutine continues execution from where it last left off
using this same thread.
Undefined behavior if called after the coroutine has completed
with a return (as opposed to a yield()).
If the coroutine has already completed, returns immediately
(handles the documented post-before-yield race condition).
Undefined behavior if resume() or post() called consecutively
without a corresponding yield.
*/
@@ -357,8 +357,10 @@ private:
If the post() job were to be executed before yield(), undefined behavior
would occur. The lock ensures that coro_ is not called again until we exit
the coroutine. At which point a scheduled resume() job waiting on the lock
would gain entry, harmlessly call coro_ and immediately return as we have
already completed the coroutine.
would gain entry. resume() checks if the coroutine has already completed
(coro_ converts to false) and, if so, skips invoking operator() since
calling operator() on a completed boost::coroutine2 pull_type is undefined
behavior.
The race condition occurs as follows:
+30 -17
View File
@@ -3,7 +3,6 @@
#include <xrpl/basics/Blob.h>
#include <xrpl/basics/SHAMapHash.h>
#include <xrpl/basics/TaggedCache.h>
#include <xrpl/ledger/CachedSLEs.h>
#include <boost/asio.hpp>
@@ -23,6 +22,20 @@ class PerfLog;
// This is temporary until we migrate all code to use ServiceRegistry.
class Application;
template <
class Key,
class T,
bool IsKeyCache,
class SharedWeakUnionPointer,
class SharedPointerType,
class Hash,
class KeyEqual,
class Mutex>
class TaggedCache;
class STLedgerEntry;
using SLE = STLedgerEntry;
using CachedSLEs = TaggedCache<uint256, SLE const>;
// Forward declarations
class AcceptedLedger;
class AmendmentTable;
@@ -89,7 +102,7 @@ public:
getNodeFamily() = 0;
virtual TimeKeeper&
timeKeeper() = 0;
getTimeKeeper() = 0;
virtual JobQueue&
getJobQueue() = 0;
@@ -98,7 +111,7 @@ public:
getTempNodeCache() = 0;
virtual CachedSLEs&
cachedSLEs() = 0;
getCachedSLEs() = 0;
virtual NetworkIDService&
getNetworkIDService() = 0;
@@ -120,26 +133,26 @@ public:
getValidations() = 0;
virtual ValidatorList&
validators() = 0;
getValidators() = 0;
virtual ValidatorSite&
validatorSites() = 0;
getValidatorSites() = 0;
virtual ManifestCache&
validatorManifests() = 0;
getValidatorManifests() = 0;
virtual ManifestCache&
publisherManifests() = 0;
getPublisherManifests() = 0;
// Network services
virtual Overlay&
overlay() = 0;
getOverlay() = 0;
virtual Cluster&
cluster() = 0;
getCluster() = 0;
virtual PeerReservationTable&
peerReservations() = 0;
getPeerReservations() = 0;
virtual Resource::Manager&
getResourceManager() = 0;
@@ -174,13 +187,13 @@ public:
getLedgerReplayer() = 0;
virtual PendingSaves&
pendingSaves() = 0;
getPendingSaves() = 0;
virtual OpenLedger&
openLedger() = 0;
getOpenLedger() = 0;
virtual OpenLedger const&
openLedger() const = 0;
getOpenLedger() const = 0;
// Transaction and operation services
virtual NetworkOPs&
@@ -210,16 +223,16 @@ public:
isStopping() const = 0;
virtual beast::Journal
journal(std::string const& name) = 0;
getJournal(std::string const& name) = 0;
virtual boost::asio::io_context&
getIOContext() = 0;
virtual Logs&
logs() = 0;
getLogs() = 0;
virtual std::optional<uint256> const&
trapTxID() const = 0;
getTrapTxID() const = 0;
/** Retrieve the "wallet database" */
virtual DatabaseCon&
@@ -228,7 +241,7 @@ public:
// Temporary: Get the underlying Application for functions that haven't
// been migrated yet. This should be removed once all code is migrated.
virtual Application&
app() = 0;
getApp() = 0;
};
} // namespace xrpl
+1 -1
View File
@@ -5,7 +5,7 @@
namespace xrpl {
enum class StartUpType { FRESH, NORMAL, LOAD, LOAD_FILE, REPLAY, NETWORK };
enum class StartUpType { Fresh, Normal, Load, LoadFile, Replay, Network };
inline std::ostream&
operator<<(std::ostream& os, StartUpType const& type)
+18 -1
View File
@@ -76,16 +76,33 @@ public:
@return true if a book from this issue to XRP exists
*/
virtual bool
isBookToXRP(Issue const& issue, std::optional<Domain> domain = std::nullopt) = 0;
isBookToXRP(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) = 0;
/**
* Process a transaction for order book tracking.
* @param ledger The ledger the transaction was applied to
* @param alTx The transaction to process
* @param jvObj The JSON object of the transaction
*/
virtual void
processTxn(
std::shared_ptr<ReadView const> const& ledger,
AcceptedLedgerTx const& alTx,
MultiApiJson const& jvObj) = 0;
/**
* Get the book listeners for a book.
* @param book The book to get the listeners for
* @return The book listeners for the book
*/
virtual BookListeners::pointer
getBookListeners(Book const&) = 0;
/**
* Create a new book listeners for a book.
* @param book The book to create the listeners for
* @return The new book listeners for the book
*/
virtual BookListeners::pointer
makeBookListeners(Book const&) = 0;
};
-9
View File
@@ -69,9 +69,6 @@ public:
std::vector<uint256>::iterator
insert(std::vector<uint256>::const_iterator pos, uint256 const& value);
std::vector<uint256>::iterator
insert(std::vector<uint256>::const_iterator pos, uint256&& value);
void
push_back(uint256 const& v);
@@ -184,12 +181,6 @@ STVector256::insert(std::vector<uint256>::const_iterator pos, uint256 const& val
return mValue.insert(pos, value);
}
inline std::vector<uint256>::iterator
STVector256::insert(std::vector<uint256>::const_iterator pos, uint256&& value)
{
return mValue.insert(pos, std::move(value));
}
inline void
STVector256::push_back(uint256 const& v)
{
+1 -1
View File
@@ -2,6 +2,6 @@
namespace xrpl {
enum class TxSearched { all, some, unknown };
enum class TxSearched { All, Some, Unknown };
}
+8 -8
View File
@@ -1,6 +1,7 @@
#pragma once
#include <xrpl/core/PerfLog.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/core/StartUpType.h>
#include <xrpl/rdb/DBInit.h>
#include <xrpl/rdb/SociDB.h>
@@ -69,7 +70,7 @@ public:
{
explicit Setup() = default;
StartUpType startUp = StartUpType::NORMAL;
StartUpType startUp = StartUpType::Normal;
bool standAlone = false;
boost::filesystem::path dataDir;
// Indicates whether or not to return the `globalPragma`
@@ -94,7 +95,7 @@ public:
struct CheckpointerSetup
{
JobQueue* jobQueue;
Logs* logs;
std::reference_wrapper<ServiceRegistry> registry;
};
template <std::size_t N, std::size_t M>
@@ -106,9 +107,8 @@ public:
beast::Journal journal)
// Use temporary files or regular DB files?
: DatabaseCon(
setup.standAlone && setup.startUp != StartUpType::LOAD &&
setup.startUp != StartUpType::LOAD_FILE &&
setup.startUp != StartUpType::REPLAY
setup.standAlone && setup.startUp != StartUpType::Load &&
setup.startUp != StartUpType::LoadFile && setup.startUp != StartUpType::Replay
? ""
: (setup.dataDir / dbName),
setup.commonPragma(),
@@ -129,7 +129,7 @@ public:
beast::Journal journal)
: DatabaseCon(setup, dbName, pragma, initSQL, journal)
{
setupCheckpointing(checkpointerSetup.jobQueue, *checkpointerSetup.logs);
setupCheckpointing(checkpointerSetup.jobQueue, checkpointerSetup.registry.get());
}
template <std::size_t N, std::size_t M>
@@ -154,7 +154,7 @@ public:
beast::Journal journal)
: DatabaseCon(dataDir, dbName, pragma, initSQL, journal)
{
setupCheckpointing(checkpointerSetup.jobQueue, *checkpointerSetup.logs);
setupCheckpointing(checkpointerSetup.jobQueue, checkpointerSetup.registry.get());
}
~DatabaseCon();
@@ -177,7 +177,7 @@ public:
private:
void
setupCheckpointing(JobQueue*, Logs&);
setupCheckpointing(JobQueue*, ServiceRegistry&);
template <std::size_t N, std::size_t M>
DatabaseCon(
+10 -9
View File
@@ -49,8 +49,9 @@ public:
struct AccountTxOptions
{
AccountID const& account;
std::uint32_t minLedger;
std::uint32_t maxLedger;
/// Ledger sequence range to search. A value of 0 for min or max
/// means unbounded in that direction (no constraint applied).
LedgerRange ledgerRange;
std::uint32_t offset;
std::uint32_t limit;
bool bUnlimited;
@@ -59,8 +60,7 @@ public:
struct AccountTxPageOptions
{
AccountID const& account;
std::uint32_t minLedger;
std::uint32_t maxLedger;
LedgerRange ledgerRange;
std::optional<AccountTxMarker> marker;
std::uint32_t limit;
bool bAdmin;
@@ -247,7 +247,7 @@ public:
* @return Struct CountMinMax which contains the minimum sequence,
* maximum sequence and number of ledgers.
*/
virtual struct CountMinMax
virtual CountMinMax
getLedgerCountMinMax() = 0;
/**
@@ -405,10 +405,10 @@ public:
* @param id Hash of the transaction.
* @param range Range of ledgers to check, if present.
* @param ec Default error code value.
* @return Transaction and its metadata if found, otherwise TxSearched::all
* @return Transaction and its metadata if found, otherwise TxSearched::All
* if a range is provided and all ledgers from the range are present
* in the database, TxSearched::some if a range is provided and not
* all ledgers are present, TxSearched::unknown if the range is not
* in the database, TxSearched::Some if a range is provided and not
* all ledgers are present, TxSearched::Unknown if the range is not
* provided or a deserializing error occurred. In the last case the
* error code is returned via the ec parameter, in other cases the
* default error code is not changed.
@@ -455,9 +455,10 @@ public:
closeTransactionDB() = 0;
};
template <class T, class C>
template <typename T, typename C>
T
rangeCheckedCast(C c)
requires(std::is_arithmetic_v<T> && std::is_arithmetic_v<C> && std::convertible_to<C, T>)
{
if ((c > std::numeric_limits<T>::max()) || (!std::numeric_limits<T>::is_signed && c < 0) ||
(std::numeric_limits<T>::is_signed && std::numeric_limits<C>::is_signed &&
+2 -2
View File
@@ -13,8 +13,8 @@
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
#include <xrpl/basics/Log.h>
#include <xrpl/core/JobQueue.h>
#include <xrpl/core/ServiceRegistry.h>
#define SOCI_USE_BOOST
#include <soci/soci.h>
@@ -111,7 +111,7 @@ public:
and so must outlive them both.
*/
std::shared_ptr<Checkpointer>
makeCheckpointer(std::uintptr_t id, std::weak_ptr<soci::session>, JobQueue&, Logs&);
makeCheckpointer(std::uintptr_t id, std::weak_ptr<soci::session>, JobQueue&, ServiceRegistry&);
} // namespace xrpl
+1 -1
View File
@@ -37,7 +37,7 @@ public:
XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set");
}
ServiceRegistry& registry;
std::reference_wrapper<ServiceRegistry> registry;
STTx const& tx;
TER const preclaimResult;
XRPAmount const baseFee;
+2 -2
View File
@@ -13,7 +13,7 @@ namespace xrpl {
struct PreflightContext
{
public:
ServiceRegistry& registry;
std::reference_wrapper<ServiceRegistry> registry;
STTx const& tx;
Rules const rules;
ApplyFlags flags;
@@ -56,7 +56,7 @@ public:
struct PreclaimContext
{
public:
ServiceRegistry& registry;
std::reference_wrapper<ServiceRegistry> registry;
ReadView const& view;
TER preflightResult;
ApplyFlags flags;
@@ -7,6 +7,7 @@
#include <xrpl/protocol/TER.h>
#include <xrpl/tx/invariants/AMMInvariant.h>
#include <xrpl/tx/invariants/FreezeInvariant.h>
#include <xrpl/tx/invariants/LoanBrokerInvariant.h>
#include <xrpl/tx/invariants/LoanInvariant.h>
#include <xrpl/tx/invariants/MPTInvariant.h>
#include <xrpl/tx/invariants/NFTInvariant.h>
@@ -0,0 +1,55 @@
#pragma once
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TER.h>
#include <map>
#include <vector>
namespace xrpl {
/**
* @brief Invariants: Loan brokers are internally consistent
*
* 1. If `LoanBroker.OwnerCount = 0` the `DirectoryNode` will have at most one
* node (the root), which will only hold entries for `RippleState` or
* `MPToken` objects.
*
*/
class ValidLoanBroker
{
// Not all of these elements will necessarily be populated. Remaining items
// will be looked up as needed.
struct BrokerInfo
{
SLE::const_pointer brokerBefore = nullptr;
// After is used for most of the checks, except
// those that check changed values.
SLE::const_pointer brokerAfter = nullptr;
};
// Collect all the LoanBrokers found directly or indirectly through
// pseudo-accounts. Key is the brokerID / index. It will be used to find the
// LoanBroker object if brokerBefore and brokerAfter are nullptr
std::map<uint256, BrokerInfo> brokers_;
// Collect all the modified trust lines. Their high and low accounts will be
// loaded to look for LoanBroker pseudo-accounts.
std::vector<SLE::const_pointer> lines_;
// Collect all the modified MPTokens. Their accounts will be loaded to look
// for LoanBroker pseudo-accounts.
std::vector<SLE::const_pointer> mpts_;
static bool
goodZeroDirectory(ReadView const& view, SLE::const_ref dir, beast::Journal const& j);
public:
void
visitEntry(bool, std::shared_ptr<SLE const> const&, std::shared_ptr<SLE const> const&);
bool
finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&);
};
} // namespace xrpl
@@ -1,57 +1,14 @@
#pragma once
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TER.h>
#include <map>
#include <vector>
namespace xrpl {
/**
* @brief Invariants: Loan brokers are internally consistent
*
* 1. If `LoanBroker.OwnerCount = 0` the `DirectoryNode` will have at most one
* node (the root), which will only hold entries for `RippleState` or
* `MPToken` objects.
*
*/
class ValidLoanBroker
{
// Not all of these elements will necessarily be populated. Remaining items
// will be looked up as needed.
struct BrokerInfo
{
SLE::const_pointer brokerBefore = nullptr;
// After is used for most of the checks, except
// those that check changed values.
SLE::const_pointer brokerAfter = nullptr;
};
// Collect all the LoanBrokers found directly or indirectly through
// pseudo-accounts. Key is the brokerID / index. It will be used to find the
// LoanBroker object if brokerBefore and brokerAfter are nullptr
std::map<uint256, BrokerInfo> brokers_;
// Collect all the modified trust lines. Their high and low accounts will be
// loaded to look for LoanBroker pseudo-accounts.
std::vector<SLE::const_pointer> lines_;
// Collect all the modified MPTokens. Their accounts will be loaded to look
// for LoanBroker pseudo-accounts.
std::vector<SLE::const_pointer> mpts_;
static bool
goodZeroDirectory(ReadView const& view, SLE::const_ref dir, beast::Journal const& j);
public:
void
visitEntry(bool, std::shared_ptr<SLE const> const&, std::shared_ptr<SLE const> const&);
bool
finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&);
};
/**
* @brief Invariants: Loans are internally consistent
*
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include <xrpl/basics/Log.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/ledger/PaymentSandbox.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/TER.h>
@@ -92,7 +92,7 @@ public:
STPathSet const& spsPaths,
std::optional<uint256> const& domainID,
Logs& l,
ServiceRegistry& registry,
Input const* const pInputs = nullptr);
// The view we are currently working on
+4 -5
View File
@@ -203,7 +203,7 @@ getAMMOfferStartWithTakerGets(
// Try to reduce the offer size to improve the quality.
// The quality might still not match the targetQuality for a tiny offer.
if (auto const amounts = getAmounts(*nTakerGets); Quality{amounts} < targetQuality)
if (auto amounts = getAmounts(*nTakerGets); Quality{amounts} < targetQuality)
return getAmounts(detail::reduceOffer(amounts.out));
else
return amounts;
@@ -270,7 +270,7 @@ getAMMOfferStartWithTakerPays(
// Try to reduce the offer size to improve the quality.
// The quality might still not match the targetQuality for a tiny offer.
if (auto const amounts = getAmounts(*nTakerPays); Quality{amounts} < targetQuality)
if (auto amounts = getAmounts(*nTakerPays); Quality{amounts} < targetQuality)
return getAmounts(detail::reduceOffer(amounts.in));
else
return amounts;
@@ -335,8 +335,7 @@ changeSpotPriceQuality(
}
auto const takerPays = toAmount<TIn>(getIssue(pool.in), nTakerPays, Number::upward);
// should not fail
if (auto const amounts =
TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
if (auto amounts = TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
Quality{amounts} < quality &&
!withinRelativeDistance(Quality{amounts}, quality, Number(1, -7)))
{
@@ -362,7 +361,7 @@ changeSpotPriceQuality(
// Generate the offer starting with XRP side. Return seated offer amounts
// if the offer can be generated, otherwise nullopt.
auto const amounts = [&]() {
auto amounts = [&]() {
if (isXRP(getIssue(pool.out)))
return getAMMOfferStartWithTakerGets(pool, quality, tfee);
return getAMMOfferStartWithTakerPays(pool, quality, tfee);
+1 -1
View File
@@ -45,7 +45,7 @@ getFileContents(
return {};
}
std::string const result{
std::string result{
std::istreambuf_iterator<char>{fileStream}, std::istreambuf_iterator<char>{}};
if (fileStream.bad())
+2 -3
View File
@@ -80,8 +80,7 @@ public:
txs_iter_impl(txs_iter_impl const&) = default;
txs_iter_impl(bool metadata, SHAMap::const_iterator iter)
: metadata_(metadata), iter_(std::move(iter))
txs_iter_impl(bool metadata, SHAMap::const_iterator iter) : metadata_(metadata), iter_(iter)
{
}
@@ -694,7 +693,7 @@ Ledger::updateNegativeUNL()
if (sle->isFieldPresent(sfDisabledValidators))
{
auto const& oldNUnl = sle->getFieldArray(sfDisabledValidators);
for (auto v : oldNUnl)
for (auto const& v : oldNUnl)
{
if (hasToReEnable && v.isFieldPresent(sfPublicKey) &&
v.getFieldVL(sfPublicKey) == sle->getFieldVL(sfValidatorToReEnable))
+1 -1
View File
@@ -161,7 +161,7 @@ getLineIfUsable(
FreezeHandling zeroIfFrozen,
beast::Journal j)
{
auto const sle = view.read(keylet::line(account, issuer, currency));
auto sle = view.read(keylet::line(account, issuer, currency));
if (!sle)
{
+2 -2
View File
@@ -23,7 +23,7 @@ namespace {
// and follow the format described at http://semver.org/
//------------------------------------------------------------------------------
// clang-format off
char const* const versionString = "3.2.0-b0"
char const* const versionString = "3.2.0-b2"
// clang-format on
;
@@ -113,7 +113,7 @@ encodeSoftwareVersion(std::string_view versionStr)
{
std::uint8_t x = 0;
for (auto id : v.preReleaseIdentifiers)
for (auto const& id : v.preReleaseIdentifiers)
{
auto parsePreRelease = [](std::string_view identifier,
std::string_view prefix,
+2 -2
View File
@@ -153,7 +153,7 @@ STPath::getJson(JsonOptions) const
{
Json::Value ret(Json::arrayValue);
for (auto it : mPath)
for (auto const& it : mPath)
{
Json::Value elem(Json::objectValue);
auto const iType = it.getNodeType();
@@ -179,7 +179,7 @@ Json::Value
STPathSet::getJson(JsonOptions options) const
{
Json::Value ret(Json::arrayValue);
for (auto it : value)
for (auto const& it : value)
ret.append(it.getJson(options));
return ret;
+9 -6
View File
@@ -1,5 +1,5 @@
#include <xrpl/basics/Log.h>
#include <xrpl/basics/contract.h>
#include <xrpl/core/ServiceRegistry.h>
#include <xrpl/rdb/DatabaseCon.h>
#include <xrpl/rdb/SociDB.h>
@@ -29,7 +29,7 @@ public:
auto it = checkpointers_.find(id);
if (it != checkpointers_.end())
return it->second;
return {};
return nullptr;
}
void
@@ -40,11 +40,14 @@ public:
}
std::shared_ptr<Checkpointer>
create(std::shared_ptr<soci::session> const& session, JobQueue& jobQueue, Logs& logs)
create(
std::shared_ptr<soci::session> const& session,
JobQueue& jobQueue,
ServiceRegistry& registry)
{
std::lock_guard lock{mutex_};
auto const id = nextId_++;
auto const r = makeCheckpointer(id, session, jobQueue, logs);
auto const r = makeCheckpointer(id, session, jobQueue, registry);
checkpointers_[id] = r;
return r;
}
@@ -82,11 +85,11 @@ DatabaseCon::~DatabaseCon()
std::unique_ptr<std::vector<std::string> const> DatabaseCon::Setup::globalPragma;
void
DatabaseCon::setupCheckpointing(JobQueue* q, Logs& l)
DatabaseCon::setupCheckpointing(JobQueue* q, ServiceRegistry& registry)
{
if (q == nullptr)
Throw<std::logic_error>("No JobQueue");
checkpointer_ = checkpointers.create(session_, *q, l);
checkpointer_ = checkpointers.create(session_, *q, registry);
}
} // namespace xrpl
+7 -4
View File
@@ -187,8 +187,11 @@ public:
std::uintptr_t id,
std::weak_ptr<soci::session> session,
JobQueue& q,
Logs& logs)
: id_(id), session_(std::move(session)), jobQueue_(q), j_(logs.journal("WALCheckpointer"))
ServiceRegistry& registry)
: id_(id)
, session_(std::move(session))
, jobQueue_(q)
, j_(registry.getJournal("WALCheckpointer"))
{
if (auto [conn, keepAlive] = getConnection(); conn)
{
@@ -307,9 +310,9 @@ makeCheckpointer(
std::uintptr_t id,
std::weak_ptr<soci::session> session,
JobQueue& queue,
Logs& logs)
ServiceRegistry& registry)
{
return std::make_shared<WALCheckpointer>(id, std::move(session), queue, logs);
return std::make_shared<WALCheckpointer>(id, std::move(session), queue, registry);
}
} // namespace xrpl
+1 -4
View File
@@ -1021,10 +1021,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t)
// save our place and work on this node
stack.emplace(std::move(node), branch);
// The semantics of this changes when we move to c++-20
// Right now no move will occur; With c++-20 child will
// be moved from.
node = intr_ptr::static_pointer_cast<SHAMapInnerNode>(std::move(child));
node = intr_ptr::static_pointer_cast<SHAMapInnerNode>(child);
pos = 0;
}
else
+20 -9
View File
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/basics/contract.h>
#include <xrpl/core/NetworkIDService.h>
#include <xrpl/json/to_string.h>
@@ -35,7 +34,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask)
if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID))
{
uint32_t nodeNID = ctx.registry.getNetworkIDService().getNetworkID();
uint32_t nodeNID = ctx.registry.get().getNetworkIDService().getNetworkID();
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];
if (nodeNID <= 1024)
@@ -212,7 +211,7 @@ Transactor::preflight2(PreflightContext const& ctx)
// Do not add any checks after this point that are relevant for
// batch inner transactions. They will be skipped.
auto const sigValid = checkValidity(ctx.registry.getHashRouter(), ctx.tx, ctx.rules);
auto const sigValid = checkValidity(ctx.registry.get().getHashRouter(), ctx.tx, ctx.rules);
if (sigValid.first == Validity::SigBad)
{ // LCOV_EXCL_START
JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second;
@@ -302,7 +301,7 @@ Transactor::calculateOwnerReserveFee(ReadView const& view, STTx const& tx)
// need to rethink charging an owner reserve as a transaction fee.
// TODO: This function is static, and I don't want to add more parameters.
// When it is finally refactored to be in a context that has access to the
// Application, include "app().overlay().networkID() > 2 ||" in the
// Application, include "app().getOverlay().networkID() > 2 ||" in the
// condition.
XRPL_ASSERT(
view.fees().increment > view.fees().base * 100,
@@ -1096,7 +1095,8 @@ Transactor::operator()()
}
#endif
if (auto const& trap = ctx_.registry.trapTxID(); trap && *trap == ctx_.tx.getTransactionID())
if (auto const& trap = ctx_.registry.get().getTrapTxID();
trap && *trap == ctx_.tx.getTransactionID())
{
trapTransaction(*trap);
}
@@ -1198,16 +1198,27 @@ Transactor::operator()()
// If necessary, remove any offers found unfunded during processing
if ((result == tecOVERSIZE) || (result == tecKILLED))
removeUnfundedOffers(view(), removedOffers, ctx_.registry.journal("View"));
{
removeUnfundedOffers(view(), removedOffers, ctx_.registry.get().getJournal("View"));
}
if (result == tecEXPIRED)
removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.registry.journal("View"));
{
removeExpiredNFTokenOffers(
view(), expiredNFTokenOffers, ctx_.registry.get().getJournal("View"));
}
if (result == tecINCOMPLETE)
removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.journal("View"));
{
removeDeletedTrustLines(
view(), removedTrustLines, ctx_.registry.get().getJournal("View"));
}
if (result == tecEXPIRED)
removeExpiredCredentials(view(), expiredCredentials, ctx_.registry.journal("View"));
{
removeExpiredCredentials(
view(), expiredCredentials, ctx_.registry.get().getJournal("View"));
}
applied = isTecClaim(result);
}
@@ -0,0 +1,194 @@
#include <xrpl/tx/invariants/LoanBrokerInvariant.h>
//
#include <xrpl/basics/Log.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/STNumber.h>
#include <xrpl/protocol/TxFormats.h>
namespace xrpl {
void
ValidLoanBroker::visitEntry(
bool isDelete,
std::shared_ptr<SLE const> const& before,
std::shared_ptr<SLE const> const& after)
{
if (after)
{
if (after->getType() == ltLOAN_BROKER)
{
auto& broker = brokers_[after->key()];
broker.brokerBefore = before;
broker.brokerAfter = after;
}
else if (after->getType() == ltACCOUNT_ROOT && after->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = after->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
else if (after->getType() == ltRIPPLE_STATE)
{
lines_.emplace_back(after);
}
else if (after->getType() == ltMPTOKEN)
{
mpts_.emplace_back(after);
}
}
}
bool
ValidLoanBroker::goodZeroDirectory(
ReadView const& view,
SLE::const_ref dir,
beast::Journal const& j)
{
auto const next = dir->at(~sfIndexNext);
auto const prev = dir->at(~sfIndexPrevious);
if ((prev && (*prev != 0u)) || (next && (*next != 0u)))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has multiple directory pages";
return false;
}
auto indexes = dir->getFieldV256(sfIndexes);
if (indexes.size() > 1)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has multiple indexes in the Directory root";
return false;
}
if (indexes.size() == 1)
{
auto const index = indexes.value().front();
auto const sle = view.read(keylet::unchecked(index));
if (!sle)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker directory corrupt";
return false;
}
if (sle->getType() != ltRIPPLE_STATE && sle->getType() != ltMPTOKEN)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has an unexpected entry in the directory";
return false;
}
}
return true;
}
bool
ValidLoanBroker::finalize(
STTx const& tx,
TER const,
XRPAmount const,
ReadView const& view,
beast::Journal const& j)
{
// Loan Brokers will not exist on ledger if the Lending Protocol amendment
// is not enabled, so there's no need to check it.
for (auto const& line : lines_)
{
for (auto const& field : {&sfLowLimit, &sfHighLimit})
{
auto const account = view.read(keylet::account(line->at(*field).getIssuer()));
// This Invariant doesn't know about the rules for Trust Lines, so
// if the account is missing, don't treat it as an error. This
// loop is only concerned with finding Broker pseudo-accounts
if (account && account->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = account->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
}
}
for (auto const& mpt : mpts_)
{
auto const account = view.read(keylet::account(mpt->at(sfAccount)));
// This Invariant doesn't know about the rules for MPTokens, so
// if the account is missing, don't treat is as an error. This
// loop is only concerned with finding Broker pseudo-accounts
if (account && account->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = account->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
}
for (auto const& [brokerID, broker] : brokers_)
{
auto const& after =
broker.brokerAfter ? broker.brokerAfter : view.read(keylet::loanbroker(brokerID));
if (!after)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker missing";
return false;
}
auto const& before = broker.brokerBefore;
// https://github.com/Tapanito/XRPL-Standards/blob/xls-66-lending-protocol/XLS-0066d-lending-protocol/README.md#3123-invariants
// If `LoanBroker.OwnerCount = 0` the `DirectoryNode` will have at most
// one node (the root), which will only hold entries for `RippleState`
// or `MPToken` objects.
if (after->at(sfOwnerCount) == 0)
{
auto const dir = view.read(keylet::ownerDir(after->at(sfAccount)));
if (dir)
{
if (!goodZeroDirectory(view, dir, j))
{
return false;
}
}
}
if (before && before->at(sfLoanSequence) > after->at(sfLoanSequence))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker sequence number "
"decreased";
return false;
}
if (after->at(sfDebtTotal) < 0)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker debt total is negative";
return false;
}
if (after->at(sfCoverAvailable) < 0)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker cover available is negative";
return false;
}
auto const vault = view.read(keylet::vault(after->at(sfVaultID)));
if (!vault)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker vault ID is invalid";
return false;
}
auto const& vaultAsset = vault->at(sfAsset);
if (after->at(sfCoverAvailable) < accountHolds(
view,
after->at(sfAccount),
vaultAsset,
FreezeHandling::fhIGNORE_FREEZE,
AuthHandling::ahIGNORE_AUTH,
j))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker cover available "
"is less than pseudo-account asset balance";
return false;
}
}
return true;
}
} // namespace xrpl
+1 -188
View File
@@ -2,197 +2,11 @@
//
#include <xrpl/basics/Log.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/STNumber.h>
#include <xrpl/protocol/TxFormats.h>
namespace xrpl {
void
ValidLoanBroker::visitEntry(
bool isDelete,
std::shared_ptr<SLE const> const& before,
std::shared_ptr<SLE const> const& after)
{
if (after)
{
if (after->getType() == ltLOAN_BROKER)
{
auto& broker = brokers_[after->key()];
broker.brokerBefore = before;
broker.brokerAfter = after;
}
else if (after->getType() == ltACCOUNT_ROOT && after->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = after->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
else if (after->getType() == ltRIPPLE_STATE)
{
lines_.emplace_back(after);
}
else if (after->getType() == ltMPTOKEN)
{
mpts_.emplace_back(after);
}
}
}
bool
ValidLoanBroker::goodZeroDirectory(
ReadView const& view,
SLE::const_ref dir,
beast::Journal const& j)
{
auto const next = dir->at(~sfIndexNext);
auto const prev = dir->at(~sfIndexPrevious);
if ((prev && (*prev != 0u)) || (next && (*next != 0u)))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has multiple directory pages";
return false;
}
auto indexes = dir->getFieldV256(sfIndexes);
if (indexes.size() > 1)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has multiple indexes in the Directory root";
return false;
}
if (indexes.size() == 1)
{
auto const index = indexes.value().front();
auto const sle = view.read(keylet::unchecked(index));
if (!sle)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker directory corrupt";
return false;
}
if (sle->getType() != ltRIPPLE_STATE && sle->getType() != ltMPTOKEN)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker with zero "
"OwnerCount has an unexpected entry in the directory";
return false;
}
}
return true;
}
bool
ValidLoanBroker::finalize(
STTx const& tx,
TER const,
XRPAmount const,
ReadView const& view,
beast::Journal const& j)
{
// Loan Brokers will not exist on ledger if the Lending Protocol amendment
// is not enabled, so there's no need to check it.
for (auto const& line : lines_)
{
for (auto const& field : {&sfLowLimit, &sfHighLimit})
{
auto const account = view.read(keylet::account(line->at(*field).getIssuer()));
// This Invariant doesn't know about the rules for Trust Lines, so
// if the account is missing, don't treat it as an error. This
// loop is only concerned with finding Broker pseudo-accounts
if (account && account->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = account->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
}
}
for (auto const& mpt : mpts_)
{
auto const account = view.read(keylet::account(mpt->at(sfAccount)));
// This Invariant doesn't know about the rules for MPTokens, so
// if the account is missing, don't treat is as an error. This
// loop is only concerned with finding Broker pseudo-accounts
if (account && account->isFieldPresent(sfLoanBrokerID))
{
auto const& loanBrokerID = account->at(sfLoanBrokerID);
// create an entry if one doesn't already exist
brokers_.emplace(loanBrokerID, BrokerInfo{});
}
}
for (auto const& [brokerID, broker] : brokers_)
{
auto const& after =
broker.brokerAfter ? broker.brokerAfter : view.read(keylet::loanbroker(brokerID));
if (!after)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker missing";
return false;
}
auto const& before = broker.brokerBefore;
// https://github.com/Tapanito/XRPL-Standards/blob/xls-66-lending-protocol/XLS-0066d-lending-protocol/README.md#3123-invariants
// If `LoanBroker.OwnerCount = 0` the `DirectoryNode` will have at most
// one node (the root), which will only hold entries for `RippleState`
// or `MPToken` objects.
if (after->at(sfOwnerCount) == 0)
{
auto const dir = view.read(keylet::ownerDir(after->at(sfAccount)));
if (dir)
{
if (!goodZeroDirectory(view, dir, j))
{
return false;
}
}
}
if (before && before->at(sfLoanSequence) > after->at(sfLoanSequence))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker sequence number "
"decreased";
return false;
}
if (after->at(sfDebtTotal) < 0)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker debt total is negative";
return false;
}
if (after->at(sfCoverAvailable) < 0)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker cover available is negative";
return false;
}
auto const vault = view.read(keylet::vault(after->at(sfVaultID)));
if (!vault)
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker vault ID is invalid";
return false;
}
auto const& vaultAsset = vault->at(sfAsset);
if (after->at(sfCoverAvailable) < accountHolds(
view,
after->at(sfAccount),
vaultAsset,
FreezeHandling::fhIGNORE_FREEZE,
AuthHandling::ahIGNORE_AUTH,
j))
{
JLOG(j.fatal()) << "Invariant failed: Loan Broker cover available "
"is less than pseudo-account asset balance";
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
void
ValidLoan::visitEntry(
bool isDelete,
@@ -236,8 +50,7 @@ ValidLoan::finalize(
after->at(sfPrincipalOutstanding) == beast::zero &&
after->at(sfManagementFeeOutstanding) == beast::zero)
{
JLOG(j.fatal()) << "Invariant failed: Loan with zero payments "
"remaining has not been paid off";
JLOG(j.fatal()) << "Invariant failed: Fully paid off Loan still has payments remaining";
return false;
}
if (before && (before->isFlag(lsfLoanOverpayment) != after->isFlag(lsfLoanOverpayment)))
@@ -38,7 +38,7 @@ ValidPermissionedDomain::visitEntry(
break;
}
}
sleStatus.emplace_back(std::move(ss));
sleStatus.emplace_back(ss);
};
if (after)
+2 -2
View File
@@ -205,7 +205,7 @@ ValidVault::finalize(
for (auto const& e : beforeMPTs_)
{
if (e.share.getMptID() == beforeVault.shareMPTID)
return std::move(e);
return e;
}
return std::nullopt;
}();
@@ -374,7 +374,7 @@ ValidVault::finalize(
for (auto const& e : beforeMPTs_)
{
if (e.share.getMptID() == beforeVault.shareMPTID)
return std::move(e);
return e;
}
return std::nullopt;
}();
+2 -3
View File
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/tx/paths/Flow.h>
@@ -35,12 +34,12 @@ RippleCalc::rippleCalculate(
STPathSet const& spsPaths,
std::optional<uint256> const& domainID,
Logs& l,
ServiceRegistry& registry,
Input const* const pInputs)
{
Output flowOut;
PaymentSandbox flowSB(&view);
auto j = l.journal("Flow");
auto j = registry.getJournal("Flow");
{
bool const defaultPaths = (pInputs == nullptr) ? true : pInputs->defaultPathsAllowed;
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
@@ -197,7 +196,7 @@ removeSignersFromLedger(
}
adjustOwnerCount(
view, view.peek(accountKeylet), removeFromOwnerCount, registry.journal("View"));
view, view.peek(accountKeylet), removeFromOwnerCount, registry.getJournal("View"));
view.erase(signers);
@@ -315,7 +314,7 @@ SignerListSet::replaceSignerList()
view().insert(signerList);
writeSignersToSLE(signerList, flags);
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
// Add the signer list to the account's directory.
auto const page =
ctx_.view().dirInsert(ownerDirKeylet, signerListKeylet, describeOwnerDir(account_));
@@ -418,7 +418,7 @@ transferHelper(
auto const reserve = psb.fees().accountReserve(ownerCount);
auto const availableBalance = [&]() -> STAmount {
STAmount const curBal = (*sleSrc)[sfBalance];
STAmount curBal = (*sleSrc)[sfBalance];
// Checking that account == src and postFeeBalance == curBal is
// not strictly necessary, but helps protect against future
// changes
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
@@ -58,7 +57,7 @@ CheckCancel::doApply()
AccountID const srcId{sleCheck->getAccountID(sfAccount)};
AccountID const dstId{sleCheck->getAccountID(sfDestination)};
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
// If the check is not written to self (and it shouldn't be), remove the
// check from the destination account root.
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/basics/scope.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
@@ -233,7 +232,7 @@ CheckCash::doApply()
//
// If it is not a check to self (as should be the case), then there's
// work to do...
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
auto const optDeliverMin = ctx_.tx[~sfDeliverMin];
if (srcId != account_)
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
@@ -169,7 +168,7 @@ CheckCreate::doApply()
view().insert(sleCheck);
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
// If it's not a self-send (and it shouldn't be), add Check to the
// destination's owner directory.
if (dstAccountId != account_)
+1 -1
View File
@@ -281,7 +281,7 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J
Book const book{issueIn, issueOut, std::nullopt};
auto const dir = keylet::quality(keylet::book(book), uRate);
if (auto const bookExisted = static_cast<bool>(sb.read(dir)); !bookExisted)
ctx_.registry.getOrderBookDB().addOrderBook(book);
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
};
addOrderBook(amount.issue(), amount2.issue(), getRate(amount2, amount));
addOrderBook(amount2.issue(), amount.issue(), getRate(amount, amount2));
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/OfferHelpers.h>
#include <xrpl/protocol/st.h>
@@ -54,7 +53,7 @@ OfferCancel::doApply()
if (auto sleOffer = view().peek(keylet::offer(account_, offerSequence)))
{
JLOG(j_.debug()) << "Trying to cancel offer #" << offerSequence;
return offerDelete(view(), sleOffer, ctx_.registry.journal("View"));
return offerDelete(view(), sleOffer, ctx_.registry.get().getJournal("View"));
}
JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found.";
@@ -144,7 +144,7 @@ OfferCreate::preclaim(PreclaimContext const& ctx)
std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence);
auto viewJ = ctx.registry.journal("View");
auto viewJ = ctx.registry.get().getJournal("View");
if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID))
{
@@ -502,7 +502,7 @@ OfferCreate::applyHybrid(
bookArr.push_back(std::move(bookInfo));
if (!bookExists)
ctx_.registry.getOrderBookDB().addOrderBook(book);
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
sleOffer->setFieldArray(sfAdditionalBooks, bookArr);
return tesSUCCESS;
@@ -536,7 +536,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
// end up on the books.
auto uRate = getRate(saTakerGets, saTakerPays);
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
TER result = tesSUCCESS;
@@ -846,7 +846,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
sb.insert(sleOffer);
if (!bookExisted)
ctx_.registry.getOrderBookDB().addOrderBook(book);
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
JLOG(j_.debug()) << "final result: success";
@@ -73,7 +73,7 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx)
if (cb && fb)
{
auto& router = ctx.registry.getHashRouter();
auto& router = ctx.registry.get().getHashRouter();
auto const id = ctx.tx.getTransactionID();
auto const flags = router.getFlags(id);
@@ -237,7 +237,7 @@ EscrowFinish::doApply()
// Check cryptocondition fulfillment
{
auto const id = ctx_.tx.getTransactionID();
auto flags = ctx_.registry.getHashRouter().getFlags(id);
auto flags = ctx_.registry.get().getHashRouter().getFlags(id);
auto const cb = ctx_.tx[~sfCondition];
@@ -261,7 +261,7 @@ EscrowFinish::doApply()
flags = SF_CF_INVALID;
}
ctx_.registry.getHashRouter().setFlags(id, flags);
ctx_.registry.get().getHashRouter().setFlags(id, flags);
// LCOV_EXCL_STOP
}
@@ -344,7 +344,7 @@ NFTokenAcceptOffer::transferNFToken(
if (!tokenAndPage)
return tecINTERNAL; // LCOV_EXCL_LINE
if (auto const ret = nft::removeToken(view(), seller, nftokenID, std::move(tokenAndPage->page));
if (auto const ret = nft::removeToken(view(), seller, nftokenID, tokenAndPage->page);
!isTesSuccess(ret))
return ret;
@@ -344,7 +344,7 @@ removeToken(ApplyView& view, AccountID const& owner, uint256 const& nftokenID)
if (!page)
return tecNO_ENTRY;
return removeToken(view, owner, nftokenID, std::move(page));
return removeToken(view, owner, nftokenID, page);
}
/** Remove the token from the owner's token directory. */
@@ -236,7 +236,7 @@ OracleSet::doApply()
}
STArray updatedSeries;
for (auto const& iter : pairs)
updatedSeries.push_back(std::move(iter.second));
updatedSeries.push_back(iter.second);
sle->setFieldArray(sfPriceDataSeries, updatedSeries);
if (ctx_.tx.isFieldPresent(sfURI))
sle->setFieldVL(sfURI, ctx_.tx[sfURI]);
@@ -284,7 +284,7 @@ OracleSet::doApply()
pairs.emplace(key, std::move(priceData));
}
for (auto const& iter : pairs)
series.push_back(std::move(iter.second));
series.push_back(iter.second);
}
sle->setFieldArray(sfPriceDataSeries, series);
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/CredentialHelpers.h>
@@ -435,7 +434,7 @@ Payment::doApply()
account_,
ctx_.tx.getFieldPathSet(sfPaths),
ctx_.tx[~sfDomainID],
ctx_.registry.logs(),
ctx_.registry,
&rcInput);
// VFALCO NOTE We might not need to apply, depending
// on the TER. But always applying *should*
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/CredentialHelpers.h>
@@ -109,7 +108,7 @@ PaymentChannelClaim::doApply()
auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count();
if ((cancelAfter && closeTime >= *cancelAfter) ||
(curExpiration && closeTime >= *curExpiration))
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
}
if (txAccount != src && txAccount != dst)
@@ -170,7 +169,7 @@ PaymentChannelClaim::doApply()
{
// Channel will close immediately if dry or the receiver closes
if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount])
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
auto const settleExpiration =
ctx_.view().header().parentCloseTime.time_since_epoch().count() +
@@ -38,7 +38,7 @@ PaymentChannelFund::doApply()
auto const cancelAfter = (*slep)[~sfCancelAfter];
auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count();
if ((cancelAfter && closeTime >= *cancelAfter) || (expiration && closeTime >= *expiration))
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
}
if (src != txAccount)
+4 -4
View File
@@ -200,7 +200,7 @@ Change::applyAmendment()
entry[sfAmendment] = amendment;
entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count();
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
if (!ctx_.registry.get().getAmendmentTable().isSupported(amendment))
{
JLOG(j_.warn()) << "Unsupported amendment " << amendment << " received a majority.";
}
@@ -211,13 +211,13 @@ Change::applyAmendment()
amendments.push_back(amendment);
amendmentObject->setFieldV256(sfAmendments, amendments);
ctx_.registry.getAmendmentTable().enable(amendment);
ctx_.registry.get().getAmendmentTable().enable(amendment);
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
if (!ctx_.registry.get().getAmendmentTable().isSupported(amendment))
{
JLOG(j_.error()) << "Unsupported amendment " << amendment
<< " activated: server blocked.";
ctx_.registry.getOPs().setAmendmentBlocked();
ctx_.registry.get().getOPs().setAmendmentBlocked();
}
}
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
@@ -71,7 +70,7 @@ TicketCreate::doApply()
return tecINSUFFICIENT_RESERVE;
}
beast::Journal viewJ{ctx_.registry.journal("View")};
beast::Journal viewJ{ctx_.registry.get().getJournal("View")};
// The starting ticket sequence is the same as the current account
// root sequence. Before we got here to doApply(), the transaction
@@ -1,4 +1,3 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
@@ -367,7 +366,7 @@ TrustSet::doApply()
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze) != 0u;
bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze) != 0u;
auto viewJ = ctx_.registry.journal("View");
auto viewJ = ctx_.registry.get().getJournal("View");
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
+2 -2
View File
@@ -1926,7 +1926,7 @@ private:
BEAST_EXPECT(isOffer(env, carol, BTC(1'000), EUR(1)));
BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50)));
auto flowJournal = env.app().logs().journal("Flow");
auto flowJournal = env.app().getJournal("Flow");
auto const flowResult = [&] {
STAmount deliver(USD(51));
STAmount smax(BTC(61));
@@ -1965,7 +1965,7 @@ private:
}();
BEAST_EXPECT(flowResult.removableOffers.size() == 1);
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
if (flowResult.removableOffers.empty())
return false;
Sandbox sb(&view, tapNONE);
+2 -2
View File
@@ -403,7 +403,7 @@ public:
// Note that we're bypassing almost all of the ledger's safety
// checks with this modify() call. If you call close() between
// here and the end of the test all the effort will be lost.
env.app().openLedger().modify([&gw, transferRate](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&gw, transferRate](OpenView& view, beast::Journal j) {
// Get the account root we want to hijack.
auto const sle = view.read(keylet::account(gw.id()));
if (!sle)
@@ -552,7 +552,7 @@ public:
auto stx = std::make_shared<STTx>(*jtx.stx);
stx->at(sfSigningPubKey) = makeSlice(std::string("badkey"));
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, *stx, tapNONE, j);
BEAST_EXPECT(result.ter == temBAD_SIGNATURE);
BEAST_EXPECT(!result.applied);
+4 -3
View File
@@ -93,6 +93,7 @@ class Batch_test : public beast::unit_test::suite
auto const ids = batchTxn.stx->getBatchTransactionIDs();
std::vector<std::string> txIDs;
txIDs.reserve(ids.size());
for (auto const& id : ids)
txIDs.push_back(strHex(id));
TxID const batchID = batchTxn.stx->getTransactionID();
@@ -1379,7 +1380,7 @@ class Batch_test : public beast::unit_test::suite
batch::inner(pay(alice, bob, XRP(1)), aliceSeq),
batch::inner(pay(alice, bob, XRP(1)), aliceSeq));
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, j);
BEAST_EXPECT(!result.applied && result.ter == temARRAY_TOO_LARGE);
return result.applied;
@@ -1422,7 +1423,7 @@ class Batch_test : public beast::unit_test::suite
batch::inner(pay(alice, bob, XRP(5)), aliceSeq + 2),
batch::sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob));
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, j);
BEAST_EXPECT(!result.applied && result.ter == temARRAY_TOO_LARGE);
return result.applied;
@@ -3627,7 +3628,7 @@ class Batch_test : public beast::unit_test::suite
BEAST_EXPECT(isPseudoTx(stx));
BEAST_EXPECT(!passesLocalChecks(stx, reason));
BEAST_EXPECT(reason == "Cannot submit pseudo transactions.");
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, stx, tapNONE, j);
BEAST_EXPECT(!result.applied && result.ter == temINVALID_FLAG);
return result.applied;
+2 -2
View File
@@ -2518,7 +2518,7 @@ struct EscrowToken_test : public beast::unit_test::suite
env.close();
auto const seq1 = env.seq(alice);
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
Sandbox sb(&view, tapNONE);
auto sleNew = std::make_shared<SLE>(keylet::escrow(alice, seq1));
MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}};
@@ -2745,7 +2745,7 @@ struct EscrowToken_test : public beast::unit_test::suite
env.fund(XRP(10'000), alice, bob);
auto const seq1 = env.seq(alice);
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
Sandbox sb(&view, tapNONE);
auto sleNew = std::make_shared<SLE>(keylet::escrow(alice, seq1));
MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}};
+18 -18
View File
@@ -256,7 +256,7 @@ class FeeVote_test : public beast::unit_test::suite
env.app().getNodeFamily());
// Create the next ledger to apply transaction to
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Test successful fee transaction with legacy fields
@@ -286,7 +286,7 @@ class FeeVote_test : public beast::unit_test::suite
env.app().getNodeFamily());
// Create the next ledger to apply transaction to
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
FeeSettingsFields fields{
.baseFeeDrops = XRPAmount{10},
@@ -319,7 +319,7 @@ class FeeVote_test : public beast::unit_test::suite
env.app().getNodeFamily());
// Create the next ledger to apply transaction to
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Test transaction with missing required legacy fields
auto invalidTx = createInvalidFeeTx(ledger->rules(), ledger->seq(), true, false, 1);
@@ -341,7 +341,7 @@ class FeeVote_test : public beast::unit_test::suite
env.app().getNodeFamily());
// Create the next ledger to apply transaction to
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Test transaction with missing required new fields
auto invalidTx = createInvalidFeeTx(ledger->rules(), ledger->seq(), true, false, 3);
@@ -368,7 +368,7 @@ class FeeVote_test : public beast::unit_test::suite
env.app().getNodeFamily());
// Create the next ledger to apply transaction to
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
auto feeTx = createFeeTx(
ledger->rules(),
@@ -406,7 +406,7 @@ class FeeVote_test : public beast::unit_test::suite
std::vector<uint256>{},
env.app().getNodeFamily());
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
FeeSettingsFields fields1{
.baseFeeDrops = XRPAmount{10},
@@ -423,7 +423,7 @@ class FeeVote_test : public beast::unit_test::suite
BEAST_EXPECT(verifyFeeObject(ledger, ledger->rules(), fields1));
// Apply second fee transaction with different values
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
FeeSettingsFields fields2{
.baseFeeDrops = XRPAmount{20},
@@ -454,7 +454,7 @@ class FeeVote_test : public beast::unit_test::suite
std::vector<uint256>{},
env.app().getNodeFamily());
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Test transaction with wrong ledger sequence
auto feeTx = createFeeTx(
@@ -485,7 +485,7 @@ class FeeVote_test : public beast::unit_test::suite
std::vector<uint256>{},
env.app().getNodeFamily());
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
FeeSettingsFields fields1{
.baseFeeDrops = XRPAmount{10},
@@ -501,7 +501,7 @@ class FeeVote_test : public beast::unit_test::suite
BEAST_EXPECT(verifyFeeObject(ledger, ledger->rules(), fields1));
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Apply partial update (only some fields)
FeeSettingsFields fields2{
@@ -531,7 +531,7 @@ class FeeVote_test : public beast::unit_test::suite
std::vector<uint256>{},
env.app().getNodeFamily());
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
// Test invalid transaction with non-zero account - this should fail
// validation
@@ -563,7 +563,7 @@ class FeeVote_test : public beast::unit_test::suite
// Test with XRPFees enabled
{
Env env(*this, testable_amendments() | featureXRPFees);
auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote"));
auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote"));
auto ledger = std::make_shared<Ledger>(
create_genesis,
@@ -576,7 +576,7 @@ class FeeVote_test : public beast::unit_test::suite
auto pub = derivePublicKey(KeyType::secp256k1, sec);
auto val = std::make_shared<STValidation>(
env.app().timeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) {
env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) {
v.setFieldU32(sfLedgerSequence, 12345);
});
@@ -593,7 +593,7 @@ class FeeVote_test : public beast::unit_test::suite
// Test with XRPFees disabled (legacy format)
{
Env env(*this, testable_amendments() - featureXRPFees);
auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote"));
auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote"));
auto ledger = std::make_shared<Ledger>(
create_genesis,
@@ -606,7 +606,7 @@ class FeeVote_test : public beast::unit_test::suite
auto pub = derivePublicKey(KeyType::secp256k1, sec);
auto val = std::make_shared<STValidation>(
env.app().timeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) {
env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) {
v.setFieldU32(sfLedgerSequence, 12345);
});
@@ -639,7 +639,7 @@ class FeeVote_test : public beast::unit_test::suite
BEAST_EXPECT(env.current()->fees().reserve == XRPAmount{200'000'000});
BEAST_EXPECT(env.current()->fees().increment == XRPAmount{50'000'000});
auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote"));
auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote"));
auto ledger = std::make_shared<Ledger>(
create_genesis,
Rules{env.app().config().features},
@@ -651,7 +651,7 @@ class FeeVote_test : public beast::unit_test::suite
// We need to create a ledger at sequence 256 to make it a flag ledger
for (int i = 0; i < 256 - 1; ++i)
{
ledger = std::make_shared<Ledger>(*ledger, env.app().timeKeeper().closeTime());
ledger = std::make_shared<Ledger>(*ledger, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(ledger->isFlagLedger());
@@ -664,7 +664,7 @@ class FeeVote_test : public beast::unit_test::suite
auto pub = derivePublicKey(KeyType::secp256k1, sec);
auto val = std::make_shared<STValidation>(
env.app().timeKeeper().now(), pub, sec, calcNodeID(pub), [&](STValidation& v) {
env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [&](STValidation& v) {
v.setFieldU32(sfLedgerSequence, ledger->seq());
// Vote for different fees than current
v.setFieldAmount(sfBaseFeeDrops, XRPAmount{setup.reference_fee});
+2 -2
View File
@@ -435,7 +435,7 @@ struct Flow_test : public beast::unit_test::suite
BEAST_EXPECT(isOffer(env, bob, BTC(60), EUR(50)));
BEAST_EXPECT(isOffer(env, carol, BTC(1000), EUR(1)));
auto flowJournal = env.app().logs().journal("Flow");
auto flowJournal = env.app().getJournal("Flow");
auto const flowResult = [&] {
STAmount deliver(USD(51));
STAmount smax(BTC(61));
@@ -474,7 +474,7 @@ struct Flow_test : public beast::unit_test::suite
}();
BEAST_EXPECT(flowResult.removableOffers.size() == 1);
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
if (flowResult.removableOffers.empty())
return false;
Sandbox sb(&view, tapNONE);
+2 -2
View File
@@ -1193,7 +1193,7 @@ class Invariants_test : public beast::unit_test::suite
STArray nfTokens = makeNFTokenIDs(1);
auto nftPage = std::make_shared<SLE>(keylet::nftpage(
keylet::nftpage_max(A1), ++(nfTokens[0].getFieldH256(sfNFTokenID))));
nftPage->setFieldArray(sfNFTokens, std::move(nfTokens));
nftPage->setFieldArray(sfNFTokens, nfTokens);
nftPage->setFieldH256(sfNextPageMin, keylet::nftpage_max(A2).key);
ac.view().insert(nftPage);
@@ -1206,7 +1206,7 @@ class Invariants_test : public beast::unit_test::suite
STArray nfTokens = makeNFTokenIDs(2);
auto nftPage = std::make_shared<SLE>(keylet::nftpage(
keylet::nftpage_max(A1), (nfTokens[1].getFieldH256(sfNFTokenID))));
nftPage->setFieldArray(sfNFTokens, std::move(nfTokens));
nftPage->setFieldArray(sfNFTokens, nfTokens);
ac.view().insert(nftPage);
return true;
+10 -10
View File
@@ -109,7 +109,7 @@ class LedgerLoad_test : public beast::unit_test::suite
// create a new env with the ledger file specified for startup
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LOAD_FILE, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LoadFile, std::nullopt),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
@@ -129,7 +129,7 @@ class LedgerLoad_test : public beast::unit_test::suite
except([&] {
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LOAD_FILE, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LoadFile, std::nullopt),
nullptr,
beast::severities::kDisabled);
});
@@ -139,7 +139,7 @@ class LedgerLoad_test : public beast::unit_test::suite
Env env(
*this,
envconfig(
ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LOAD_FILE, std::nullopt),
ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LoadFile, std::nullopt),
nullptr,
beast::severities::kDisabled);
});
@@ -164,7 +164,7 @@ class LedgerLoad_test : public beast::unit_test::suite
ledgerConfig,
sd.dbPath,
ledgerFileCorrupt.string(),
StartUpType::LOAD_FILE,
StartUpType::LoadFile,
std::nullopt),
nullptr,
beast::severities::kDisabled);
@@ -182,7 +182,7 @@ class LedgerLoad_test : public beast::unit_test::suite
boost::erase_all(ledgerHash, "\"");
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::LOAD, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Load, std::nullopt),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
@@ -203,7 +203,7 @@ class LedgerLoad_test : public beast::unit_test::suite
boost::erase_all(ledgerHash, "\"");
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, std::nullopt),
nullptr,
beast::severities::kDisabled);
auto const jrb = env.rpc("ledger", "current", "full")[jss::result];
@@ -229,7 +229,7 @@ class LedgerLoad_test : public beast::unit_test::suite
boost::erase_all(ledgerHash, "\"");
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, sd.trapTxHash),
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, sd.trapTxHash),
nullptr,
beast::severities::kDisabled);
auto const jrb = env.rpc("ledger", "current", "full")[jss::result];
@@ -259,7 +259,7 @@ class LedgerLoad_test : public beast::unit_test::suite
// replay when trapTxHash is set to an invalid transaction
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, ~sd.trapTxHash),
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, ~sd.trapTxHash),
nullptr,
beast::severities::kDisabled);
BEAST_EXPECT(false);
@@ -283,7 +283,7 @@ class LedgerLoad_test : public beast::unit_test::suite
// create a new env with the ledger "latest" specified for startup
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::LOAD, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::Load, std::nullopt),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
@@ -301,7 +301,7 @@ class LedgerLoad_test : public beast::unit_test::suite
// create a new env with specific ledger index at startup
Env env(
*this,
envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::LOAD, std::nullopt),
envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::Load, std::nullopt),
nullptr,
beast::severities::kDisabled);
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
+4 -3
View File
@@ -464,7 +464,7 @@ struct LedgerServer
assert(param.initLedgers > 0);
createAccounts(param.initAccounts);
createLedgerHistory();
app.logs().threshold(beast::severities::kWarning);
app.getLogs().threshold(beast::severities::kWarning);
}
/**
@@ -803,8 +803,8 @@ logAll(
LedgerReplayClient& client,
beast::severities::Severity level = Severity::kTrace)
{
server.app.logs().threshold(level);
client.app.logs().threshold(level);
server.app.getLogs().threshold(level);
client.app.getLogs().threshold(level);
}
// logAll(net.server, net.client);
@@ -968,6 +968,7 @@ struct LedgerReplayer_test : public beast::unit_test::suite
auto makeSkipList = [](int count) -> std::vector<uint256> {
std::vector<uint256> sList;
sList.reserve(count);
for (int i = 0; i < count; ++i)
sList.emplace_back(i);
return sList;
+6 -4
View File
@@ -1539,7 +1539,7 @@ protected:
auto const pseudoAcct = [&]() {
auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID));
if (!BEAST_EXPECT(brokerSle))
return lender;
return Account{lender};
auto const brokerPseudo = brokerSle->at(sfAccount);
return Account("Broker pseudo-account", brokerPseudo);
}();
@@ -1809,9 +1809,9 @@ protected:
if (!BEAST_EXPECT(vaultSle))
{
// This will be wrong, but the test has failed anyway.
return lender;
return Account{lender};
}
auto const vaultPseudo = Account("Vault pseudo-account", vaultSle->at(sfAccount));
auto vaultPseudo = Account("Vault pseudo-account", vaultSle->at(sfAccount));
return vaultPseudo;
}();
@@ -2875,6 +2875,7 @@ protected:
// Create vaults and loan brokers
std::array const assets{mptAsset, iouAsset};
std::vector<BrokerInfo> brokers;
brokers.reserve(assets.size());
for (auto const& asset : assets)
{
brokers.emplace_back(createVaultAndBroker(env, asset, lender));
@@ -3408,6 +3409,7 @@ protected:
// Create vaults and loan brokers
std::vector<BrokerInfo> brokers;
brokers.reserve(assets.size());
for (auto const& asset : assets)
{
brokers.emplace_back(createVaultAndBroker(
@@ -4566,7 +4568,7 @@ protected:
auto const pseudoAcct = [&]() {
auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID));
if (!BEAST_EXPECT(brokerSle))
return lender;
return Account{lender};
auto const brokerPseudo = brokerSle->at(sfAccount);
return Account("Broker pseudo-account", brokerPseudo);
}();
+5 -6
View File
@@ -147,9 +147,8 @@ public:
Serializer s;
st.add(s);
// m is non-const so it can be moved from
std::string m(static_cast<char const*>(s.data()), s.size());
if (auto r = deserializeManifest(std::move(m)))
std::string const m(static_cast<char const*>(s.data()), s.size());
if (auto r = deserializeManifest(m))
return std::move(*r);
Throw<std::runtime_error>("Could not create a revocation manifest");
return *deserializeManifest(std::string{}); // Silence compiler warning.
@@ -182,9 +181,8 @@ public:
Serializer s;
st.add(s);
std::string m(static_cast<char const*>(s.data()),
s.size()); // non-const so can be moved
if (auto r = deserializeManifest(std::move(m)))
std::string const m(static_cast<char const*>(s.data()), s.size());
if (auto r = deserializeManifest(m))
return std::move(*r);
Throw<std::runtime_error>("Could not create a manifest");
return *deserializeManifest(std::string{}); // Silence compiler warning.
@@ -252,6 +250,7 @@ public:
// save should store all trusted master keys to db
std::vector<std::string> s1;
std::vector<std::string> keys;
s1.reserve(inManifests.size());
for (auto const& man : inManifests)
s1.push_back(toBase58(TokenType::NodePublic, man->masterKey));
unl->load({}, s1, keys);
+4 -4
View File
@@ -110,7 +110,7 @@ public:
view.rawInsert(sleA1);
return true;
};
env.app().openLedger().modify(unauthTrustline);
env.app().getOpenLedger().modify(unauthTrustline);
if (features[fixEnforceNFTokenTrustlineV2])
{
@@ -173,7 +173,7 @@ public:
view.rawInsert(sleA1);
return true;
};
env.app().openLedger().modify(unauthTrustline);
env.app().getOpenLedger().modify(unauthTrustline);
if (features[fixEnforceNFTokenTrustlineV2])
{
// test: check that offer can't be accepted even with balance
@@ -293,7 +293,7 @@ public:
view.rawInsert(sleA1);
return true;
};
env.app().openLedger().modify(unauthTrustline);
env.app().getOpenLedger().modify(unauthTrustline);
if (features[fixEnforceNFTokenTrustlineV2])
{
env(token::acceptSellOffer(A1, sellIdx), ter(tecNO_AUTH));
@@ -412,7 +412,7 @@ public:
view.rawInsert(sleA1);
return true;
};
env.app().openLedger().modify(unauthTrustline);
env.app().getOpenLedger().modify(unauthTrustline);
if (features[fixEnforceNFTokenTrustlineV2])
{
+1 -1
View File
@@ -399,7 +399,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite
// Note that we're bypassing almost all of the ledger's safety
// checks with this modify() call. If you call close() between
// here and the end of the test all the effort will be lost.
env.app().openLedger().modify([&alice](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&alice](OpenView& view, beast::Journal j) {
// Get the account root we want to hijack.
auto const sle = view.read(keylet::account(alice.id()));
if (!sle)
+3 -3
View File
@@ -863,7 +863,7 @@ public:
auto const aliceOffers = offersOnAccount(env, alice);
BEAST_EXPECT(aliceOffers.size() == 1);
for (auto offerPtr : aliceOffers)
for (auto const& offerPtr : aliceOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == XRP(2000));
@@ -878,7 +878,7 @@ public:
auto const bobOffers = offersOnAccount(env, bob);
BEAST_EXPECT(bobOffers.size() == 1);
for (auto offerPtr : bobOffers)
for (auto const& offerPtr : bobOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == USD(1000));
@@ -927,7 +927,7 @@ public:
auto const bobOffers = offersOnAccount(env, "bob");
BEAST_EXPECT(bobOffers.size() == 1);
for (auto offerPtr : bobOffers)
for (auto const& offerPtr : bobOffers)
{
auto const& offer = *offerPtr;
BEAST_EXPECT(offer[sfTakerGets] == USD(499.5));
+10 -10
View File
@@ -623,7 +623,7 @@ struct PayStrand_test : public beast::unit_test::suite
OfferCrossing::no,
ammContext,
std::nullopt,
env.app().logs().journal("Flow"));
env.app().getJournal("Flow"));
BEAST_EXPECT(ter == expTer);
if (sizeof...(expSteps) != 0)
BEAST_EXPECT(equal(strand, std::forward<decltype(expSteps)>(expSteps)...));
@@ -650,7 +650,7 @@ struct PayStrand_test : public beast::unit_test::suite
OfferCrossing::no,
ammContext,
std::nullopt,
env.app().logs().journal("Flow"));
env.app().getJournal("Flow"));
(void)_;
BEAST_EXPECT(isTesSuccess(ter));
}
@@ -668,7 +668,7 @@ struct PayStrand_test : public beast::unit_test::suite
OfferCrossing::no,
ammContext,
std::nullopt,
env.app().logs().journal("Flow"));
env.app().getJournal("Flow"));
(void)_;
BEAST_EXPECT(isTesSuccess(ter));
}
@@ -765,7 +765,7 @@ struct PayStrand_test : public beast::unit_test::suite
{
// The root account can't be the src or dst
auto flowJournal = env.app().logs().journal("Flow");
auto flowJournal = env.app().getJournal("Flow");
{
// The root account can't be the dst
auto r = toStrand(
@@ -936,7 +936,7 @@ struct PayStrand_test : public beast::unit_test::suite
OfferCrossing::no,
ammContext,
std::nullopt,
env.app().logs().journal("Flow"));
env.app().getJournal("Flow"));
BEAST_EXPECT(isTesSuccess(ter));
BEAST_EXPECT(equal(strand, D{alice, gw, usdC}));
}
@@ -964,7 +964,7 @@ struct PayStrand_test : public beast::unit_test::suite
OfferCrossing::no,
ammContext,
std::nullopt,
env.app().logs().journal("Flow"));
env.app().getJournal("Flow"));
BEAST_EXPECT(isTesSuccess(ter));
BEAST_EXPECT(equal(
strand, D{alice, gw, usdC}, B{USD.issue(), xrpIssue(), std::nullopt}, XRPS{bob}));
@@ -1145,7 +1145,7 @@ struct PayStrand_test : public beast::unit_test::suite
noAccount(),
pathSet,
std::nullopt,
env.app().logs(),
env.app(),
&inputs);
BEAST_EXPECT(r.result() == temBAD_PATH);
}
@@ -1158,7 +1158,7 @@ struct PayStrand_test : public beast::unit_test::suite
srcAcc,
pathSet,
std::nullopt,
env.app().logs(),
env.app(),
&inputs);
BEAST_EXPECT(r.result() == temBAD_PATH);
}
@@ -1171,7 +1171,7 @@ struct PayStrand_test : public beast::unit_test::suite
srcAcc,
pathSet,
std::nullopt,
env.app().logs(),
env.app(),
&inputs);
BEAST_EXPECT(r.result() == temBAD_PATH);
}
@@ -1184,7 +1184,7 @@ struct PayStrand_test : public beast::unit_test::suite
srcAcc,
pathSet,
std::nullopt,
env.app().logs(),
env.app(),
&inputs);
BEAST_EXPECT(r.result() == temBAD_PATH);
}
+1 -1
View File
@@ -70,7 +70,7 @@ struct PseudoTx_test : public beast::unit_test::suite
BEAST_EXPECT(isPseudoTx(stx));
BEAST_EXPECT(!passesLocalChecks(stx, reason));
BEAST_EXPECT(reason == "Cannot submit pseudo transactions.");
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, stx, tapNONE, j);
BEAST_EXPECT(!result.applied && result.ter == temINVALID);
return result.applied;
+4 -4
View File
@@ -65,7 +65,7 @@ class RCLValidations_test : public beast::unit_test::suite
history.push_back(prev);
for (auto i = 0; i < ((2 * maxAncestors) + 1); ++i)
{
auto next = std::make_shared<Ledger>(*prev, env.app().timeKeeper().closeTime());
auto next = std::make_shared<Ledger>(*prev, env.app().getTimeKeeper().closeTime());
next->updateSkipList();
history.push_back(next);
prev = next;
@@ -82,7 +82,7 @@ class RCLValidations_test : public beast::unit_test::suite
bool forceHash = true;
while (altHistory.size() < history.size())
{
auto next = std::make_shared<Ledger>(*prev, env.app().timeKeeper().closeTime());
auto next = std::make_shared<Ledger>(*prev, env.app().getTimeKeeper().closeTime());
// Force a different hash on the first iteration
next->updateSkipList();
BEAST_EXPECT(next->read(keylet::fees()));
@@ -132,7 +132,7 @@ class RCLValidations_test : public beast::unit_test::suite
{
RCLValidatedLedger a{RCLValidatedLedger::MakeGenesis{}};
for (auto ledger : {history.back(), history[maxAncestors - 1]})
for (auto const& ledger : {history.back(), history[maxAncestors - 1]})
{
RCLValidatedLedger b{ledger, env.journal};
BEAST_EXPECT(mismatch(a, b) == 1);
@@ -231,7 +231,7 @@ class RCLValidations_test : public beast::unit_test::suite
history.push_back(prev);
for (auto i = 0; i < (maxAncestors + 10); ++i)
{
auto next = std::make_shared<Ledger>(*prev, env.app().timeKeeper().closeTime());
auto next = std::make_shared<Ledger>(*prev, env.app().getTimeKeeper().closeTime());
next->updateSkipList();
history.push_back(next);
prev = next;
+2 -2
View File
@@ -56,7 +56,7 @@ struct Regression_test : public beast::unit_test::suite
auto const aliceXRP = 400;
auto const aliceAmount = XRP(aliceXRP);
auto next = std::make_shared<Ledger>(*closed, env.app().timeKeeper().closeTime());
auto next = std::make_shared<Ledger>(*closed, env.app().getTimeKeeper().closeTime());
{
// Fund alice
auto const jt = env.jt(pay(env.master, "alice", aliceAmount));
@@ -273,7 +273,7 @@ struct Regression_test : public beast::unit_test::suite
if (BEAST_EXPECT(bob_index.isNonZero()) && BEAST_EXPECT(digest.has_value()))
{
auto& cache = env.app().cachedSLEs();
auto& cache = env.app().getCachedSLEs();
cache.del(*digest, false); // NOLINT(bugprone-unchecked-optional-access)
auto const beforeCounts = mapCounts(CountedObjects::getInstance().getCounts(0));
+2 -2
View File
@@ -481,7 +481,7 @@ public:
section,
megabytes(env.app().config().getValueFor(SizedItem::burstSize, std::nullopt)),
scheduler,
env.app().logs().journal("NodeStoreTest"))};
env.app().getJournal("NodeStoreTest"))};
backend->open();
return backend;
}
@@ -514,7 +514,7 @@ public:
std::move(writableBackend),
std::move(archiveBackend),
nscfg,
env.app().logs().journal("NodeStoreTest"));
env.app().getJournal("NodeStoreTest"));
/////////////////////////////////////////////////////////////
// Check basic functionality
+6 -4
View File
@@ -95,14 +95,16 @@ struct Transaction_ordering_test : public beast::unit_test::suite
env.fund(XRP(1000), noripple(alice));
auto const aliceSequence = env.seq(alice);
static constexpr auto kSIZE = 5;
std::vector<JTx> tx;
for (auto i = 0; i < 5; ++i)
tx.reserve(kSIZE);
for (auto i = 0; i < kSIZE; ++i)
{
tx.emplace_back(env.jt(noop(alice), seq(aliceSequence + i), last_ledger_seq(7)));
}
for (auto i = 1; i < 5; ++i)
for (auto i = 1; i < kSIZE; ++i)
{
env(tx[i], ter(terPRE_SEQ));
BEAST_EXPECT(env.seq(alice) == aliceSequence);
@@ -110,11 +112,11 @@ struct Transaction_ordering_test : public beast::unit_test::suite
env(tx[0]);
env.app().getJobQueue().rendezvous();
BEAST_EXPECT(env.seq(alice) == aliceSequence + 5);
BEAST_EXPECT(env.seq(alice) == aliceSequence + kSIZE);
env.close();
for (auto i = 0; i < 5; ++i)
for (auto i = 0; i < kSIZE; ++i)
{
auto const result = env.rpc("tx", to_string(tx[i].stx->getTransactionID()));
BEAST_EXPECT(result["result"]["meta"]["TransactionResult"] == "tesSUCCESS");
+3 -3
View File
@@ -950,7 +950,7 @@ public:
Env::ParsedResult parsed;
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, env.journal);
parsed.ter = result.ter;
return result.applied;
@@ -3873,7 +3873,7 @@ public:
// (This requires calling directly into the open ledger,
// which won't work if unit tests are separated to only
// be callable via RPC.)
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const tx = env.jt(noop(alice), seq(aliceSeq), fee(openLedgerCost(env)));
auto const result = xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j);
BEAST_EXPECT(isTesSuccess(result.ter) && result.applied);
@@ -3941,7 +3941,7 @@ public:
// (This requires calling directly into the open ledger,
// which won't work if unit tests are separated to only
// be callable via RPC.)
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
auto const tx = env.jt(noop(alice), ticket::use(tktSeq0 + 1), fee(openLedgerCost(env)));
auto const result = xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j);
BEAST_EXPECT(isTesSuccess(result.ter) && result.applied);
+1 -1
View File
@@ -59,7 +59,7 @@ public:
// 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::severities::kDisabled};
beast::Journal journal{env.app().journal("ValidatorKeys_test")};
beast::Journal journal{env.app().getJournal("ValidatorKeys_test")};
// Keys/ID when using [validation_seed]
SecretKey const seedSecretKey =
+73 -71
View File
@@ -373,6 +373,7 @@ private:
// load should accept valid validator list publisher keys
std::vector<std::string> cfgPublishers;
cfgPublishers.reserve(keys.size());
for (auto const& key : keys)
cfgPublishers.push_back(strHex(key));
@@ -393,6 +394,7 @@ private:
std::vector<PublicKey> keys(
{randomMasterKey(), randomMasterKey(), randomMasterKey(), randomMasterKey()});
std::vector<std::string> cfgPublishers;
cfgPublishers.reserve(keys.size());
for (auto const& key : keys)
cfgPublishers.push_back(strHex(key));
@@ -534,7 +536,7 @@ private:
auto trustedKeys = std::make_unique<ValidatorList>(
manifests,
manifests,
env.app().timeKeeper(),
env.app().getTimeKeeper(),
app.config().legacy("database_path"),
env.journal);
@@ -813,7 +815,7 @@ private:
{},
effective6 + 1s,
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
expectUntrusted(lists.at(3));
@@ -831,7 +833,7 @@ private:
{},
effective8 + 1s,
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
expectUntrusted(lists.at(6));
@@ -896,7 +898,7 @@ private:
auto trustedKeys = std::make_unique<ValidatorList>(
manifests,
manifests,
env.app().timeKeeper(),
env.app().getTimeKeeper(),
app.config().legacy("database_path"),
env.journal);
@@ -1062,7 +1064,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
for (auto const& val : unseenValidators)
@@ -1088,7 +1090,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.added.empty());
BEAST_EXPECT(changes.removed.empty());
@@ -1112,7 +1114,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.added == asNodeIDs({masterPublic}));
BEAST_EXPECT(changes.removed.empty());
@@ -1173,7 +1175,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed == asNodeIDs({masterPublic}));
BEAST_EXPECT(changes.added.empty());
@@ -1208,7 +1210,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added.empty());
@@ -1240,7 +1242,7 @@ private:
activeValidatorsOuter,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added.size() == 1);
@@ -1287,7 +1289,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added == expectedTrusted);
@@ -1299,7 +1301,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added.empty());
@@ -1310,7 +1312,7 @@ private:
auto trustedKeys = std::make_unique<ValidatorList>(
manifestsOuter,
manifestsOuter,
env.app().timeKeeper(),
env.app().getTimeKeeper(),
app.config().legacy("database_path"),
env.journal);
@@ -1349,7 +1351,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added == activeValidators);
@@ -1365,7 +1367,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed == activeValidators);
BEAST_EXPECT(changes.added.empty());
@@ -1390,7 +1392,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(
@@ -1431,7 +1433,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
BEAST_EXPECT(changes.added == asNodeIDs({valKey}));
@@ -1468,7 +1470,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(changes.removed.empty());
if (cfgKeys.size() > 2)
@@ -1560,7 +1562,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(valKeys.size() * 0.8f));
@@ -1675,7 +1677,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil((valKeys.size() - 3) * 0.8f));
@@ -1706,7 +1708,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil((valKeys.size() - 6) * 0.8f));
@@ -1739,7 +1741,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::numeric_limits<std::size_t>::max());
@@ -1809,7 +1811,7 @@ private:
auto trustedKeys = std::make_unique<ValidatorList>(
manifests,
manifests,
env.app().timeKeeper(),
env.app().getTimeKeeper(),
app.config().legacy("database_path"),
env.journal);
@@ -1907,7 +1909,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(
trustedKeys->expires() &&
@@ -1924,7 +1926,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(
trustedKeys->expires() &&
@@ -1969,7 +1971,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
if (minimumQuorum == trustedKeys->quorum() ||
trustedKeys->quorum() == std::ceil(cfgKeys.size() * 0.8f))
@@ -2019,7 +2021,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(
validators->quorum() ==
@@ -2063,7 +2065,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
return validators->quorum() == quorum;
}
@@ -2094,7 +2096,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(validators->quorum() == 39);
}
@@ -2121,7 +2123,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(validators->quorum() == 30);
hash_set<PublicKey> nUnl;
@@ -2136,7 +2138,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(validators->quorum() == 30);
}
@@ -2629,7 +2631,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2650,7 +2652,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -2688,7 +2690,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2708,7 +2710,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
@@ -2753,7 +2755,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2773,7 +2775,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -2822,7 +2824,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2843,7 +2845,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -2889,7 +2891,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2909,7 +2911,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -2956,7 +2958,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -2976,7 +2978,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
@@ -3021,7 +3023,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3042,7 +3044,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3080,7 +3082,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3101,7 +3103,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3139,7 +3141,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3159,7 +3161,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3195,7 +3197,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3215,7 +3217,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3260,7 +3262,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3281,7 +3283,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3327,7 +3329,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3347,7 +3349,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3394,7 +3396,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3414,7 +3416,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
@@ -3453,7 +3455,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3474,7 +3476,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3514,7 +3516,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3535,7 +3537,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3576,7 +3578,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3596,7 +3598,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
@@ -3637,7 +3639,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3658,7 +3660,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3700,7 +3702,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3738,7 +3740,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3784,7 +3786,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3805,7 +3807,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
@@ -3853,7 +3855,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(keysTotal * 0.8f));
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal);
@@ -3873,7 +3875,7 @@ private:
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1);
+2 -1
View File
@@ -139,7 +139,7 @@ private:
p->legacy("database_path", good.subdir().string());
return p;
}());
auto& trustedKeys = env.app().validators();
auto& trustedKeys = env.app().getValidators();
env.timeKeeper().set(env.timeKeeper().now() + 30s);
test::StreamSink sink;
@@ -298,6 +298,7 @@ private:
auto sites = std::make_unique<ValidatorSite>(env.app(), journal);
std::vector<std::string> uris;
uris.reserve(servers.size());
for (auto const& u : servers)
uris.push_back(u.uri);
sites->load(uris);
+18 -17
View File
@@ -1329,7 +1329,7 @@ class Vault_test : public beast::unit_test::suite
return defXRP;
return a + XRP(1000);
}
auto const defIOU = STAmount{a.issue(), 30000};
auto defIOU = STAmount{a.issue(), 30000};
if (a <= defIOU)
return defIOU;
return a + STAmount{a.issue(), 1000};
@@ -3366,23 +3366,24 @@ class Vault_test : public beast::unit_test::suite
env.memoize(vaultAccount);
auto const peek = [keylet, &env, this](std::function<bool(SLE&, SLE&)> fn) -> bool {
return env.app().openLedger().modify([&](OpenView& view, beast::Journal j) -> bool {
Sandbox sb(&view, tapNONE);
auto vault = sb.peek(keylet::vault(keylet.key));
if (!BEAST_EXPECT(vault != nullptr))
return env.app().getOpenLedger().modify(
[&](OpenView& view, beast::Journal j) -> bool {
Sandbox sb(&view, tapNONE);
auto vault = sb.peek(keylet::vault(keylet.key));
if (!BEAST_EXPECT(vault != nullptr))
return false;
auto shares = sb.peek(keylet::mptIssuance(vault->at(sfShareMPTID)));
if (!BEAST_EXPECT(shares != nullptr))
return false;
if (fn(*vault, *shares))
{
sb.update(vault);
sb.update(shares);
sb.apply(view);
return true;
}
return false;
auto shares = sb.peek(keylet::mptIssuance(vault->at(sfShareMPTID)));
if (!BEAST_EXPECT(shares != nullptr))
return false;
if (fn(*vault, *shares))
{
sb.update(vault);
sb.update(shares);
sb.apply(view);
return true;
}
return false;
});
});
};
test(
+3
View File
@@ -592,6 +592,7 @@ public:
}
};
std::vector<std::thread> threads;
threads.reserve(numThreads);
for (int i = 0; i < numThreads; ++i)
{
threads.emplace_back(cloneAndDestroy, i);
@@ -737,6 +738,7 @@ public:
}
};
std::vector<std::thread> threads;
threads.reserve(numThreads);
for (int i = 0; i < numThreads; ++i)
{
threads.emplace_back(cloneAndDestroy, i);
@@ -845,6 +847,7 @@ public:
}
};
std::vector<std::thread> threads;
threads.reserve(numThreads);
for (int i = 0; i < numThreads; ++i)
{
threads.emplace_back(lockAndDestroy, i);
+1 -1
View File
@@ -29,7 +29,7 @@ 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::severities::kDisabled};
beast::Journal j_{env_.app().journal("PerfLog_test")};
beast::Journal j_{env_.app().getJournal("PerfLog_test")};
struct Fixture
{
@@ -1362,7 +1362,7 @@ aged_associative_container_test_base::testArrayCreate()
{
// Copy construct key
typename Traits::template Cont<> c(clock);
for (auto e : v)
for (auto const& e : v)
c[e.first] = e.second;
checkContents(c, v);
}
+1 -1
View File
@@ -149,7 +149,7 @@ class PreimageSha256_test : public beast::unit_test::suite
"9CF1D5F810302"
"0000"}};
for (auto x : others)
for (auto const& x : others)
{
std::error_code ec;
+17 -13
View File
@@ -222,7 +222,7 @@ class NegativeUNL_test : public beast::unit_test::suite
{
//(1) the ledger after genesis, not a flag ledger
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
auto txDisable_0 = createTx(true, l->seq(), publicKeys[0]);
auto txReEnable_1 = createTx(false, l->seq(), publicKeys[1]);
@@ -239,7 +239,7 @@ class NegativeUNL_test : public beast::unit_test::suite
// generate more ledgers
for (auto i = 0; i < 256 - 2; ++i)
{
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -274,7 +274,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size);
if (good_size)
BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -326,7 +326,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(l->validatorToDisable() == publicKeys[1]);
BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
}
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -368,7 +368,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
}
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -417,7 +417,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
}
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -459,7 +459,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->validatorToReEnable() == publicKeys[1]);
}
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -473,7 +473,7 @@ class NegativeUNL_test : public beast::unit_test::suite
for (auto i = 0; i < 256; ++i)
{
BEAST_EXPECT(negUnlSizeTest(l, 0, false, false));
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
}
BEAST_EXPECT(l->isFlagLedger());
l->updateNegativeUNL();
@@ -557,7 +557,7 @@ struct NetworkHistory
int nidx = 0;
while (l->seq() <= param.numLedgers)
{
l = std::make_shared<Ledger>(*l, env.app().timeKeeper().closeTime());
l = std::make_shared<Ledger>(*l, env.app().getTimeKeeper().closeTime());
history.push_back(l);
if (l->isFlagLedger())
@@ -605,7 +605,11 @@ struct NetworkHistory
{
static auto keyPair = randomKeyPair(KeyType::secp256k1);
return std::make_shared<STValidation>(
env.app().timeKeeper().now(), keyPair.first, keyPair.second, v, [&](STValidation& v) {
env.app().getTimeKeeper().now(),
keyPair.first,
keyPair.second,
v,
[&](STValidation& v) {
v.setFieldH256(sfLedgerHash, ledger->header().hash);
v.setFieldU32(sfLedgerSequence, ledger->seq());
v.setFlag(vfFullValidation);
@@ -1682,7 +1686,7 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
auto createSTVal = [&](std::pair<PublicKey, SecretKey> const& keys) {
return std::make_shared<STValidation>(
env.app().timeKeeper().now(),
env.app().getTimeKeeper().now(),
keys.first,
keys.second,
calcNodeID(keys.first),
@@ -1713,7 +1717,7 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
}
// setup the ValidatorList
auto& validators = env.app().validators();
auto& validators = env.app().getValidators();
auto& local = *nUnlKeys.begin();
std::vector<std::string> cfgPublishers;
validators.load(local, cfgKeys, cfgPublishers);
@@ -1721,7 +1725,7 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
activeValidators,
env.timeKeeper().now(),
env.app().getOPs(),
env.app().overlay(),
env.app().getOverlay(),
env.app().getHashRouter());
BEAST_EXPECT(validators.getTrustedMasterKeys().size() == numNodes);
validators.setNegativeUNL(nUnlKeys);
+2 -1
View File
@@ -373,7 +373,7 @@ class Validations_test : public beast::unit_test::suite
[&](TestValidations& vals) { vals.getCurrentNodeIDs(); },
[&](TestValidations& vals) { vals.getPreferred(genesisLedger); },
[&](TestValidations& vals) { vals.getNodesAfter(ledgerA, ledgerA.id()); }};
for (Trigger trigger : triggers)
for (Trigger const& trigger : triggers)
{
TestHarness harness(h.oracle);
Node n = harness.makeNode();
@@ -569,6 +569,7 @@ class Validations_test : public beast::unit_test::suite
std::uint32_t baseFee = 0;
std::vector<uint32_t> expectedFees;
expectedFees.reserve(expectedValidations.size());
for (auto const& val : expectedValidations)
{
expectedFees.push_back(val.loadFee().value_or(baseFee));
+1 -1
View File
@@ -17,7 +17,7 @@ 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::severities::kDisabled};
beast::Journal j{env_.app().journal("ClosureCounter_test")};
beast::Journal j{env_.app().getJournal("ClosureCounter_test")};
void
testConstruction()
+2 -2
View File
@@ -189,7 +189,7 @@ public:
beast::severities::Severity thresh = beast::severities::kError)
: test(suite_)
, bundle_(suite_, std::move(config), std::move(logs), thresh)
, journal{bundle_.app->journal("Env")}
, journal{bundle_.app->getJournal("Env")}
{
memoize(Account::master);
Pathfinder::initPathTable();
@@ -328,7 +328,7 @@ public:
std::shared_ptr<OpenView const>
current() const
{
return app().openLedger().current();
return app().getOpenLedger().current();
}
/** Returns the last closed ledger.
+1 -1
View File
@@ -317,7 +317,7 @@ template <typename... IOU>
Json::Value
getAccountLines(Env& env, AccountID const& acctId, IOU... ious)
{
auto const jrr = getAccountLines(env, acctId);
auto jrr = getAccountLines(env, acctId);
Json::Value res;
for (auto const& line : jrr[jss::lines])
{
+1 -1
View File
@@ -775,7 +775,7 @@ AMM::expectAuctionSlot(auto&& cb) const
// to avoid the failure.
auto const slotFee = auctionSlot[~sfDiscountedFee].value_or(0);
auto const slotInterval = ammAuctionTimeSlot(
env_.app().timeKeeper().now().time_since_epoch().count(), auctionSlot);
env_.app().getTimeKeeper().now().time_since_epoch().count(), auctionSlot);
auto const slotPrice = auctionSlot[sfPrice].iou();
auto const authAccounts = auctionSlot.getFieldArray(sfAuthAccounts);
return cb(slotFee, slotInterval, slotPrice, authAccounts);
+1 -1
View File
@@ -119,7 +119,7 @@ AMMTestBase::testAMM(std::function<void(jtx::AMM&, jtx::Env&)> const& cb, TestAM
return defXRP;
return a + XRP(1000);
}
auto const defIOU = STAmount{a.issue(), 30000};
auto defIOU = STAmount{a.issue(), 30000};
if (a <= defIOU)
return defIOU;
return a + STAmount{a.issue(), 1000};
+3 -3
View File
@@ -61,7 +61,7 @@ Env::AppBundle::AppBundle(
config->SSL_VERIFY_DIR, config->SSL_VERIFY_FILE, config->SSL_VERIFY, debugLog());
owned = make_Application(std::move(config), std::move(logs), std::move(timeKeeper_));
app = owned.get();
app->logs().threshold(thresh);
app->getLogs().threshold(thresh);
if (!app->setup({}))
Throw<std::runtime_error>("Env::AppBundle: setup failed");
timeKeeper->set(app->getLedgerMaster().getClosedLedger()->header().closeTime);
@@ -637,14 +637,14 @@ Env::do_rpc(
std::vector<std::string> const& args,
std::unordered_map<std::string, std::string> const& headers)
{
auto response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
auto response = rpcClient(args, app().config(), app().getLogs(), apiVersion, headers);
for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); ++ctr)
{
JLOG(journal.error()) << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ...";
std::this_thread::sleep_for(std::chrono::milliseconds(500));
response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
response = rpcClient(args, app().config(), app().getLogs(), apiVersion, headers);
}
return response.second;
+1 -1
View File
@@ -15,7 +15,7 @@ bumpLastPage(
std::function<bool(ApplyView&, uint256, std::uint64_t)> adjust) -> Expected<void, Error>
{
Expected<void, Error> res{};
env.app().openLedger().modify([&](OpenView& view, beast::Journal j) -> bool {
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) -> bool {
Sandbox sb(&view, tapNONE);
// Find the root page
+2 -2
View File
@@ -45,7 +45,7 @@ MPTTester::MPTTester(Env& env, Account const& issuer, MPTInit const& arg)
if (arg.fund)
{
env_.fund(arg.xrp, issuer_);
for (auto it : holders_)
for (auto const& it : holders_)
env_.fund(arg.xrpHolders, it.second);
}
if (close_)
@@ -53,7 +53,7 @@ MPTTester::MPTTester(Env& env, Account const& issuer, MPTInit const& arg)
if (arg.fund)
{
env_.require(owners(issuer_, 0));
for (auto it : holders_)
for (auto const& it : holders_)
{
if (issuer_.id() == it.second.id())
Throw<std::runtime_error>("Issuer can't be holder");
+1 -1
View File
@@ -30,7 +30,7 @@ paths::operator()(Env& env, JTx& jt) const
}
Pathfinder pf(
std::make_shared<RippleLineCache>(env.current(), env.app().journal("RippleLineCache")),
std::make_shared<RippleLineCache>(env.current(), env.app().getJournal("RippleLineCache")),
from,
to,
in_.currency,
+1 -1
View File
@@ -291,7 +291,7 @@ private:
env_.require(owners(issuer_, *arg.ownerCount));
if (arg.holderCount)
{
for (auto it : holders_)
for (auto const& it : holders_)
env_.require(owners(it.second, *arg.holderCount));
}
return err;
+1 -1
View File
@@ -22,7 +22,7 @@ struct signer
std::optional<uint256> tag;
signer(Account account_, std::uint32_t weight_ = 1, std::optional<uint256> tag_ = std::nullopt)
: weight(weight_), account(std::move(account_)), tag(std::move(tag_))
: weight(weight_), account(std::move(account_)), tag(tag_)
{
}
};
+1 -1
View File
@@ -204,7 +204,7 @@ struct Directory_test : public beast::unit_test::suite
BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice)));
for (auto c : currencies)
for (auto const& c : currencies)
{
env(trust(charlie, c(50)));
env.close();
+1 -1
View File
@@ -88,7 +88,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
env.fund(XRP(10000), alice, gw1, gw2);
auto j = env.app().journal("View");
auto j = env.app().getJournal("View");
auto const USD_gw1 = gw1["USD"];
auto const USD_gw2 = gw2["USD"];
+1 -1
View File
@@ -25,7 +25,7 @@ class SkipList_test : public beast::unit_test::suite
history.push_back(prev);
for (auto i = 0; i < 1023; ++i)
{
auto next = std::make_shared<Ledger>(*prev, env.app().timeKeeper().closeTime());
auto next = std::make_shared<Ledger>(*prev, env.app().getTimeKeeper().closeTime());
next->updateSkipList();
history.push_back(next);
prev = next;
+13 -10
View File
@@ -121,7 +121,8 @@ class View_test : public beast::unit_test::suite
config.FEES.toFees(),
std::vector<uint256>{},
env.app().getNodeFamily());
auto const ledger = std::make_shared<Ledger>(*genesis, env.app().timeKeeper().closeTime());
auto const ledger =
std::make_shared<Ledger>(*genesis, env.app().getTimeKeeper().closeTime());
wipe(*ledger);
ReadView& v = *ledger;
succ(v, 0, std::nullopt);
@@ -151,7 +152,7 @@ class View_test : public beast::unit_test::suite
using namespace jtx;
Env env(*this);
wipe(env.app().openLedger());
wipe(env.app().getOpenLedger());
auto const open = env.current();
ApplyViewImpl v(&*open, tapNONE);
succ(v, 0, std::nullopt);
@@ -184,7 +185,7 @@ class View_test : public beast::unit_test::suite
using namespace jtx;
Env env(*this);
wipe(env.app().openLedger());
wipe(env.app().getOpenLedger());
auto const open = env.current();
ApplyViewImpl v0(&*open, tapNONE);
v0.insert(sle(1));
@@ -250,7 +251,7 @@ class View_test : public beast::unit_test::suite
using namespace jtx;
Env env(*this);
wipe(env.app().openLedger());
wipe(env.app().getOpenLedger());
auto const open = env.current();
ApplyViewImpl v0(&*open, tapNONE);
v0.rawInsert(sle(1, 1));
@@ -319,7 +320,7 @@ class View_test : public beast::unit_test::suite
using namespace std::chrono;
{
Env env(*this);
wipe(env.app().openLedger());
wipe(env.app().getOpenLedger());
auto const open = env.current();
OpenView v0(open.get());
BEAST_EXPECT(v0.seq() != 98);
@@ -388,7 +389,8 @@ class View_test : public beast::unit_test::suite
config.FEES.toFees(),
std::vector<uint256>{},
env.app().getNodeFamily());
auto const ledger = std::make_shared<Ledger>(*genesis, env.app().timeKeeper().closeTime());
auto const ledger =
std::make_shared<Ledger>(*genesis, env.app().getTimeKeeper().closeTime());
auto setup = [&ledger](std::vector<int> const& vec) {
wipe(*ledger);
@@ -596,7 +598,8 @@ class View_test : public beast::unit_test::suite
config.FEES.toFees(),
std::vector<uint256>{},
env.app().getNodeFamily());
auto const ledger = std::make_shared<Ledger>(*genesis, env.app().timeKeeper().closeTime());
auto const ledger =
std::make_shared<Ledger>(*genesis, env.app().getTimeKeeper().closeTime());
auto setup123 = [&ledger, this]() {
// erase middle element
wipe(*ledger);
@@ -947,7 +950,7 @@ class View_test : public beast::unit_test::suite
std::vector<uint256>{},
env.app().getNodeFamily());
auto const ledger =
std::make_shared<Ledger>(*genesis, env.app().timeKeeper().closeTime());
std::make_shared<Ledger>(*genesis, env.app().getTimeKeeper().closeTime());
wipe(*ledger);
ledger->rawInsert(sle(1));
ReadView& v0 = *ledger;
@@ -963,9 +966,9 @@ class View_test : public beast::unit_test::suite
// Make sure OpenLedger::empty works
{
Env env(*this);
BEAST_EXPECT(env.app().openLedger().empty());
BEAST_EXPECT(env.app().getOpenLedger().empty());
env.fund(XRP(10000), Account("test"));
BEAST_EXPECT(!env.app().openLedger().empty());
BEAST_EXPECT(!env.app().getOpenLedger().empty());
}
}
Loaded 100 of 192 files, more files were not shown because too many files have changed in this diff. Show more