3#include <xrpl/basics/Number.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/chrono.h>
6#include <xrpl/beast/hash/uhash.h>
7#include <xrpl/core/ServiceRegistry.h>
8#include <xrpl/ledger/Ledger.h>
9#include <xrpl/ledger/OpenView.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/Feature.h>
12#include <xrpl/protocol/LedgerFormats.h>
13#include <xrpl/protocol/Rules.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/STAmount.h>
16#include <xrpl/protocol/STTx.h>
17#include <xrpl/protocol/TER.h>
18#include <xrpl/protocol/TxFlags.h>
19#include <xrpl/protocol/TxMeta.h>
20#include <xrpl/protocol/XRPAmount.h>
21#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
22#include <xrpl/protocol_autogen/ledger_entries/AccountRoot.h>
23#include <xrpl/tx/applySteps.h>
25#include <helpers/Account.h>
26#include <helpers/IOU.h>
27#include <helpers/TestServiceRegistry.h>
50template <std::
integral T>
62template <std::
floating_po
int T>
103 return lsfRequireDestTag;
105 return lsfRequireAuth;
107 return lsfDisallowXRP;
108 case asfDisableMaster:
109 return lsfDisableMaster;
112 case asfGlobalFreeze:
113 return lsfGlobalFreeze;
114 case asfDefaultRipple:
115 return lsfDefaultRipple;
117 return lsfDepositAuth;
118 case asfAllowTrustLineClawback:
119 return lsfAllowTrustLineClawback;
120 case asfDisallowIncomingCheck:
121 return lsfDisallowIncomingCheck;
122 case asfDisallowIncomingNFTokenOffer:
123 return lsfDisallowIncomingNFTokenOffer;
124 case asfDisallowIncomingPayChan:
125 return lsfDisallowIncomingPayChan;
126 case asfDisallowIncomingTrustline:
127 return lsfDisallowIncomingTrustline;
128 case asfAllowTrustLineLocking:
129 return lsfAllowTrustLineLocking;
208 [[nodiscard]]
Rules const&
222 template <
typename T>
228 auto const& obj = builder.getSTObject();
229 auto const accountId = obj[sfAccount];
231 if (!obj.isFieldPresent(sfTicketSequence))
237 builder.setSequence(0);
240 return submit(builder.build(signer.
pk(), signer.
sk()).getSTTx());
301 [[nodiscard]]
Ledger const&
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
Number is a floating point type that can represent a wide range of values.
Writable ledger view that accumulates state and tx changes.
Rules controlling protocol behavior.
Service registry for dependency injection.
Ledger Entry: AccountRoot.
Test implementation of ServiceRegistry for unit tests.
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.
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.
bool isEnabled(UInt256 const &feature) const
Check if a feature is enabled.
NetClock::time_point now_
Current time (can be advanced arbitrarily for testing).
std::unordered_set< UInt256, beast::Uhash<> > featureSet_
TestServiceRegistry registry_
Rules const & getRules() const
Get the current rules.
void close()
Close the current ledger.
TxResult submit(T &&builder, Account const &signer)
Submit a transaction from a builder.
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_
Ledger const & getClosedLedger() const
Get the closed (base) ledger view.
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.
ServiceRegistry & getServiceRegistry()
Get the service registry.
Immutable cryptographic account descriptor.
SecretKey const & sk() const
Return the secret key.
PublicKey const & pk() const
Return the public key.
Converts to IOU Issue or STAmount.
Base class for all transaction builders.
XrpT const XRP
Converts to XRP Issue or STAmount.
FeatureBitset allFeatures()
Returns all testable amendments.
constexpr XRPAmount
Convert XRP to drops (integral types).
constexpr std::uint32_t asfToLsf(std::uint32_t asf)
Convert AccountSet flag (asf) to LedgerState flag (lsf).
constexpr XRPAmount kDropsPerXrp
Number of drops per 1 XRP.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
Result of a transaction submission in TxTest.
TER ter
The transaction engine result code.
bool applied
Whether the transaction was applied to the ledger.
std::shared_ptr< STTx const > tx
Pointer to the submitted transaction.
std::optional< TxMeta > metadata
Transaction metadata, if available.