mode

package
v0.1.101 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAll

func GetAll() map[string]Runner

GetAll returns all registered modes (by canonical name only).

func GetRandomAddress

func GetRandomAddress(deps *Dependencies) *common.Address

GetRandomAddress generates a random Ethereum address using the given random source.

func NewHexwordReader

func NewHexwordReader(deps *Dependencies) io.Reader

NewHexwordReader creates a new hexword reader with the given random source.

func OutputRawBytes

func OutputRawBytes(rawTx []byte) error

OutputRawBytes outputs raw bytes as a 0x-prefixed hex string to stdout.

func OutputRawTransaction

func OutputRawTransaction(tx *types.Transaction) error

OutputRawTransaction outputs a raw signed transaction as hex.

func Register

func Register(mode Runner)

Register adds a mode to the registry.

func TransactOptsToCallMsg

func TransactOptsToCallMsg(cfg *config.Config, gasLimit uint64) ethereum.CallMsg

TransactOptsToCallMsg converts bind.TransactOpts to an ethereum.CallMsg.

func TxToCallMsg

func TxToCallMsg(cfg *config.Config, tx *types.Transaction) ethereum.CallMsg

TxToCallMsg converts a transaction to an ethereum.CallMsg.

Types

type Dependencies

type Dependencies struct {
	// Ethereum clients
	Client    *ethclient.Client
	RPCClient *ethrpc.Client

	// Contract instances
	LoadTesterContract *tester.LoadTester
	LoadTesterAddress  common.Address
	ERC20Contract      *tokens.ERC20
	ERC20Address       common.Address
	ERC721Contract     *tokens.ERC721
	ERC721Address      common.Address

	// Mode-specific data
	RecallTransactions []rpctypes.PolyTransaction
	IndexedActivity    *IndexedActivity

	// Random source for deterministic randomness
	RandSource   *rand.Rand
	RandSourceMu sync.Mutex

	// UniswapV3 configuration (populated when uniswapv3 mode is used)
	UniswapV3Config     *uniswap.UniswapV3Config
	UniswapV3PoolConfig *uniswap.PoolConfig
	UniswapV3Pool       *uniswapv3.IUniswapV3Pool
}

Dependencies holds shared resources needed by mode implementations.

func (*Dependencies) RandIntn

func (d *Dependencies) RandIntn(n int) int

RandIntn returns a deterministic random int while guarding concurrent access.

func (*Dependencies) RandRead

func (d *Dependencies) RandRead(p []byte) (int, error)

RandRead fills p with deterministic random data while guarding concurrent access.

type HexwordReader

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

HexwordReader provides a reader that generates hex-word patterns.

func (*HexwordReader) Read

func (h *HexwordReader) Read(p []byte) (n int, err error)

type IndexedActivity

type IndexedActivity struct {
	BlockNumbers    []string
	TransactionIDs  []string
	BlockIDs        []string
	Addresses       []string
	ERC20Addresses  []string
	ERC721Addresses []string
	Contracts       []string
	BlockNumber     uint64
	Transactions    []rpctypes.PolyTransaction
}

IndexedActivity holds indexed blockchain activity data for RPC testing.

type Runner

type Runner interface {
	// Name returns the canonical name of the mode.
	Name() string

	// Aliases returns alternative names/shortcuts for this mode.
	Aliases() []string

	// RequiresContract returns true if this mode needs the LoadTester contract.
	RequiresContract() bool

	// RequiresERC20 returns true if this mode needs an ERC20 contract.
	RequiresERC20() bool

	// RequiresERC721 returns true if this mode needs an ERC721 contract.
	RequiresERC721() bool

	// Init sets up any mode-specific state before execution.
	Init(ctx context.Context, cfg *config.Config, deps *Dependencies) error

	// Execute performs a single load test operation.
	// Returns start time, end time, transaction hash, and any error.
	Execute(ctx context.Context, cfg *config.Config, deps *Dependencies, opts *bind.TransactOpts) (start, end time.Time, txHash common.Hash, err error)
}

Runner defines the interface that all load test modes must implement.

func Get

func Get(name string) (Runner, error)

Get retrieves a mode by name or alias. First tries exact match (for case-sensitive aliases like "r" vs "R"), then falls back to lowercase match (for canonical names).

Jump to

Keyboard shortcuts

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