testengine

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testengine runs op-reth-test-engine, the Rust OP Stack execution engine that Go tests drive over a Unix domain socket: it locates the binary, spawns it over a genesis file behind a typed client, and builds the minimal chains and blocks its own tests drive it with.

Index

Constants

View Source
const BinaryName = "op-reth-test-engine"

BinaryName is the name of the engine's binary and of the cargo package that builds it in the monorepo's rust/ workspace.

Variables

View Source
var ErrNotConfigured = errors.New("engine binary not configured")

ErrNotConfigured is wrapped by the error ResolveBinary returns when no binary is configured, built, or requested to be built. The error's message says how to provide one; callers for which the engine is optional can skip on it.

Functions

func ResolveBinary

func ResolveBinary(ctx context.Context) (string, error)

ResolveBinary returns the path of the op-reth-test-engine binary. See resolveBinary for the environment it reads and the order it looks in.

Types

type Client

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

Client is a thin typed client for an op-reth-test-engine process: the Engine API methods the tests drive directly, the engine's optest_ namespace, and the raw RPC client for everything else.

func Spawn

func Spawn(binPath, genesisPath string, logw io.Writer) (*Client, error)

Spawn starts the engine binary at binPath over the L2 genesis JSON at genesisPath and dials its socket. The engine's stderr is forwarded to logw. The returned Client owns the process and must be closed.

func (*Client) Close

func (c *Client) Close()

Close stops the engine process. It is idempotent.

func (*Client) DumpAccounts

func (c *Client) DumpAccounts(ctx context.Context, blockHash common.Hash, addrs []common.Address) (types.GenesisAlloc, error)

DumpAccounts returns the state of the given accounts at the block with the given hash (optest_dumpAccounts): nonce, balance, code and non-zero storage. Accounts that do not exist at that block are absent from the result.

func (*Client) ForcedEmpty

func (c *Client) ForcedEmpty(ctx context.Context) (bool, error)

ForcedEmpty reports whether the block being built is force-empty (optest_forcedEmpty).

func (*Client) ForkchoiceUpdated

func (c *Client) ForkchoiceUpdated(ctx context.Context, method eth.EngineAPIMethod, state eth.ForkchoiceState, attrs *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)

ForkchoiceUpdated calls method, a version of engine_forkchoiceUpdated; attrs may be nil.

func (*Client) GetPayload

GetPayload calls method, a version of engine_getPayload.

func (*Client) IncludeNextTx

func (c *Client) IncludeNextTx(ctx context.Context, from common.Address) (*IncludeNextTxResult, error)

IncludeNextTx executes the parked transaction from `from` with the account's next nonce into the block being built (optest_includeNextTx). eth_sendRawTransaction parks transactions.

func (*Client) IncludeTx

func (c *Client) IncludeTx(ctx context.Context, raw hexutil.Bytes) (*IncludeTxResult, error)

IncludeTx executes the encoded transaction raw into the block being built (optest_includeTx). It returns a nil result if the block is force-empty, which drops the transaction.

func (*Client) NewPayload

func (c *Client) NewPayload(ctx context.Context, method eth.EngineAPIMethod, payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash) (*eth.PayloadStatusV1, error)

NewPayload calls method, a version of engine_newPayload, with the parameters that version takes, as op-node sends them: V3 adds empty blob versioned hashes and parentBeaconBlockRoot, V4 empty execution requests.

func (*Client) RPC

func (c *Client) RPC() *rpc.Client

RPC returns the raw RPC client, for the eth_ namespace and for go-ethereum's and op-node's clients. It is valid until Close.

func (*Client) RemainingBlockGas

func (c *Client) RemainingBlockGas(ctx context.Context) (uint64, error)

RemainingBlockGas returns the gas still available in the block being built (optest_remainingBlockGas).

func (*Client) SetForceEmpty

func (c *Client) SetForceEmpty(ctx context.Context, forced bool) error

SetForceEmpty sets the force-empty flag of the block being built (optest_setForceEmpty).

func (*Client) SocketPath

func (c *Client) SocketPath() string

SocketPath returns the path of the engine's Unix socket, for processes that dial the engine themselves, such as kona-host. It is valid until Close.

type IncludeNextTxResult

type IncludeNextTxResult struct {
	TxHash  *common.Hash `json:"txHash"`
	GasUsed uint64       `json:"gasUsed"`
	// Skipped reports that the block is force-empty, which drops the transaction.
	Skipped bool `json:"skipped"`
	// NoTx reports that no parked transaction from the account has the next nonce.
	NoTx bool `json:"noTx"`
}

IncludeNextTxResult is the result of including the next parked transaction from an account in the block being built: exactly one of TxHash, Skipped and NoTx is set.

type IncludeTxResult

type IncludeTxResult struct {
	TxHash  common.Hash `json:"txHash"`
	GasUsed uint64      `json:"gasUsed"`
}

IncludeTxResult is the result of including a transaction in the block being built.

Directories

Path Synopsis
Package chainfixture is a fixed test chain for driving a testengine process directly: a chain id, a chain config with every OP Stack fork active at genesis, a genesis writer and helpers that build blocks over the engine API.
Package chainfixture is a fixed test chain for driving a testengine process directly: a chain id, a chain config with every OP Stack fork active at genesis, a genesis writer and helpers that build blocks over the engine API.

Jump to

Keyboard shortcuts

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