ethtest

package
v1.13.14-0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ethtest provides utility functions for use in testing Ethereum-related functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewZeroEVM

func NewZeroEVM(tb testing.TB, opts ...EVMOption) (*state.StateDB, *vm.EVM)

NewZeroEVM returns a new EVM backed by a rawdb.NewMemoryDatabase; all other arguments to vm.NewEVM are the zero values of their respective types, except for the use of core.CanTransfer and core.Transfer instead of nil functions.

Types

type EVMOption

type EVMOption interface {
	// contains filtered or unexported methods
}

An EVMOption configures the EVM returned by NewZeroEVM.

func WithBlockContext

func WithBlockContext(c vm.BlockContext) EVMOption

WithBlockContext overrides the default context.

func WithChainConfig

func WithChainConfig(c *params.ChainConfig) EVMOption

WithBlockContext overrides the default context.

type PseudoRand

type PseudoRand struct {
	*rand.Rand
}

PseudoRand extends rand.Rand (*not* crypto/rand).

func NewPseudoRand

func NewPseudoRand(seed uint64) *PseudoRand

NewPseudoRand returns a new PseudoRand with the given seed.

func (*PseudoRand) Address

func (r *PseudoRand) Address() (a common.Address)

Address returns a pseudorandom address.

func (*PseudoRand) AddressPtr

func (r *PseudoRand) AddressPtr() *common.Address

AddressPtr returns a pointer to a pseudorandom address.

func (*PseudoRand) BigUint64

func (r *PseudoRand) BigUint64() *big.Int

Big returns rand.Rand.Uint64 as a big.Int.

func (*PseudoRand) Bytes

func (r *PseudoRand) Bytes(n uint) []byte

Bytes returns `n` pseudorandom bytes.

func (*PseudoRand) Hash

func (r *PseudoRand) Hash() (h common.Hash)

Hash returns a pseudorandom hash.

func (*PseudoRand) HashPtr

func (r *PseudoRand) HashPtr() *common.Hash

HashPtr returns a pointer to a pseudorandom hash.

func (*PseudoRand) Read

func (r *PseudoRand) Read(p []byte) int

Read is equivalent to rand.Rand.Read except that it doesn't return an error because it is guaranteed to be nil.

func (*PseudoRand) Uint256

func (r *PseudoRand) Uint256() *uint256.Int

Uint256 returns a random 256-bit unsigned int.

func (*PseudoRand) Uint64Ptr

func (r *PseudoRand) Uint64Ptr() *uint64

Uint64Ptr returns a pointer to a pseudorandom uint64.

Jump to

Keyboard shortcuts

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