testing

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const TestNetworkPassphrase = "Test SDF Network ; September 2015"

TestNetworkPassphrase is the passphrase used for testing

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBuilder

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

AccountBuilder helps construct mock account responses

func NewAccount

func NewAccount(address string) *AccountBuilder

NewAccount creates a new account builder

func (*AccountBuilder) Build

Build returns the constructed account

func (*AccountBuilder) WithSequence

func (b *AccountBuilder) WithSequence(seq int64) *AccountBuilder

WithSequence sets the account sequence

type GetTransactionResponseBuilder

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

GetTransactionResponseBuilder helps construct mock get transaction responses

func NewGetTransactionResponse

func NewGetTransactionResponse() *GetTransactionResponseBuilder

NewGetTransactionResponse creates a new get transaction response builder

func (*GetTransactionResponseBuilder) Build

Build returns the constructed response

func (*GetTransactionResponseBuilder) WithLedger

WithLedger sets the ledger number

func (*GetTransactionResponseBuilder) WithResultXDR

WithResultXDR sets the result XDR

func (*GetTransactionResponseBuilder) WithStatus

WithStatus sets the transaction status

type MockRPCClient

type MockRPCClient struct {
	// Function hooks - set these to customize behavior in tests
	LoadAccountFunc         func(ctx context.Context, address string) (txnbuild.Account, error)
	SimulateTransactionFunc func(ctx context.Context, req protocol.SimulateTransactionRequest) (protocol.SimulateTransactionResponse, error)
	SendTransactionFunc     func(ctx context.Context, req protocol.SendTransactionRequest) (protocol.SendTransactionResponse, error)
	GetTransactionFunc      func(ctx context.Context, req protocol.GetTransactionRequest) (protocol.GetTransactionResponse, error)
	GetLedgerEntriesFunc    func(ctx context.Context, req protocol.GetLedgerEntriesRequest) (protocol.GetLedgerEntriesResponse, error)

	// Call tracking
	LoadAccountCalls         []string
	SimulateTransactionCalls []protocol.SimulateTransactionRequest
	SendTransactionCalls     []protocol.SendTransactionRequest
	GetTransactionCalls      []protocol.GetTransactionRequest
}

MockRPCClient is a mock implementation of the Stellar RPC client for testing

func NewMockRPCClient

func NewMockRPCClient() *MockRPCClient

NewMockRPCClient creates a new mock RPC client with default implementations

func (*MockRPCClient) GetLedgerEntries

GetLedgerEntries mocks the GetLedgerEntries method

func (*MockRPCClient) GetTransaction

GetTransaction mocks the GetTransaction method

func (*MockRPCClient) LoadAccount

func (m *MockRPCClient) LoadAccount(ctx context.Context, address string) (txnbuild.Account, error)

LoadAccount mocks the LoadAccount method

func (*MockRPCClient) Reset

func (m *MockRPCClient) Reset()

Reset clears all call tracking

func (*MockRPCClient) SendTransaction

SendTransaction mocks the SendTransaction method

func (*MockRPCClient) SimulateTransaction

SimulateTransaction mocks the SimulateTransaction method

type SendTransactionResponseBuilder

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

SendTransactionResponseBuilder helps construct mock send transaction responses

func NewSendTransactionResponse

func NewSendTransactionResponse() *SendTransactionResponseBuilder

NewSendTransactionResponse creates a new send transaction response builder

func (*SendTransactionResponseBuilder) Build

Build returns the constructed response

func (*SendTransactionResponseBuilder) WithError

WithError sets an error on the response

func (*SendTransactionResponseBuilder) WithHash

WithHash sets the transaction hash

func (*SendTransactionResponseBuilder) WithStatus

WithStatus sets the transaction status

type SimulationResponseBuilder

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

SimulationResponseBuilder helps construct mock simulation responses

func NewSimulationResponse

func NewSimulationResponse() *SimulationResponseBuilder

NewSimulationResponse creates a new simulation response builder

func (*SimulationResponseBuilder) Build

Build returns the constructed simulation response

func (*SimulationResponseBuilder) WithAddressResult

func (b *SimulationResponseBuilder) WithAddressResult(address string) *SimulationResponseBuilder

WithAddressResult adds an address result to the simulation

func (*SimulationResponseBuilder) WithAuth

WithAuth adds mock auth entries for transaction signing

func (*SimulationResponseBuilder) WithBoolResult

func (b *SimulationResponseBuilder) WithBoolResult(value bool) *SimulationResponseBuilder

WithBoolResult adds a bool result to the simulation

func (*SimulationResponseBuilder) WithError

WithError sets an error on the simulation response

func (*SimulationResponseBuilder) WithI128Result

func (b *SimulationResponseBuilder) WithI128Result(value int64) *SimulationResponseBuilder

WithI128Result adds an i128 result to the simulation

func (*SimulationResponseBuilder) WithMinResourceFee

func (b *SimulationResponseBuilder) WithMinResourceFee(fee int64) *SimulationResponseBuilder

WithMinResourceFee sets the minimum resource fee

func (*SimulationResponseBuilder) WithTransactionData

func (b *SimulationResponseBuilder) WithTransactionData() *SimulationResponseBuilder

WithTransactionData adds mock transaction data for submission

func (*SimulationResponseBuilder) WithU64Result

WithU64Result adds a u64 result to the simulation

type TestKeys

type TestKeys struct {
	TreasurySecret string
	TreasuryPublic string
	AdminSecret    string
	AdminPublic    string
	UserSecret     string
	UserPublic     string
	ContractID     string
}

TestKeys contains test keypairs for testing

func NewTestKeys

func NewTestKeys() *TestKeys

NewTestKeys returns a set of valid test keys These are deterministic keys for testing only

Jump to

Keyboard shortcuts

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