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/ledger/ReadView.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Feature.h>
13#include <xrpl/protocol/LedgerFormats.h>
14#include <xrpl/protocol/Rules.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STAmount.h>
17#include <xrpl/protocol/STTx.h>
18#include <xrpl/protocol/TER.h>
19#include <xrpl/protocol/TxFlags.h>
20#include <xrpl/protocol/TxMeta.h>
21#include <xrpl/protocol/XRPAmount.h>
22#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
23#include <xrpl/protocol_autogen/ledger_entries/AccountRoot.h>
24#include <xrpl/tx/applySteps.h>
26#include <helpers/Account.h>
27#include <helpers/IOU.h>
28#include <helpers/TestServiceRegistry.h>
51template <std::
integral T>
63template <std::
floating_po
int T>
104 return lsfRequireDestTag;
106 return lsfRequireAuth;
108 return lsfDisallowXRP;
109 case asfDisableMaster:
110 return lsfDisableMaster;
113 case asfGlobalFreeze:
114 return lsfGlobalFreeze;
115 case asfDefaultRipple:
116 return lsfDefaultRipple;
118 return lsfDepositAuth;
119 case asfAllowTrustLineClawback:
120 return lsfAllowTrustLineClawback;
121 case asfDisallowIncomingCheck:
122 return lsfDisallowIncomingCheck;
123 case asfDisallowIncomingNFTokenOffer:
124 return lsfDisallowIncomingNFTokenOffer;
125 case asfDisallowIncomingPayChan:
126 return lsfDisallowIncomingPayChan;
127 case asfDisallowIncomingTrustline:
128 return lsfDisallowIncomingTrustline;
129 case asfAllowTrustLineLocking:
130 return lsfAllowTrustLineLocking;
209 [[nodiscard]]
Rules const&
223 template <
typename T>
229 auto const& obj = builder.getSTObject();
230 auto accountId = obj[sfAccount];
232 if (!obj.isFieldPresent(sfTicketSequence))
238 builder.setSequence(0);
241 return submit(builder.build(signer.
pk(), signer.
sk()).getSTTx());
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.
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.
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.