1#include <helpers/TxTest.h>
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/ledger/ApplyView.h>
7#include <xrpl/ledger/CanonicalTXSet.h>
8#include <xrpl/ledger/Ledger.h>
9#include <xrpl/ledger/OpenView.h>
10#include <xrpl/ledger/ReadView.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Feature.h>
13#include <xrpl/protocol/Fees.h>
14#include <xrpl/protocol/Indexes.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STLedgerEntry.h>
17#include <xrpl/protocol/STTx.h>
18#include <xrpl/protocol/TER.h>
19#include <xrpl/protocol_autogen/ledger_entries/AccountRoot.h>
20#include <xrpl/protocol_autogen/ledger_entries/RippleState.h>
21#include <xrpl/protocol_autogen/transactions/AccountSet.h>
22#include <xrpl/protocol_autogen/transactions/Payment.h>
23#include <xrpl/tx/apply.h>
25#include <helpers/Account.h>
26#include <helpers/IOU.h>
48 for ([[maybe_unused]]
auto const& [name, _] : sa)
95 return rules_->enabled(feature);
117 .applied = result.applied,
118 .metadata = std::move(result).metadata,
119 .tx = std::move(stx)};
125 auto const paymentTer =
135 if (accountFlags != 0)
137 auto const accountSetTer =
185 auto const ledgerCloseTime =
now_ + prevLedger.header().closeTimeResolution;
187 now_ = ledgerCloseTime;
197 for (
auto const& [key, tx] : txSet)
205 accum.
apply(*newLedger);
208 newLedger->setAccepted(ledgerCloseTime, newLedger->header().closeTimeResolution,
true);
240 auto balance = trustLine.getBalance();
Holds transactions which were deferred to the next pass of consensus.
void insert(std::shared_ptr< STTx const > txn)
A currency issued by an account.
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
Writable ledger view that accumulates state and tx changes.
SLE::const_pointer read(Keylet const &k) const override
Return the state item associated with a key.
void apply(TxsRawView &to) const
Apply changes.
Rules controlling protocol behavior.
Ledger Entry: AccountRoot.
Ledger Entry: RippleState.
static Account const kMaster
The master account that holds all XRP in genesis.
TxTest(std::optional< FeatureBitset > features=std::nullopt)
Construct a TxTest environment.
void createAccount(Account const &account, XRPAmount xrp, uint32_t accountFlags=0)
Create a new account in the ledger.
std::unordered_set< uint256, beast::Uhash<> > featureSet_
NetClock::time_point getCloseTime() const
Get the current ledger close time.
std::shared_ptr< Ledger const > closedLedger_
OpenView & getOpenLedger()
Get the current open ledger view.
NetClock::time_point now_
Current time (can be advanced arbitrarily for testing).
ReadView const & getClosedLedger() const
Get the closed (base) ledger view.
TestServiceRegistry registry_
bool isEnabled(uint256 const &feature) const
Check if a feature is enabled.
Rules const & getRules() const
Get the current rules.
void close()
Close the current ledger.
void advanceTime(NetClock::duration duration)
Advance time without closing the ledger.
std::vector< std::shared_ptr< STTx const > > pendingTxs_
Transactions submitted to the open ledger, for canonical reordering on close.
std::optional< Rules > rules_
STAmount getBalance(AccountID const &account, IOU const &iou) const
Get the balance of an IOU for an account.
std::shared_ptr< OpenView > openLedger_
ledger_entries::AccountRoot getAccountRoot(AccountID const &id) const
Get the account root object from the current open ledger.
TxResult submit(T &&builder, Account const &signer)
Submit a transaction from a builder.
Immutable cryptographic account descriptor.
Converts to IOU Issue or STAmount.
Builder for AccountSet transactions.
AccountSetBuilder & setSetFlag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSetFlag (SoeOptional).
Builder for Payment transactions.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
FeatureBitset allFeatures()
Returns all testable amendments.
constexpr XRPAmount
Convert XRP to drops (integral types).
ApplyResult apply(ServiceRegistry ®istry, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
CreateGenesisT const kCreateGenesis
void foreachFeature(FeatureBitset bs, F &&f)
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
std::map< std::string, AmendmentSupport > const & allAmendments()
All amendments libxrpl knows about.
constexpr struct xrpl::OpenLedgerT kOpenLedger
std::optional< uint256 > getRegisteredFeature(std::string const &name)
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
T const_pointer_cast(T... args)
Reflects the fee settings for a particular ledger.
Result of a transaction submission in TxTest.
TER ter
The transaction engine result code.