simulated

package
v2.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: GPL-3.0, LGPL-3.0 Imports: 11 Imported by: 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBlockGasLimit

func WithBlockGasLimit(gaslimit uint64) func(ethConf *ethconfig.Config)

WithBlockGasLimit configures the simulated backend to target a specific gas limit when producing blocks.

func WithCallGasLimit

func WithCallGasLimit(gaslimit uint64) func(ethConf *ethconfig.Config)

WithCallGasLimit configures the simulated backend to cap eth_calls to a specific gas limit when running client operations.

Types

type Backend

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

Backend is a simulated blockchain for testing.

func NewBackend

func NewBackend(alloc types.GenesisAlloc, options ...func(*ethconfig.Config)) *Backend

NewBackend creates a new simulated backend.

func (*Backend) AdjustTime

func (b *Backend) AdjustTime(adjustment time.Duration) error

AdjustTime changes the block timestamp.

func (*Backend) Client

func (b *Backend) Client() Client

Client returns the underlying client.

func (*Backend) Close

func (b *Backend) Close() error

Close shuts down the backend.

func (*Backend) Commit

func (b *Backend) Commit(accept bool) common.Hash

Commit seals a block and moves the chain forward.

func (*Backend) Fork

func (b *Backend) Fork(parentHash common.Hash) error

Fork creates a side-chain for reorg testing.

func (*Backend) Rollback

func (b *Backend) Rollback()

Rollback removes all pending transactions.

type Client

type Client interface {
	bind.ContractBackend
	Close()
	ChainID(context.Context) (*big.Int, error)
	BlockByNumber(context.Context, *big.Int) (*types.Block, error)
	BlockNumber(context.Context) (uint64, error)
	HeaderByHash(context.Context, common.Hash) (*types.Header, error)
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
	TransactionByHash(context.Context, common.Hash) (*types.Transaction, bool, error)
	BalanceAt(context.Context, common.Address, *big.Int) (*big.Int, error)
	NonceAt(context.Context, common.Address, *big.Int) (uint64, error)
	SuggestGasPrice(context.Context) (*big.Int, error)
	EstimateBaseFee(context.Context) (*big.Int, error)
}

Client exposes the methods provided by the Ethereum RPC client.

Jump to

Keyboard shortcuts

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