Documentation ¶
Overview ¶
Package ethtest provides utility functions for use in testing Ethereum-related functionality.
Index ¶
- func NewZeroEVM(tb testing.TB, opts ...EVMOption) (*state.StateDB, *vm.EVM)
- type EVMOption
- type PseudoRand
- func (r *PseudoRand) Address() (a common.Address)
- func (r *PseudoRand) AddressPtr() *common.Address
- func (r *PseudoRand) BigUint64() *big.Int
- func (r *PseudoRand) Bytes(n uint) []byte
- func (r *PseudoRand) Hash() (h common.Hash)
- func (r *PseudoRand) HashPtr() *common.Hash
- func (r *PseudoRand) Read(p []byte) int
- func (r *PseudoRand) Uint256() *uint256.Int
- func (r *PseudoRand) Uint64Ptr() *uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewZeroEVM ¶
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 ¶
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.