3#include <xrpl/basics/Number.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/core/ServiceRegistry.h>
7#include <xrpl/ledger/ApplyViewImpl.h>
8#include <xrpl/ledger/Ledger.h>
9#include <xrpl/ledger/OpenView.h>
10#include <xrpl/protocol/Feature.h>
11#include <xrpl/protocol/LedgerFormats.h>
12#include <xrpl/protocol/Rules.h>
13#include <xrpl/protocol/STTx.h>
14#include <xrpl/protocol/TER.h>
15#include <xrpl/protocol/TxFlags.h>
16#include <xrpl/protocol/XRPAmount.h>
17#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
18#include <xrpl/protocol_autogen/ledger_entries/AccountRoot.h>
19#include <xrpl/tx/applySteps.h>
21#include <helpers/Account.h>
22#include <helpers/IOU.h>
23#include <helpers/TestServiceRegistry.h>
45template <std::
integral T>
57template <std::
floating_po
int T>
98 return lsfRequireDestTag;
100 return lsfRequireAuth;
102 return lsfDisallowXRP;
103 case asfDisableMaster:
104 return lsfDisableMaster;
107 case asfGlobalFreeze:
108 return lsfGlobalFreeze;
109 case asfDefaultRipple:
110 return lsfDefaultRipple;
112 return lsfDepositAuth;
113 case asfAllowTrustLineClawback:
114 return lsfAllowTrustLineClawback;
115 case asfDisallowIncomingCheck:
116 return lsfDisallowIncomingCheck;
117 case asfDisallowIncomingNFTokenOffer:
118 return lsfDisallowIncomingNFTokenOffer;
119 case asfDisallowIncomingPayChan:
120 return lsfDisallowIncomingPayChan;
121 case asfDisallowIncomingTrustline:
122 return lsfDisallowIncomingTrustline;
123 case asfAllowTrustLineLocking:
124 return lsfAllowTrustLineLocking;
203 [[nodiscard]]
Rules const&
217 template <
typename T>
223 auto const& obj = builder.getSTObject();
224 auto accountId = obj[sfAccount];
226 if (!obj.isFieldPresent(sfTicketSequence))
232 builder.setSequence(0);
235 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.