Documentation
¶
Overview ¶
Package hookstest provides test doubles and convenience wrappers for testing libevm hooks.
Index ¶
- func Register[C params.ChainConfigHooks, R params.RulesHooks](tb testing.TB, extras params.Extras[C, R]) params.ExtraPayloads[C, R]
- type Stub
- func (s Stub) ActivePrecompiles(active []common.Address) []common.Address
- func (s Stub) CanCreateContract(cc *libevm.AddressContext, gas uint64, sr libevm.StateReader) (uint64, error)
- func (s Stub) CanExecuteTransaction(from common.Address, to *common.Address, sr libevm.StateReader) error
- func (s Stub) CheckConfigCompatible(newcfg *params.ChainConfig, headNumber *big.Int, headTimestamp uint64) *params.ConfigCompatError
- func (s Stub) CheckConfigForkOrder() error
- func (s Stub) Description() string
- func (s Stub) PrecompileOverride(a common.Address) (libevm.PrecompiledContract, bool)
- func (s *Stub) Register(tb testing.TB) params.ExtraPayloads[*Stub, *Stub]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register[C params.ChainConfigHooks, R params.RulesHooks](tb testing.TB, extras params.Extras[C, R]) params.ExtraPayloads[C, R]
Register clears any registered params.Extras and then registers `extras` for the lifetime of the current test, clearing them via tb's testing.TB.Cleanup.
Types ¶
type Stub ¶
type Stub struct { CheckConfigForkOrderFn func() error CheckConfigCompatibleFn func(*params.ChainConfig, *big.Int, uint64) *params.ConfigCompatError DescriptionSuffix string PrecompileOverrides map[common.Address]libevm.PrecompiledContract ActivePrecompilesFn func([]common.Address) []common.Address CanExecuteTransactionFn func(common.Address, *common.Address, libevm.StateReader) error CanCreateContractFn func(*libevm.AddressContext, uint64, libevm.StateReader) (uint64, error) }
A Stub is a test double for params.ChainConfigHooks and params.RulesHooks. Each of the fields, if non-nil, back their respective hook methods, which otherwise fall back to the default behaviour.
func (Stub) ActivePrecompiles ¶
ActivePrecompiles proxies arguments to the s.ActivePrecompilesFn function if non-nil, otherwise it acts as a noop.
func (Stub) CanCreateContract ¶
func (s Stub) CanCreateContract(cc *libevm.AddressContext, gas uint64, sr libevm.StateReader) (uint64, error)
CanCreateContract proxies arguments to the s.CanCreateContractFn function if non-nil, otherwise it acts as a noop.
func (Stub) CanExecuteTransaction ¶
func (s Stub) CanExecuteTransaction(from common.Address, to *common.Address, sr libevm.StateReader) error
CanExecuteTransaction proxies arguments to the s.CanExecuteTransactionFn function if non-nil, otherwise it acts as a noop.
func (Stub) CheckConfigCompatible ¶
func (s Stub) CheckConfigCompatible(newcfg *params.ChainConfig, headNumber *big.Int, headTimestamp uint64) *params.ConfigCompatError
CheckConfigCompatible proxies arguments to the s.CheckConfigCompatibleFn function if non-nil, otherwise it acts as a noop.
func (Stub) CheckConfigForkOrder ¶
CheckConfigForkOrder proxies arguments to the s.CheckConfigForkOrderFn function if non-nil, otherwise it acts as a noop.
func (Stub) Description ¶
Description returns s.DescriptionSuffix.
func (Stub) PrecompileOverride ¶
PrecompileOverride uses the s.PrecompileOverrides map, if non-empty, as the canonical source of all overrides. If the map is empty then no precompiles are overridden.
func (*Stub) Register ¶
Register is a convenience wrapper for registering s as both the params.ChainConfigHooks and params.RulesHooks via Register.