testing

package
v0.0.0-...-19a5819 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: ISC Imports: 34 Imported by: 0

Documentation

Overview

Package testing provides test infrastructure for XRPL transaction testing.

Package testing provides test infrastructure for XRPL transaction testing.

This package is inspired by rippled's test::jtx framework and provides a similar API for creating deterministic test environments.

Overview

The testing package provides:

  • TestEnv: A test environment with ledger state management
  • Account: Deterministic test accounts with keypairs
  • Amount helpers: Functions for creating XRP and IOU amounts
  • Transaction builders: Fluent builders for common transaction types
  • Assertions: Test assertion helpers for common checks

Basic Usage

func TestPayment(t *testing.T) {
    env := testing.NewTestEnv(t)

    alice := testing.NewAccount("alice")
    bob := testing.NewAccount("bob")

    env.Fund(alice, bob)
    env.Close()

    // Alice sends 100 XRP to Bob
    payment := builders.Pay(
        &builders.Account{Address: alice.Address},
        &builders.Account{Address: bob.Address},
        testing.XRP(100),
    ).Build()

    result := env.Submit(payment)
    testing.RequireTxSuccess(t, result)
}

TestEnv

TestEnv manages a test ledger environment. It creates a genesis ledger with a master account and provides methods for funding accounts, submitting transactions, and closing ledgers.

env := testing.NewTestEnv(t)
env.Fund(alice)        // Fund account with 1000 XRP
env.FundAmount(bob, testing.XRP(500))  // Fund with specific amount
env.Close()            // Close ledger, advance sequence
env.Balance(alice)     // Get XRP balance in drops
env.Now()              // Get current ledger time

Account

Account represents a test account with deterministic keypair derivation. Using the same name will always produce the same account, making tests reproducible.

alice := testing.NewAccount("alice")        // secp256k1 by default
bob := testing.NewAccountWithKeyType("bob", testing.KeyTypeEd25519)
master := testing.MasterAccount()           // Genesis account

Amount Helpers

Amount helpers convert between XRP and drops:

testing.XRP(100)    // 100 XRP = 100,000,000 drops
testing.Drops(1000) // 1000 drops

For issued currencies:

gateway := testing.NewAccount("gateway")
testing.USD(gateway, 100.50)  // $100.50 USD from gateway
testing.EUR(gateway, 50.00)   // 50 EUR from gateway
testing.IssuedCurrency(gateway, "JPY", 1000.0)  // Custom currency

Transaction Builders

The builders package provides fluent interfaces for constructing transactions:

// Payment
builders.Pay(from, to, amount).Fee(10).Build()

// Trust line
builders.TrustUSD(account, issuer, "1000000").Build()

// Offer
builders.OfferCreate(account, takerPays, takerGets).Passive().Build()

// Escrow
builders.EscrowCreate(from, to, amount).
    FinishTime(time.Now().Add(24 * time.Hour)).
    Condition(builders.TestCondition1).
    Build()

Assertions

Helper functions for common test assertions:

testing.RequireBalance(t, env, alice, testing.XRP(900))
testing.RequireBalanceXRP(t, env, alice, 900)
testing.RequireTxSuccess(t, result)
testing.RequireTxFail(t, result, testing.TecUNFUNDED_PAYMENT)
testing.RequireAccountExists(t, env, alice)

Clock Control

The test environment uses a ManualClock that can be controlled:

env.AdvanceTime(10 * time.Second)
env.SetTime(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC))
env.Now()  // Current test time

Index

Constants

View Source
const (
	KeyTypeSecp256k1 = "secp256k1"
	KeyTypeEd25519   = "ed25519"
)

KeyType constants for account key derivation.

View Source
const DropsPerXRP int64 = 1_000_000

DropsPerXRP is the number of drops in one XRP.

Variables

This section is empty.

Functions

func AssertBalanceChange

func AssertBalanceChange(t *testing.T, env *TestEnv, acc *Account, expectedChange int64, fn func())

AssertBalanceChange runs a function and asserts the expected balance change. The change can be positive (increase) or negative (decrease).

func AssertNoBalanceChange

func AssertNoBalanceChange(t *testing.T, env *TestEnv, acc *Account, fn func())

AssertNoBalanceChange runs a function and asserts the balance stays the same.

func BTC

func BTC(gw *Account, amount float64) tx.Amount

BTC creates a BTC issued currency amount with the specified gateway.

func DecodeAddress

func DecodeAddress(address string) ([20]byte, error)

DecodeAddress decodes an XRPL address to a 20-byte account ID.

func Drops

func Drops(n int64) int64

Drops returns the drop amount unchanged. This is a convenience function for clarity when specifying amounts in drops.

func EUR

func EUR(gw *Account, amount float64) tx.Amount

EUR creates a EUR issued currency amount with the specified gateway.

func FormatBalance

func FormatBalance(drops uint64) string

FormatBalance formats a balance in drops as a human-readable string. For example, 1000000000 drops becomes "1000.000000 XRP".

func IssuedCurrency

func IssuedCurrency(gw *Account, currency string, amount float64) tx.Amount

IssuedCurrency creates an issued currency amount with custom currency code. The currency code must be 3 characters (e.g., "JPY", "GBP", "CNY").

func IssuedCurrencyFromMantissa

func IssuedCurrencyFromMantissa(gw *Account, currency string, mantissa int64, exponent int) tx.Amount

IssuedCurrencyFromMantissa creates an issued currency amount from mantissa/exponent. Use this when you need precise control over the amount representation.

func NewDisableRegularKeyTx

func NewDisableRegularKeyTx(acc *Account) tx.Transaction

NewDisableRegularKeyTx creates a raw SetRegularKey transaction that clears the regular key.

func NewRemoveSignerListTx

func NewRemoveSignerListTx(acc *Account) tx.Transaction

NewRemoveSignerListTx creates a raw SignerListSet transaction that removes the signer list.

func NewSetRegularKeyTx

func NewSetRegularKeyTx(acc *Account, regularKey *Account) tx.Transaction

NewSetRegularKeyTx creates a raw SetRegularKey transaction that sets a regular key.

func NewSignerListSetTx

func NewSignerListSetTx(acc *Account, quorum uint32, signers []TestSigner) tx.Transaction

NewSignerListSetTx creates a raw SignerListSet transaction without submitting. Use this when you need to submit via SubmitMultiSigned or SubmitSignedWith.

func RequireAccountExists

func RequireAccountExists(t *testing.T, env *TestEnv, acc *Account)

RequireAccountExists asserts that an account exists in the ledger.

func RequireAccountNotExists

func RequireAccountNotExists(t *testing.T, env *TestEnv, acc *Account)

RequireAccountNotExists asserts that an account does not exist in the ledger.

func RequireBalance

func RequireBalance(t *testing.T, env *TestEnv, acc *Account, expected uint64)

RequireBalance asserts that an account has the expected XRP balance in drops. This is a convenience wrapper around require.Equal for balance checks.

func RequireBalanceApprox

func RequireBalanceApprox(t *testing.T, env *TestEnv, acc *Account, expected uint64, tolerance uint64)

RequireBalanceApprox asserts that an account balance is within a tolerance of the expected value. This is useful when fees or other small adjustments affect the exact balance.

func RequireBalanceXRP

func RequireBalanceXRP(t *testing.T, env *TestEnv, acc *Account, expectedXRP int64)

RequireBalanceXRP asserts that an account has the expected XRP balance. The expected amount is in whole XRP units (e.g., 100 XRP, not drops).

func RequireBurnedCount

func RequireBurnedCount(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireBurnedCount asserts that an account has the expected number of burned NFTokens. Reference: rippled's burnedCount() test helper.

func RequireFlagNotSet

func RequireFlagNotSet(t *testing.T, env *TestEnv, acc *Account, flag uint32)

RequireFlagNotSet asserts that a specific flag is NOT set on an account.

func RequireFlagSet

func RequireFlagSet(t *testing.T, env *TestEnv, acc *Account, flag uint32)

RequireFlagSet asserts that a specific flag is set on an account.

func RequireFlags

func RequireFlags(t *testing.T, env *TestEnv, acc *Account, expectedFlags uint32)

RequireFlags asserts that an account has the expected flags set.

func RequireIOUBalance

func RequireIOUBalance(t *testing.T, env *TestEnv, holder, issuer *Account, currency string, expected float64)

RequireIOUBalance asserts that an account has the expected IOU balance. The balance is from the holder's perspective. Reference: rippled's require(env.balance(alice, USD) == USD(100))

func RequireIOUBalanceApprox

func RequireIOUBalanceApprox(t *testing.T, env *TestEnv, holder, issuer *Account, currency string, expected, tolerance float64)

RequireIOUBalanceApprox asserts that an account IOU balance is within a tolerance of the expected value.

func RequireLedgerEntryExists

func RequireLedgerEntryExists(t *testing.T, env *TestEnv, key keylet.Keylet)

RequireLedgerEntryExists asserts that a ledger entry exists at the given keylet.

func RequireLedgerEntryNotExists

func RequireLedgerEntryNotExists(t *testing.T, env *TestEnv, key keylet.Keylet)

RequireLedgerEntryNotExists asserts that a ledger entry does NOT exist at the given keylet.

func RequireLines

func RequireLines(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireLines asserts that an account has the expected number of trust lines. This counts RippleState entries in the account's owner directory.

func RequireMintedCount

func RequireMintedCount(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireMintedCount asserts that an account has the expected number of minted NFTokens. Reference: rippled's mintedCount() test helper.

func RequireOffers

func RequireOffers(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireOffers asserts that an account has the expected number of offers. This counts Offer entries in the account's owner directory.

func RequireOwnerCount

func RequireOwnerCount(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireOwnerCount asserts that an account has the expected owner count.

func RequireSequence

func RequireSequence(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireSequence asserts that an account has the expected sequence number.

func RequireSignerListCount

func RequireSignerListCount(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireSignerListCount asserts that an account has the expected number of signer lists. On the XRPL, an account can have at most one signer list, so expected is 0 or 1.

func RequireTicketCount

func RequireTicketCount(t *testing.T, env *TestEnv, acc *Account, expected uint32)

RequireTicketCount asserts that an account has the expected number of tickets. This iterates the owner directory and counts entries of type Ticket (0x0054), matching rippled's owner_count<ltTICKET> behavior.

func RequireTrustLineExists

func RequireTrustLineExists(t *testing.T, env *TestEnv, acc1, acc2 *Account, currency string)

RequireTrustLineExists asserts that a trust line exists between two accounts for a currency.

func RequireTrustLineNotExists

func RequireTrustLineNotExists(t *testing.T, env *TestEnv, acc1, acc2 *Account, currency string)

RequireTrustLineNotExists asserts that a trust line does NOT exist between two accounts for a currency.

func RequireTxClaimed

func RequireTxClaimed(t *testing.T, result TxResult, expectedCode string)

RequireTxClaimed asserts that a transaction had its fee claimed but wasn't applied. This corresponds to "tec" result codes.

func RequireTxFail

func RequireTxFail(t *testing.T, result TxResult, expectedCode string)

RequireTxFail asserts that a transaction result indicates failure with a specific code.

func RequireTxSuccess

func RequireTxSuccess(t *testing.T, result TxResult)

RequireTxSuccess asserts that a transaction result indicates success.

func ResultCodeCategory

func ResultCodeCategory(code string) string

ResultCodeCategory returns the category of a result code.

func USD

func USD(gw *Account, amount float64) tx.Amount

USD creates a USD issued currency amount with the specified gateway. The amount is specified as a float (e.g., 100.50 for $100.50).

func WithSeq

func WithSeq(transaction tx.Transaction, seq uint32) tx.Transaction

WithSeq sets the sequence number on a transaction manually. This bypasses autofill and allows testing transactions from non-existent accounts. Reference: rippled's seq(1) funclet in test/jtx/seq.h

func WithTicketSeq

func WithTicketSeq(transaction tx.Transaction, ticketSeq uint32) tx.Transaction

WithTicketSeq sets TicketSequence on a transaction (Sequence becomes 0). Reference: rippled's ticket::use(ticketSeq) in ticket.h

func XRP

func XRP(n int64) int64

XRP converts an XRP amount to drops. For example, XRP(100) returns 100,000,000 drops.

func XRPMinusFee

func XRPMinusFee(env *TestEnv, amountXRP int64) uint64

XRPMinusFee calculates expected XRP balance after paying fees. amount is in drops, fee defaults to env's base fee.

func XRPMinusFees

func XRPMinusFees(env *TestEnv, amountXRP int64, numFees int) uint64

XRPMinusFees calculates expected XRP balance after paying multiple fees.

func XRPTxAmount

func XRPTxAmount(drops int64) tx.Amount

XRPTxAmount creates an XRP tx.Amount from drops. This returns a tx.Amount suitable for use in transactions.

func XRPTxAmountFromXRP

func XRPTxAmountFromXRP(xrp float64) tx.Amount

XRPTxAmountFromXRP creates an XRP tx.Amount from whole XRP units. For example, XRPTxAmountFromXRP(100) creates an amount of 100 XRP.

Types

type Account

type Account struct {
	// Name is a human-readable identifier for the account (used for debugging).
	Name string

	// KeyType indicates the cryptographic algorithm used ("secp256k1" or "ed25519").
	KeyType string

	// Seed is the seed bytes used to derive the keypair.
	Seed []byte

	// Address is the classic XRPL address (e.g., "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh").
	Address string

	// PublicKey is the compressed public key bytes (33 bytes for secp256k1, 33 for ed25519 with prefix).
	PublicKey []byte

	// PrivateKey is the private key bytes (32 bytes).
	PrivateKey []byte

	// ID is the 20-byte account ID derived from the public key.
	ID [20]byte

	// Sequence tracks the account's sequence number (for test convenience).
	Sequence uint32
}

Account represents a test account with keypair and address information.

func MasterAccount

func MasterAccount() *Account

MasterAccount returns the well-known master account derived from "masterpassphrase". This is the genesis account that holds all XRP initially. Address: rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh

func NewAccount

func NewAccount(name string) *Account

NewAccount creates a new test account with a deterministic keypair derived from the name. Using the same name will always produce the same account, making tests reproducible. By default, uses secp256k1 key derivation.

func NewAccountFromPassphrase

func NewAccountFromPassphrase(name, passphrase string) *Account

NewAccountFromPassphrase creates a test account from a specific passphrase. This is useful for recreating well-known accounts. Uses secp256k1 by default.

func NewAccountFromPassphraseWithKeyType

func NewAccountFromPassphraseWithKeyType(name, passphrase, keyType string) *Account

NewAccountFromPassphraseWithKeyType creates a test account from a specific passphrase with the specified key type.

func NewAccountFromSeed

func NewAccountFromSeed(name, base58Seed string) *Account

NewAccountFromSeed creates a test account from a base58-encoded seed string. This is useful for recreating accounts from known seeds (e.g., from rippled test vectors).

func NewAccountWithAddress

func NewAccountWithAddress(name string, address string) *Account

NewAccountWithAddress creates a test account at a specific address. The account has no real keypair — it can only be used as a payment destination (to create/fund an account at that specific address) in test environments with signature verification disabled.

func NewAccountWithKeyType

func NewAccountWithKeyType(name string, keyType string) *Account

NewAccountWithKeyType creates a new test account with the specified key type. Supported key types: "secp256k1" and "ed25519".

func (*Account) AccountID

func (a *Account) AccountID() [20]byte

AccountID returns the 20-byte account ID. This is an alias for accessing the ID field directly.

func (*Account) AccountIDHex

func (a *Account) AccountIDHex() string

AccountIDHex returns the account ID as a hex string.

func (*Account) Human

func (a *Account) Human() string

Human returns the human-readable address of the account. This is equivalent to accessing the Address field directly.

func (*Account) IOU

func (a *Account) IOU(currency string, value float64) tx.Amount

IOU returns a tx.Amount for this account as issuer of the given currency. Usage: gw.IOU("USD", 100) returns an issued amount of 100 USD from gw. Reference: rippled's Account::operator[]("USD")(100)

func (*Account) IsEd25519

func (a *Account) IsEd25519() bool

IsEd25519 returns true if this account uses Ed25519 cryptography.

func (*Account) IsSecp256k1

func (a *Account) IsSecp256k1() bool

IsSecp256k1 returns true if this account uses secp256k1 cryptography.

func (*Account) PrivateKeyHex

func (a *Account) PrivateKeyHex() string

PrivateKeyHex returns the private key as a hex string (uppercase).

func (*Account) PublicKeyHex

func (a *Account) PublicKeyHex() string

PublicKeyHex returns the public key as a hex string (uppercase).

func (*Account) String

func (a *Account) String() string

String implements the Stringer interface for debugging.

type AccountInfo

type AccountInfo struct {
	Address              string
	Balance              uint64
	Sequence             uint32
	OwnerCount           uint32
	Flags                uint32
	MintedNFTokens       uint32
	BurnedNFTokens       uint32
	FirstNFTokenSequence *uint32
	NFTokenMinter        string
	Domain               string
	EmailHash            string
	MessageKey           string
	WalletLocator        string
	AccountTxnID         [32]byte
	TransferRate         uint32
	TicketCount          uint32
}

AccountInfo contains account information from the ledger.

type ManualClock

type ManualClock struct {
	// contains filtered or unexported fields
}

ManualClock provides a controllable clock for testing time-dependent behavior.

func NewManualClock

func NewManualClock() *ManualClock

NewManualClock creates a new ManualClock set to a default time. The default is January 1, 2020, 00:00:00 UTC, which is after the Ripple epoch.

func NewManualClockAt

func NewManualClockAt(t time.Time) *ManualClock

NewManualClockAt creates a new ManualClock set to the specified time.

func (*ManualClock) Advance

func (c *ManualClock) Advance(d time.Duration)

Advance moves the clock forward by the specified duration.

func (*ManualClock) Now

func (c *ManualClock) Now() time.Time

Now returns the current time on the clock.

func (*ManualClock) Set

func (c *ManualClock) Set(t time.Time)

Set sets the clock to a specific time.

type TestEnv

type TestEnv struct {

	// VerifySignatures enables cryptographic signature verification in the engine.
	// Default is false (test mode). Set to true for conformance tests with real tx_blobs.
	VerifySignatures bool
	// contains filtered or unexported fields
}

TestEnv manages a test ledger environment for transaction testing. It provides a simplified interface for creating accounts, funding them, submitting transactions, and verifying results.

func NewTestEnv

func NewTestEnv(t testing.TB) *TestEnv

NewTestEnv creates a new test environment with a genesis ledger.

func NewTestEnvBacked

func NewTestEnvBacked(t testing.TB) *TestEnv

NewTestEnvBacked creates a test environment with PebbleDB-backed SHAMaps. Use this for heavy tests (e.g., crossing_limits with 2000+ offers) that would OOM with unbacked mode. Data goes to disk; only the LRU cache lives in RAM.

func NewTestEnvWithConfig

func NewTestEnvWithConfig(t testing.TB, cfg genesis.Config) *TestEnv

NewTestEnvWithConfig creates a new test environment with custom genesis configuration.

func NewTestEnvWithConfigBacked

func NewTestEnvWithConfigBacked(t testing.TB, cfg genesis.Config) *TestEnv

NewTestEnvWithConfigBacked creates a test environment with custom config and PebbleDB backing.

func NewTestEnvWithTxQ

func NewTestEnvWithTxQ(t testing.TB, cfg txq.Config) *TestEnv

NewTestEnvWithTxQ creates a test environment with a transaction queue. Submit() will route transactions through the TxQ for fee escalation and sequence-gap queuing, matching rippled's behavior when using Env with TxQ. Reference: rippled's test Env routes through NetworkOPs -> TxQ.

func NewTestEnvWithTxQAndConfig

func NewTestEnvWithTxQAndConfig(t testing.TB, txqCfg txq.Config, genesisCfg genesis.Config) *TestEnv

NewTestEnvWithTxQAndConfig creates a test environment with a transaction queue and custom genesis configuration.

func (*TestEnv) AccountInfo

func (e *TestEnv) AccountInfo(acc *Account) *AccountInfo

AccountInfo returns detailed account information.

func (*TestEnv) AdvanceTime

func (e *TestEnv) AdvanceTime(d time.Duration)

AdvanceTime advances the test clock by the specified duration.

func (*TestEnv) AuthorizeTrustLine

func (e *TestEnv) AuthorizeTrustLine(issuer, holder *Account, currency string)

AuthorizeTrustLine authorizes a trust line (when RequireAuth is set on the issuer). Reference: rippled's trust(account, amount, tfSetfAuth)

func (*TestEnv) Balance

func (e *TestEnv) Balance(acc *Account) uint64

Balance returns the XRP balance of an account in drops.

func (*TestEnv) BalanceIOU

func (e *TestEnv) BalanceIOU(holder *Account, currency string, issuer *Account) float64

BalanceIOU returns the IOU balance of an account for a specific currency and issuer as float64. This is a convenience method for tests that need simple numeric comparisons.

func (*TestEnv) BaseFee

func (e *TestEnv) BaseFee() uint64

BaseFee returns the base fee in drops.

func (*TestEnv) BumpDirectoryLastPage

func (e *TestEnv) BumpDirectoryLastPage(acc *Account, targetPage uint64, adjustField string) error

BumpDirectoryLastPage moves the last page of an account's owner directory to a target page number. This mirrors rippled's test::jtx::directory::bumpLastPage() which is used to test directory page limit checks by placing the last page near the maximum allowed page number.

The operation: 1. Finds the last page of the owner directory 2. Copies its entries to a new page at targetPage 3. Erases the old last page 4. Updates page chain pointers (root, previous page) 5. Updates each moved entry's adjustField to the new page number

Reference: rippled src/test/jtx/impl/directory.cpp bumpLastPage()

func (*TestEnv) BumpSequenceAndDeductAmount

func (e *TestEnv) BumpSequenceAndDeductAmount(acc *Account, fee uint64)

BumpSequenceAndDeductAmount increments an account's sequence and deducts the specified fee amount directly in the ledger. This is used when the fee to deduct differs from the base fee, e.g., for multi-signed transactions where the fee is baseFee * (1 + numSigners).

func (*TestEnv) BumpSequenceAndDeductFee

func (e *TestEnv) BumpSequenceAndDeductFee(acc *Account)

BumpSequenceAndDeductFee increments an account's sequence and deducts the base fee directly in the ledger. Used by the conformance runner to match rippled's behavior where tem* results from type-specific preflight (inside doApply) still consume the sequence and fee because the engine's generic preclaim already passed.

func (*TestEnv) BurnedCount

func (e *TestEnv) BurnedCount(acc *Account) uint32

BurnedCount returns the number of NFTokens burned for this issuer. Reference: rippled's burnedCount() test helper.

func (*TestEnv) ClearTrustLineAuth

func (e *TestEnv) ClearTrustLineAuth(acc1, acc2 *Account, currency string)

ClearTrustLineAuth clears the authorization flags on a trust line between two accounts. This directly modifies ledger state, simulating rippled's rawInsert for tests that require unauthorized but funded trust lines.

func (*TestEnv) Close

func (e *TestEnv) Close()

Close closes the current ledger and advances to a new one. This is equivalent to "ledger_accept" in rippled.

When replayOnClose is enabled, Close() simulates the consensus process: it discards the current open ledger state, creates a fresh open ledger from the last closed ledger (parent), and replays all tracked transactions in canonical order with retry passes. This matches rippled's standalone consensus simulation (BuildLedger.cpp).

func (*TestEnv) CloseAt

func (e *TestEnv) CloseAt(targetSeq uint32)

CloseAt closes ledgers until the ledger reaches the target sequence. If already at or past target, does nothing.

func (*TestEnv) CloseWithTimeLeap

func (e *TestEnv) CloseWithTimeLeap()

CloseWithTimeLeap closes the current ledger with a simulated time leap. A time leap indicates that consensus was slow, causing the TxQ to aggressively reduce txnsExpected back toward the minimum. This matches rippled's behavior when env.close(env.now() + 5s, 10000ms) is called in tests. Reference: rippled TxQ::FeeMetrics::update timeLeap handling

func (*TestEnv) CreateOffer

func (e *TestEnv) CreateOffer(acc *Account, takerGets, takerPays tx.Amount) TxResult

CreateOffer creates an offer on the DEX. takerGets is what the offer creator will receive (what the taker pays). takerPays is what the offer creator will pay (what the taker gets).

func (*TestEnv) CreatePassiveOffer

func (e *TestEnv) CreatePassiveOffer(acc *Account, takerGets, takerPays tx.Amount) TxResult

CreatePassiveOffer creates a passive offer on the DEX. Passive offers don't immediately consume offers at an equal or better rate.

func (*TestEnv) CreateTickets

func (e *TestEnv) CreateTickets(acc *Account, count uint32) uint32

CreateTickets creates N tickets for an account. Returns the first ticket sequence number. Reference: rippled's ticket::create(account, count) in ticket.h

func (*TestEnv) DisableDepositAuth

func (e *TestEnv) DisableDepositAuth(acc *Account)

DisableDepositAuth disables the DepositAuth flag on an account.

func (*TestEnv) DisableDisallowIncomingCheck

func (e *TestEnv) DisableDisallowIncomingCheck(acc *Account)

DisableDisallowIncomingCheck disables the DisallowIncomingCheck flag on an account.

func (*TestEnv) DisableDisallowIncomingNFTokenOffer

func (e *TestEnv) DisableDisallowIncomingNFTokenOffer(acc *Account)

DisableDisallowIncomingNFTokenOffer disables the DisallowIncomingNFTokenOffer flag on an account.

func (*TestEnv) DisableDisallowIncomingPayChan

func (e *TestEnv) DisableDisallowIncomingPayChan(acc *Account)

DisableDisallowIncomingPayChan disables the DisallowIncomingPayChan flag on an account.

func (*TestEnv) DisableDisallowIncomingTrustline

func (e *TestEnv) DisableDisallowIncomingTrustline(acc *Account)

DisableDisallowIncomingTrustline disables the DisallowIncomingTrustline flag on an account.

func (*TestEnv) DisableFeature

func (e *TestEnv) DisableFeature(name string)

DisableFeature disables an amendment by name for subsequent transactions. See EnableFeature for the Close()-required semantic. Reference: rippled's Env::disableFeature() in test/jtx/impl/Env.cpp.

func (*TestEnv) DisableGlobalFreeze

func (e *TestEnv) DisableGlobalFreeze(acc *Account)

DisableGlobalFreeze disables the GlobalFreeze flag on an account. Note: Cannot be cleared if NoFreeze is set.

func (*TestEnv) DisableMasterKey

func (e *TestEnv) DisableMasterKey(acc *Account)

DisableMasterKey disables the master key on an account using AccountSet. The account must have a regular key or signer list set first.

func (*TestEnv) DisableRegularKey

func (e *TestEnv) DisableRegularKey(acc *Account)

DisableRegularKey removes the regular key from an account. Reference: rippled's regkey(account, disabled) in regkey.h

func (*TestEnv) DisableRegularKeyExpect

func (e *TestEnv) DisableRegularKeyExpect(acc *Account, expectedCode string)

DisableRegularKeyExpect attempts to clear the regular key and expects a specific result.

func (*TestEnv) DisableRequireAuth

func (e *TestEnv) DisableRequireAuth(acc *Account)

DisableRequireAuth disables the RequireAuth flag on an account.

func (*TestEnv) DisableRequireDest

func (e *TestEnv) DisableRequireDest(acc *Account)

DisableRequireDest disables the RequireDest flag on an account.

func (*TestEnv) EnableDepositAuth

func (e *TestEnv) EnableDepositAuth(acc *Account)

EnableDepositAuth enables the DepositAuth flag on an account. When enabled, the account can only receive payments from preauthorized accounts.

func (*TestEnv) EnableDisallowIncomingCheck

func (e *TestEnv) EnableDisallowIncomingCheck(acc *Account)

EnableDisallowIncomingCheck enables the DisallowIncomingCheck flag on an account.

func (*TestEnv) EnableDisallowIncomingNFTokenOffer

func (e *TestEnv) EnableDisallowIncomingNFTokenOffer(acc *Account)

EnableDisallowIncomingNFTokenOffer enables the DisallowIncomingNFTokenOffer flag on an account.

func (*TestEnv) EnableDisallowIncomingPayChan

func (e *TestEnv) EnableDisallowIncomingPayChan(acc *Account)

EnableDisallowIncomingPayChan enables the DisallowIncomingPayChan flag on an account.

func (*TestEnv) EnableDisallowIncomingTrustline

func (e *TestEnv) EnableDisallowIncomingTrustline(acc *Account)

EnableDisallowIncomingTrustline enables the DisallowIncomingTrustline flag on an account.

func (*TestEnv) EnableFeature

func (e *TestEnv) EnableFeature(name string)

EnableFeature enables an amendment by name for subsequent transactions. Matches rippled's Env::enableFeature() in test/jtx/impl/Env.cpp: the amendment is staged into the rules builder and only takes effect after the next Close() — call e.Close() before submitting transactions that depend on the new amendment.

func (*TestEnv) EnableGlobalFreeze

func (e *TestEnv) EnableGlobalFreeze(acc *Account)

EnableGlobalFreeze enables the GlobalFreeze flag on an account. When enabled, all trust lines for this account's issued currencies are frozen.

func (*TestEnv) EnableNoFreeze

func (e *TestEnv) EnableNoFreeze(acc *Account)

EnableNoFreeze enables the NoFreeze flag on an account. Once set, this flag cannot be cleared. It prevents the account from freezing trust lines.

func (*TestEnv) EnableOpenLedgerReplay

func (e *TestEnv) EnableOpenLedgerReplay()

EnableOpenLedgerReplay enables the open-ledger consensus replay behavior. When enabled, Close() rebuilds the closed ledger from the parent closed ledger by replaying all tracked transactions in canonical order with retry passes. This matches rippled's standalone consensus simulation.

Use this for tests that depend on:

  • terPRE_SEQ transactions being retried after close
  • tec transactions being re-applied from a clean state after prerequisite objects are created by batch transactions

Must be called before any Submit calls in the test. Reference: rippled BuildLedger.cpp applyTransactions()

func (*TestEnv) EnableRequireAuth

func (e *TestEnv) EnableRequireAuth(acc *Account)

EnableRequireAuth enables the RequireAuth flag on an account. When enabled, trust lines to this account require authorization.

func (*TestEnv) EnableRequireDest

func (e *TestEnv) EnableRequireDest(acc *Account)

EnableRequireDest enables the RequireDest flag on an account. When enabled, the account requires a destination tag on incoming payments.

func (*TestEnv) EscalatedFee

func (e *TestEnv) EscalatedFee() uint64

EscalatedFee returns the fee (in drops) a transaction should pay to bypass the queue and get directly into the current open ledger. This matches rippled's auto-fill fee computation in TransactionSign.cpp:

escalatedFee = toDrops(openLedgerFeeLevel - 1, baseFee) + 1

Reference: rippled getCurrentNetworkFee() in TransactionSign.cpp

func (*TestEnv) Exists

func (e *TestEnv) Exists(acc *Account) bool

Exists checks if an account exists in the ledger.

func (*TestEnv) FeatureEnabled

func (e *TestEnv) FeatureEnabled(name string) bool

FeatureEnabled returns true if the named amendment is currently enabled. Reference: rippled's Env::enabled() in test/jtx/Env.h

func (*TestEnv) ForceOwnerDirEmptyAnchorWithNext

func (e *TestEnv) ForceOwnerDirEmptyAnchorWithNext(acc *Account, nextPage uint64) error

ForceOwnerDirEmptyAnchorWithNext rewrites the anchor (root) page of an account's owner directory to have an empty Indexes slice while leaving IndexNext pointing at a non-zero continuation page. This reproduces the state rippled's dirIsEmpty must guard against: an emptied anchor whose directory is still non-empty because subsequent pages remain.

Reference: rippled View.cpp dirIsEmpty().

func (*TestEnv) FreezeTrustLine

func (e *TestEnv) FreezeTrustLine(issuer, holder *Account, currency string)

FreezeTrustLine freezes a specific trust line (issuer-side freeze). Reference: rippled's trust(account, amount, peer, tfSetFreeze)

func (*TestEnv) Fund

func (e *TestEnv) Fund(accounts ...*Account)

Fund funds the specified accounts from the master account. Each account receives the specified amount or a default of 1000 XRP.

func (*TestEnv) FundAmount

func (e *TestEnv) FundAmount(acc *Account, amount uint64)

FundAmount funds an account with a specific amount. Like rippled's test environment, this also enables DefaultRipple on the account. This is important for trust line behavior - without DefaultRipple, trust lines cannot be deleted when limit is set to 0 (the NoRipple state would be "non-default").

func (*TestEnv) FundAmountNoRipple

func (e *TestEnv) FundAmountNoRipple(acc *Account, amount uint64)

FundAmountNoRipple funds an account with a specific amount but does NOT enable DefaultRipple.

func (*TestEnv) FundNoRipple

func (e *TestEnv) FundNoRipple(accounts ...*Account)

FundNoRipple funds accounts WITHOUT enabling DefaultRipple. Reference: rippled's noripple(accounts...) in Env.h

func (*TestEnv) GetAccount

func (e *TestEnv) GetAccount(name string) *Account

GetAccount returns a registered account by name.

func (*TestEnv) GetTxQ

func (e *TestEnv) GetTxQ() *txq.TxQ

GetTxQ returns the test environment's transaction queue, or nil if not configured.

func (*TestEnv) HasNoRipple

func (e *TestEnv) HasNoRipple(account, counterparty *Account, currency string) bool

HasNoRipple checks if the account's side of the trust line has NoRipple set.

func (*TestEnv) IOUBalance

func (e *TestEnv) IOUBalance(holder, issuer *Account, currency string) *state.Amount

IOUBalance returns the IOU balance of an account for a specific currency and issuer. The balance is returned from the perspective of the holder (not the issuer). Positive means the holder has tokens, negative means they owe tokens.

func (*TestEnv) IncLedgerSeqForAccDel

func (e *TestEnv) IncLedgerSeqForAccDel(acc *Account)

IncLedgerSeqForAccDel closes enough ledgers so account deletion is allowed. rippled requires the account's sequence + 255 to be <= the current ledger sequence. Uses addition instead of subtraction to avoid uint32 underflow. Reference: rippled's incLgrSeqForAccDel() in acctdelete.h

func (*TestEnv) IsReplayEnabled

func (e *TestEnv) IsReplayEnabled() bool

IsReplayEnabled returns whether open-ledger replay is enabled.

func (*TestEnv) LastClosedLedger

func (e *TestEnv) LastClosedLedger() *ledger.Ledger

LastClosedLedger returns the most recently closed ledger (LCL), the parent of the current open ledger. Useful for replay-style tests that need to anchor on a real, fully-constructed parent ledger (e.g., post-state derivation tests that replay txs from one closed ledger into a verified successor).

func (*TestEnv) Ledger

func (e *TestEnv) Ledger() *ledger.Ledger

Ledger returns the current open ledger.

func (*TestEnv) LedgerEntry

func (e *TestEnv) LedgerEntry(key keylet.Keylet) ([]byte, error)

LedgerEntry reads a raw ledger entry by keylet.

func (*TestEnv) LedgerEntryExists

func (e *TestEnv) LedgerEntryExists(key keylet.Keylet) bool

LedgerEntryExists checks if a ledger entry exists by keylet.

func (*TestEnv) LedgerSeq

func (e *TestEnv) LedgerSeq() uint32

LedgerSeq returns the current ledger sequence number.

func (*TestEnv) Limit

func (e *TestEnv) Limit(holder, issuer *Account, currency string) float64

Limit returns the trust line limit for an account/issue. Returns 0 if the trust line doesn't exist. Reference: rippled's Env::limit(account, issue)

func (*TestEnv) MasterAccount

func (e *TestEnv) MasterAccount() *Account

MasterAccount returns the master account for the test environment.

func (*TestEnv) MintedCount

func (e *TestEnv) MintedCount(acc *Account) uint32

MintedCount returns the number of NFTokens minted by this issuer. Reference: rippled's mintedCount() test helper.

func (*TestEnv) Noop

func (e *TestEnv) Noop(acc *Account)

Noop submits a no-op AccountSet to bump an account's sequence number. Reference: rippled's noop(account) in noop.h

func (*TestEnv) NoopWithFee

func (e *TestEnv) NoopWithFee(acc *Account, fee uint64)

NoopWithFee submits a no-op AccountSet with a custom fee. Reference: rippled's env(noop(account), fee(f))

func (*TestEnv) Now

func (e *TestEnv) Now() time.Time

Now returns the current time on the test clock.

func (*TestEnv) OpenLedgerFee

func (e *TestEnv) OpenLedgerFee(customBaseFee uint64) uint64

OpenLedgerFee returns the fee (in drops) needed to bypass the queue for a transaction with the given customBaseFee. This is used for batch transactions where the "base fee" is the batch fee (which is higher than the standard base fee due to signers and inner transactions).

Reference: rippled Batch_test.cpp openLedgerFee():

toDrops(metrics.openLedgerFeeLevel, batchFee) + 1

func (*TestEnv) OwnerCount

func (e *TestEnv) OwnerCount(acc *Account) uint32

OwnerCount returns the owner count for an account. It fatals if the account does not exist, matching rippled's Env which throws when querying a non-existent account. Reference: rippled's Env::ownerCount(account) in Env.h

func (*TestEnv) Pay

func (e *TestEnv) Pay(acc *Account, drops uint64)

Pay sends XRP from master to an already-funded account. This is useful for tests that need to top-up an account with additional XRP (e.g., to meet reserve requirements). Unlike FundAmount, this does not register the account or enable DefaultRipple.

func (*TestEnv) PayIOU

func (e *TestEnv) PayIOU(sender, receiver *Account, issuer *Account, currency string, amount float64)

PayIOU sends an IOU payment from sender to receiver. The issuer is the gateway that issued the currency. Reference: rippled's env(pay(sender, receiver, amount))

func (*TestEnv) PayIOUWithSendMax

func (e *TestEnv) PayIOUWithSendMax(sender, receiver *Account, issuer *Account, currency string, amount, sendMax float64)

PayIOUWithSendMax sends an IOU payment with a SendMax limit. Reference: rippled's env(pay(sender, receiver, amount), sendmax(max))

func (*TestEnv) Preauthorize

func (e *TestEnv) Preauthorize(owner, authorized *Account)

Preauthorize allows owner to preauthorize authorized for deposits. This creates a DepositPreauth ledger entry.

func (*TestEnv) ReimburseWithPayment

func (e *TestEnv) ReimburseWithPayment(acc *Account)

ReimburseWithPayment submits a real Payment from master to reimburse the TrustSet fee, matching rippled's Env::trust() behavior where trust setup includes a Payment(master → account, baseFee) that costs master 2×baseFee (payment amount + tx fee). The Payment is tracked as a setup transaction when inSetupMode=true, so it participates in canonical sort salt and survives replay-on-close.

func (*TestEnv) RemoveSignerList

func (e *TestEnv) RemoveSignerList(acc *Account)

RemoveSignerList removes the signer list from an account. Reference: rippled's signers(account, none) in multisign.h

func (*TestEnv) ReserveBase

func (e *TestEnv) ReserveBase() uint64

ReserveBase returns the base reserve in drops.

func (*TestEnv) ReserveIncrement

func (e *TestEnv) ReserveIncrement() uint64

ReserveIncrement returns the reserve increment in drops.

func (*TestEnv) ResetTxQMaxSize

func (e *TestEnv) ResetTxQMaxSize()

ResetTxQMaxSize resets the TxQ's maxSize to nil (no limit). This matches rippled's initial state where maxSize_ is std::nullopt before the first user-initiated processClosedLedger call. In rippled, the genesis close (startGenesisLedger) does NOT call processClosedLedger, so maxSize_ remains nullopt until the first env.close() in the test.

func (*TestEnv) Seq

func (e *TestEnv) Seq(acc *Account) uint32

Seq returns the current sequence number for an account. It fatals if the account does not exist, matching rippled's Env which throws when querying a non-existent account. Use SeqOrDefault for auto-fill paths where the account may not exist yet.

func (*TestEnv) SeqOrDefault

func (e *TestEnv) SeqOrDefault(acc *Account) uint32

SeqOrDefault returns the current sequence number for an account, or 1 if the account does not exist. This is useful for auto-fill paths where the account may not have been created yet (e.g., the Payment that creates it is the one being submitted).

func (*TestEnv) SetAmendments

func (e *TestEnv) SetAmendments(names []string)

SetAmendments replaces the current amendment set with exactly the named amendments. Changes are deferred until the next Close(), matching rippled where enableFeature/disableFeature require close() to take effect. Reference: rippled Env.cpp: "Env::close() must be called for feature enable to take place."

func (*TestEnv) SetBaseFee

func (e *TestEnv) SetBaseFee(baseFee uint64)

SetBaseFee changes the base fee for subsequent transactions. Used to apply post-initFee() fee changes in conformance tests.

func (*TestEnv) SetBypassTxQ

func (e *TestEnv) SetBypassTxQ(bypass bool)

SetBypassTxQ temporarily bypasses TxQ routing. When true, Submit() goes directly to the engine even when a TxQ is configured. This matches rippled's distinction between apply() (direct, used for setup) and submit() (via TxQ).

func (*TestEnv) SetDelegate

func (e *TestEnv) SetDelegate(owner, authorized *Account, permissions []string)

SetDelegate creates a Delegate SLE that grants delegation permissions from one account to another. permissions is a list of permission names like "Payment", "AccountDomainSet", etc. Reference: rippled's delegate::set(account, authorize, permissions) in Delegate_test.cpp

func (*TestEnv) SetFirstNFTokenSequenceDirect

func (e *TestEnv) SetFirstNFTokenSequenceDirect(acc *Account, seq uint32)

SetFirstNFTokenSequenceDirect directly modifies an account's FirstNFTokenSequence field in the ledger, bypassing normal transaction validation. This is used to test boundary conditions with fixNFTokenRemint. Reference: rippled NFToken_test.cpp testMintMaxTokens (env.app().openLedger().modify())

func (*TestEnv) SetInSetupMode

func (e *TestEnv) SetInSetupMode(setup bool)

SetInSetupMode controls whether subsequent transactions are tagged as setup (fund/trust) or user (fixture) for replay purposes. Setup transactions are replayed first in submission order; user transactions are replayed second in canonical sorted order.

func (*TestEnv) SetMintedNFTokensDirect

func (e *TestEnv) SetMintedNFTokensDirect(acc *Account, count uint32)

SetMintedNFTokensDirect directly modifies an account's MintedNFTokens field in the ledger, bypassing normal transaction validation. This is used to test boundary conditions (e.g., near 0xFFFFFFFF) without actually minting billions of tokens. Reference: rippled NFToken_test.cpp testMintMaxTokens (env.app().openLedger().modify())

func (*TestEnv) SetNetworkID

func (e *TestEnv) SetNetworkID(id uint32)

SetNetworkID sets the network identifier for the test environment. Networks with ID > 1024 require NetworkID in transactions. Networks with ID <= 1024 are legacy networks and cannot have NetworkID in transactions. Reference: rippled's Config::NETWORK_ID

func (*TestEnv) SetNextCloseSalt

func (e *TestEnv) SetNextCloseSalt(salt [32]byte)

SetNextCloseSalt sets the canonical sort salt for the next replay close. When set, closeWithReplay() uses this salt instead of computing one from the transaction set. Cleared after use.

func (*TestEnv) SetOpenLedger

func (e *TestEnv) SetOpenLedger(open bool)

SetOpenLedger controls whether the engine checks fee adequacy. When false, fee adequacy checks are skipped (matching rippled's closed-ledger behavior).

func (*TestEnv) SetRegularKey

func (e *TestEnv) SetRegularKey(acc, regularKey *Account)

SetRegularKey sets a regular key on an account. Reference: rippled's regkey(account, signer) in regkey.h

func (*TestEnv) SetReserves

func (e *TestEnv) SetReserves(reserveBase, reserveIncrement uint64)

SetReserves changes the reserve base and increment for subsequent transactions. Used to apply post-initFee() reserve changes in conformance tests.

func (*TestEnv) SetSignerList

func (e *TestEnv) SetSignerList(acc *Account, quorum uint32, signers []TestSigner)

SetSignerList sets a signer list on an account. Reference: rippled's signers(account, quorum, signerList) in multisign.h

func (*TestEnv) SetTime

func (e *TestEnv) SetTime(t time.Time)

SetTime sets the test clock to a specific time.

func (*TestEnv) SetTransferRate

func (e *TestEnv) SetTransferRate(acc *Account, rate uint32)

SetTransferRate sets the transfer rate for an account. Rate is specified as a multiplier * 1e9 (1e9 = 100%, 1.1e9 = 110% means 10% fee). Use 0 to clear the transfer rate (sets it back to 1e9 / 100%).

func (*TestEnv) SetTransferRateDirect

func (e *TestEnv) SetTransferRateDirect(acc *Account, rate uint32)

SetTransferRateDirect modifies the TransferRate directly in ledger state. This bypasses transaction validation, allowing out-of-bounds rates for testing legacy MainNet accounts. Reference: rippled AccountSet_test.cpp lines 446-460 (env.app().openLedger().modify())

func (*TestEnv) SetVerifySignatures

func (e *TestEnv) SetVerifySignatures(verify bool)

SetVerifySignatures enables or disables signature verification in the engine.

func (*TestEnv) SignWith

func (e *TestEnv) SignWith(txn tx.Transaction, signer *Account) tx.Transaction

SignWith signs a transaction using a specific account's key pair. Sets SigningPubKey and TxnSignature on the transaction. Reference: rippled's sig.h -- sig(account) funclet.

func (*TestEnv) Submit

func (e *TestEnv) Submit(transaction interface{}) TxResult

Submit submits a transaction to the current open ledger. If the transaction doesn't have a sequence number set, it will be auto-filled from the account's current sequence in the ledger.

When a TxQ is configured (via NewTestEnvWithTxQ), Submit routes through the TxQ for fee escalation and sequence-gap queuing. Transactions that cannot afford the escalated fee or have a future sequence are queued and return terQUEUED or terPRE_SEQ respectively.

func (*TestEnv) SubmitMultiSigned

func (e *TestEnv) SubmitMultiSigned(transaction interface{}, signers []*Account) TxResult

SubmitMultiSigned attaches multi-signatures from the given signers and submits with signature verification enabled. Each signer signs the transaction with their key, sorted by account ID. Reference: rippled's msig(signers...) funclet.

func (*TestEnv) SubmitPseudo

func (e *TestEnv) SubmitPseudo(transaction interface{}) TxResult

SubmitPseudo submits a pseudo-transaction (EnableAmendment, SetFee, UNLModify) directly to the engine. Pseudo-transactions bypass account lookup, sequence auto-fill, fee deduction, and signature verification. Reference: rippled Change.cpp -- pseudo-txs have zero account, zero fee, no sigs.

func (*TestEnv) SubmitSigned

func (e *TestEnv) SubmitSigned(transaction interface{}) TxResult

SubmitSigned signs the transaction with the account's own key and submits with signature verification enabled. The signing account is inferred from the transaction's Account field.

func (*TestEnv) SubmitSignedWith

func (e *TestEnv) SubmitSignedWith(transaction interface{}, signer *Account) TxResult

SubmitSignedWith signs the transaction with a different key (e.g. a regular key) and submits with signature verification enabled. Reference: rippled's sig(account) -- sign with regular key.

func (*TestEnv) TicketCount

func (e *TestEnv) TicketCount(acc *Account) uint32

TicketCount returns the ticket count for an account (0 if account doesn't exist). Reference: rippled sfTicketCount field on AccountRoot

func (*TestEnv) Trust

func (e *TestEnv) Trust(acc *Account, amount tx.Amount)

Trust creates a trust line and refunds the fee from master. Reference: rippled's Env::trust(amount, account) in Env.h

func (*TestEnv) TrustLineExists

func (e *TestEnv) TrustLineExists(acc1, acc2 *Account, currency string) bool

TrustLineExists checks if a trust line exists between two accounts for a currency.

func (*TestEnv) TrustLineFlags

func (e *TestEnv) TrustLineFlags(account, counterparty *Account, currency string) uint32

TrustLineFlags returns the flags on a trust line between two accounts. Returns the flags from the perspective of 'account' (which side's flags).

func (*TestEnv) TxInLedger

func (e *TestEnv) TxInLedger() uint32

TxInLedger returns the number of transactions applied to the current open ledger. This is useful for TxQ-related test assertions (e.g., checkMetrics).

func (*TestEnv) TxQMetrics

func (e *TestEnv) TxQMetrics() txq.Metrics

TxQMetrics returns the current TxQ metrics. Panics if TxQ is not configured. Reference: rippled TxQ::getMetrics(*env.current())

func (*TestEnv) Unauthorize

func (e *TestEnv) Unauthorize(owner, authorized *Account)

Unauthorize removes preauthorization for authorized from owner.

func (*TestEnv) UnfreezeTrustLine

func (e *TestEnv) UnfreezeTrustLine(issuer, holder *Account, currency string)

UnfreezeTrustLine unfreezes a specific trust line.

func (*TestEnv) WithT

func (e *TestEnv) WithT(t testing.TB) *TestEnv

WithT retargets the env at the given testing.TB. Use this from a subtest so that env-driven Helper / Fatalf calls attribute failures to the subtest rather than the parent test captured at construction.

type TestSigner

type TestSigner struct {
	Account *Account
	Weight  uint16
}

TestSigner represents a signer entry for use in SetSignerList.

type TxResult

type TxResult struct {
	// Code is the transaction engine result code (e.g., "tesSUCCESS").
	Code string

	// Success indicates whether the transaction was successfully applied.
	Success bool

	// Message provides additional details about the result.
	Message string

	// Metadata contains the transaction metadata (AffectedNodes, etc.).
	Metadata *tx.Metadata
}

TxResult represents the result of applying a transaction.

func ResultSuccess

func ResultSuccess() TxResult

ResultSuccess returns a successful transaction result.

func ResultWithCode

func ResultWithCode(code string, success bool, message string) TxResult

ResultWithCode creates a TxResult with the specified code.

func (TxResult) IsClaimed

func (r TxResult) IsClaimed() bool

IsClaimed returns true if the result code indicates the fee was claimed but the transaction was not applied (tec codes).

func (TxResult) IsFailed

func (r TxResult) IsFailed() bool

IsFailed returns true if the result code indicates a failure.

func (TxResult) IsMalformed

func (r TxResult) IsMalformed() bool

IsMalformed returns true if the result code indicates the transaction is malformed.

func (TxResult) IsRetry

func (r TxResult) IsRetry() bool

IsRetry returns true if the result code indicates a retry is possible.

func (TxResult) IsSuccess

func (r TxResult) IsSuccess() bool

IsSuccess returns true if the result code indicates success.

type TxResultCode

type TxResultCode = string

TxResultCode is a type alias for transaction result codes for better documentation.

const (
	// Success
	TesSUCCESS TxResultCode = "tesSUCCESS"

	// Claimed (tec) - fee claimed but transaction not applied
	TecCLAIM                 TxResultCode = "tecCLAIM"
	TecPATH_PARTIAL          TxResultCode = "tecPATH_PARTIAL"
	TecUNFUNDED_ADD          TxResultCode = "tecUNFUNDED_ADD"
	TecUNFUNDED_OFFER        TxResultCode = "tecUNFUNDED_OFFER"
	TecUNFUNDED_PAYMENT      TxResultCode = "tecUNFUNDED_PAYMENT"
	TecFAILED_PROCESSING     TxResultCode = "tecFAILED_PROCESSING"
	TecDIR_FULL              TxResultCode = "tecDIR_FULL"
	TecINSUF_RESERVE_LINE    TxResultCode = "tecINSUF_RESERVE_LINE"
	TecINSUF_RESERVE_OFFER   TxResultCode = "tecINSUF_RESERVE_OFFER"
	TecNO_DST                TxResultCode = "tecNO_DST"
	TecNO_DST_INSUF_XRP      TxResultCode = "tecNO_DST_INSUF_XRP"
	TecNO_LINE_INSUF_RESERVE TxResultCode = "tecNO_LINE_INSUF_RESERVE"
	TecNO_LINE_REDUNDANT     TxResultCode = "tecNO_LINE_REDUNDANT"
	TecPATH_DRY              TxResultCode = "tecPATH_DRY"
	TecUNFUNDED              TxResultCode = "tecUNFUNDED"
	TecNO_ALTERNATIVE_KEY    TxResultCode = "tecNO_ALTERNATIVE_KEY"
	TecNO_REGULAR_KEY        TxResultCode = "tecNO_REGULAR_KEY"
	TecOWNERS                TxResultCode = "tecOWNERS"
	TecNO_ISSUER             TxResultCode = "tecNO_ISSUER"
	TecNO_AUTH               TxResultCode = "tecNO_AUTH"
	TecNO_LINE               TxResultCode = "tecNO_LINE"
	TecINSUFF_FEE            TxResultCode = "tecINSUFF_FEE"
	TecFROZEN                TxResultCode = "tecFROZEN"
	TecNO_TARGET             TxResultCode = "tecNO_TARGET"
	TecNO_PERMISSION         TxResultCode = "tecNO_PERMISSION"
	TecNO_ENTRY              TxResultCode = "tecNO_ENTRY"
	TecINSUFFICIENT_RESERVE  TxResultCode = "tecINSUFFICIENT_RESERVE"
	TecNEED_MASTER_KEY       TxResultCode = "tecNEED_MASTER_KEY"
	TecDST_TAG_NEEDED        TxResultCode = "tecDST_TAG_NEEDED"
	TecINTERNAL              TxResultCode = "tecINTERNAL"
	TecOVERSIZE              TxResultCode = "tecOVERSIZE"
	TecCRYPTOCONDITION_ERROR TxResultCode = "tecCRYPTOCONDITION_ERROR"
	TecINVARIANT_FAILED      TxResultCode = "tecINVARIANT_FAILED"
	TecDUPLICATE             TxResultCode = "tecDUPLICATE"
	TecEXPIRED               TxResultCode = "tecEXPIRED"
	TecHAS_OBLIGATIONS       TxResultCode = "tecHAS_OBLIGATIONS"
	TecINSUFFICIENT_FUNDS    TxResultCode = "tecINSUFFICIENT_FUNDS"
	TecOBJECT_NOT_FOUND      TxResultCode = "tecOBJECT_NOT_FOUND"
	TecLOCKED                TxResultCode = "tecLOCKED"
	TecKILLED                TxResultCode = "tecKILLED"

	// Failure (tef) - transaction not applied, retry possible
	TefFAILURE          TxResultCode = "tefFAILURE"
	TefALREADY          TxResultCode = "tefALREADY"
	TefBAD_ADD_AUTH     TxResultCode = "tefBAD_ADD_AUTH"
	TefBAD_AUTH         TxResultCode = "tefBAD_AUTH"
	TefBAD_LEDGER       TxResultCode = "tefBAD_LEDGER"
	TefCREATED          TxResultCode = "tefCREATED"
	TefEXCEPTION        TxResultCode = "tefEXCEPTION"
	TefINTERNAL         TxResultCode = "tefINTERNAL"
	TefNO_AUTH_REQUIRED TxResultCode = "tefNO_AUTH_REQUIRED"
	TefPAST_SEQ         TxResultCode = "tefPAST_SEQ"
	TefWRONG_PRIOR      TxResultCode = "tefWRONG_PRIOR"
	TefMASTER_DISABLED  TxResultCode = "tefMASTER_DISABLED"
	TefMAX_LEDGER       TxResultCode = "tefMAX_LEDGER"
	TefBAD_SIGNATURE    TxResultCode = "tefBAD_SIGNATURE"
	TefBAD_QUORUM       TxResultCode = "tefBAD_QUORUM"
	TefINVARIANT_FAILED TxResultCode = "tefINVARIANT_FAILED"
	TefTOO_BIG          TxResultCode = "tefTOO_BIG"

	// Retry (ter) - not applied, retry later
	TerRETRY       TxResultCode = "terRETRY"
	TerFUNDS_SPENT TxResultCode = "terFUNDS_SPENT"
	TerINSUF_FEE_B TxResultCode = "terINSUF_FEE_B"
	TerNO_ACCOUNT  TxResultCode = "terNO_ACCOUNT"
	TerNO_AUTH     TxResultCode = "terNO_AUTH"
	TerNO_LINE     TxResultCode = "terNO_LINE"
	TerOWNERS      TxResultCode = "terOWNERS"
	TerPRE_SEQ     TxResultCode = "terPRE_SEQ"
	TerLAST        TxResultCode = "terLAST"
	TerNO_RIPPLE   TxResultCode = "terNO_RIPPLE"
	TerQUEUED      TxResultCode = "terQUEUED"

	// Malformed (tem) - invalid transaction format
	TemMALFORMED              TxResultCode = "temMALFORMED"
	TemBAD_AMOUNT             TxResultCode = "temBAD_AMOUNT"
	TemBAD_CURRENCY           TxResultCode = "temBAD_CURRENCY"
	TemBAD_EXPIRATION         TxResultCode = "temBAD_EXPIRATION"
	TemBAD_FEE                TxResultCode = "temBAD_FEE"
	TemBAD_ISSUER             TxResultCode = "temBAD_ISSUER"
	TemBAD_LIMIT              TxResultCode = "temBAD_LIMIT"
	TemBAD_OFFER              TxResultCode = "temBAD_OFFER"
	TemBAD_PATH               TxResultCode = "temBAD_PATH"
	TemBAD_PATH_LOOP          TxResultCode = "temBAD_PATH_LOOP"
	TemBAD_REGKEY             TxResultCode = "temBAD_REGKEY"
	TemBAD_SEQUENCE           TxResultCode = "temBAD_SEQUENCE"
	TemBAD_SIGNATURE          TxResultCode = "temBAD_SIGNATURE"
	TemBAD_SRC_ACCOUNT        TxResultCode = "temBAD_SRC_ACCOUNT"
	TemBAD_TRANSFER_RATE      TxResultCode = "temBAD_TRANSFER_RATE"
	TemBAD_TRANSFER_FEE       TxResultCode = "temBAD_TRANSFER_FEE"
	TemDST_IS_SRC             TxResultCode = "temDST_IS_SRC"
	TemDST_NEEDED             TxResultCode = "temDST_NEEDED"
	TemINVALID                TxResultCode = "temINVALID"
	TemINVALID_FLAG           TxResultCode = "temINVALID_FLAG"
	TemREDUNDANT              TxResultCode = "temREDUNDANT"
	TemRIPPLE_EMPTY           TxResultCode = "temRIPPLE_EMPTY"
	TemDISABLED               TxResultCode = "temDISABLED"
	TemBAD_SIGNER             TxResultCode = "temBAD_SIGNER"
	TemBAD_QUORUM             TxResultCode = "temBAD_QUORUM"
	TemBAD_WEIGHT             TxResultCode = "temBAD_WEIGHT"
	TemBAD_TICK_SIZE          TxResultCode = "temBAD_TICK_SIZE"
	TemINVALID_ACCOUNT_ID     TxResultCode = "temINVALID_ACCOUNT_ID"
	TemUNCERTAIN              TxResultCode = "temUNCERTAIN"
	TemUNKNOWN                TxResultCode = "temUNKNOWN"
	TemSEQ_AND_TICKET         TxResultCode = "temSEQ_AND_TICKET"
	TemBAD_SEND_XRP_PATHS     TxResultCode = "temBAD_SEND_XRP_PATHS"
	TemBAD_SEND_XRP_MAX       TxResultCode = "temBAD_SEND_XRP_MAX"
	TemBAD_SEND_XRP_PARTIAL   TxResultCode = "temBAD_SEND_XRP_PARTIAL"
	TemBAD_SEND_XRP_NO_DIRECT TxResultCode = "temBAD_SEND_XRP_NO_DIRECT"
)

Transaction result codes for use in assertions.

Directories

Path Synopsis
Package amm provides test builders for AMM transactions.
Package amm provides test builders for AMM transactions.
Package batch provides test builder helpers for Batch transactions.
Package batch provides test builder helpers for Batch transactions.
Package conformance provides a test runner for xrpl-fixtures test vectors.
Package conformance provides a test runner for xrpl-fixtures test vectors.
Package consensus provides integration test utilities for multi-node consensus testing.
Package consensus provides integration test utilities for multi-node consensus testing.
Package depositpreauth provides fluent transaction builder helpers for DepositPreauth testing, plus integration tests matching rippled's DepositAuth_test.cpp and DepositPreauth_test sections.
Package depositpreauth provides fluent transaction builder helpers for DepositPreauth testing, plus integration tests matching rippled's DepositAuth_test.cpp and DepositPreauth_test sections.
Package metadata provides test helpers for validating transaction metadata.
Package metadata provides test helpers for validating transaction metadata.
Package mpt provides test helpers for MPT (Multi-Purpose Token) transaction testing.
Package mpt provides test helpers for MPT (Multi-Purpose Token) transaction testing.
Package builders provides fluent transaction builder helpers for testing.
Package builders provides fluent transaction builder helpers for testing.
Package permissioneddex provides test helpers for PermissionedDEX tests.
Package permissioneddex provides test helpers for PermissionedDEX tests.
Package ticket provides test helpers for Ticket transaction testing.
Package ticket provides test helpers for Ticket transaction testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL