|
xrpld
|
A lightweight transaction testing harness. More...
#include <TxTest.h>

Public Member Functions | |
| TxTest (std::optional< FeatureBitset > features=std::nullopt) | |
| Construct a TxTest environment. | |
| bool | isEnabled (uint256 const &feature) const |
| Check if a feature is enabled. | |
| Rules const & | getRules () const |
| Get the current rules. | |
| template<typename T> | |
| TxResult | submit (T &&builder, Account const &signer) |
| Submit a transaction from a builder. | |
| TxResult | submit (std::shared_ptr< STTx const > stx) |
| Submit a transaction to the open ledger. | |
| void | createAccount (Account const &account, XRPAmount xrp, uint32_t accountFlags=0) |
| Create a new account in the ledger. | |
| ledger_entries::AccountRoot | getAccountRoot (AccountID const &id) const |
| Get the account root object from the current open ledger. | |
| OpenView & | getOpenLedger () |
| Get the current open ledger view. | |
| OpenView const & | getOpenLedger () const |
| Get the current open ledger view (const). | |
| ReadView const & | getClosedLedger () const |
| Get the closed (base) ledger view. | |
| void | close () |
| Close the current ledger. | |
| void | advanceTime (NetClock::duration duration) |
| Advance time without closing the ledger. | |
| NetClock::time_point | getCloseTime () const |
| Get the current ledger close time. | |
| STAmount | getBalance (AccountID const &account, IOU const &iou) const |
| Get the balance of an IOU for an account. | |
| ServiceRegistry & | getServiceRegistry () |
| Get the service registry. | |
Private Attributes | |
| TestServiceRegistry | registry_ |
| std::unordered_set< uint256, beast::Uhash<> > | featureSet_ |
| std::optional< Rules > | rules_ |
| std::shared_ptr< Ledger const > | closedLedger_ |
| std::shared_ptr< OpenView > | openLedger_ |
| std::vector< std::shared_ptr< STTx const > > | pendingTxs_ |
| Transactions submitted to the open ledger, for canonical reordering on close. | |
| NetClock::time_point | now_ |
| Current time (can be advanced arbitrarily for testing). | |
A lightweight transaction testing harness.
Unlike the JTx framework which requires a full Application and RPC layer, TxTest applies transactions directly to an OpenView using the transactor pipeline (preflight -> preclaim -> doApply).
This makes it suitable for:
|
explicit |
Construct a TxTest environment.
Creates a genesis ledger and an open view on top of it.
| features | Optional set of features to enable. If not specified, uses all testable amendments. |
Definition at line 62 of file TxTest.cpp.
|
nodiscard |
Check if a feature is enabled.
| feature | The feature to check. |
Definition at line 92 of file TxTest.cpp.
|
nodiscard |
Get the current rules.
Definition at line 99 of file TxTest.cpp.
|
nodiscard |
Submit a transaction from a builder.
Convenience overload that accepts transaction builders. Automatically sets sequence and fee before submission.
| T | A type derived from TransactionBuilderBase. |
| builder | The transaction builder. |
| signer | The account to sign with. |
|
nodiscard |
Submit a transaction to the open ledger.
Applies the transaction through the full transactor pipeline: preflight -> preclaim -> doApply -> invariant checks
Invariant checks are automatically run after doApply. If any invariant fails, the result will be tecINVARIANT_FAILED.
| stx | The transaction to submit. |
Definition at line 106 of file TxTest.cpp.
| void xrpl::test::TxTest::createAccount | ( | Account const & | account, |
| XRPAmount | xrp, | ||
| uint32_t | accountFlags = 0 ) |
Create a new account in the ledger.
Sends a Payment from the master account to create and fund the account. Closes the ledger after creation. If accountFlags is non-zero, submits an AccountSet transaction and closes again.
| account | The account to create. |
| xrp | The initial XRP balance. |
| accountFlags | Optional account flags to set. Defaults to 0 (no flags). |
Definition at line 123 of file TxTest.cpp.
|
nodiscard |
Get the account root object from the current open ledger.
| id | The account ID. |
| std::runtime_error | if the account does not exist. |
Definition at line 148 of file TxTest.cpp.
|
nodiscard |
Get the current open ledger view.
Definition at line 157 of file TxTest.cpp.
|
nodiscard |
Get the current open ledger view (const).
Definition at line 163 of file TxTest.cpp.
|
nodiscard |
Get the closed (base) ledger view.
Definition at line 169 of file TxTest.cpp.
| void xrpl::test::TxTest::close | ( | ) |
Close the current ledger.
Creates a new closed ledger from the current open ledger. All pending transactions are re-applied in canonical order.
Definition at line 175 of file TxTest.cpp.
| void xrpl::test::TxTest::advanceTime | ( | NetClock::duration | duration | ) |
Advance time without closing the ledger.
Useful for testing time-dependent features like escrow release times or offer expirations.
| duration | The amount of time to advance. |
Definition at line 220 of file TxTest.cpp.
|
nodiscard |
Get the current ledger close time.
Definition at line 226 of file TxTest.cpp.
|
nodiscard |
Get the balance of an IOU for an account.
Returns the balance from the perspective of the specified account. If the trust line doesn't exist, returns zero.
| account | The account to check. |
| iou | The IOU to check the balance for. |
Definition at line 232 of file TxTest.cpp.
| ServiceRegistry & xrpl::test::TxTest::getServiceRegistry | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |