testutils

package
v2.13.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FixtureChainID = big.NewInt(0)

FixtureChainID matches the chain always added by fixtures.sql It is set to 0 since no real chain ever has this ID and allows a virtual "test" chain ID to be used without clashes

View Source
var SimulatedChainID = big.NewInt(1337)

SimulatedChainID is the chain ID for the go-ethereum simulated backend

Functions

func Head(val interface{}) *evmtypes.Head

Head given the value convert it into an Head

func NewAddress

func NewAddress() common.Address

NewAddress return a random new address

func NewAddressPtr added in v2.13.0

func NewAddressPtr() *common.Address

func NewEthClientMock

func NewEthClientMock(t *testing.T) *evmclmocks.Client

func NewEthClientMockWithDefaultChain

func NewEthClientMockWithDefaultChain(t *testing.T) *evmclmocks.Client

func NewHash added in v2.13.0

func NewHash() common.Hash

NewHash return random Keccak256

func NewLegacyTransaction

func NewLegacyTransaction(nonce uint64, to common.Address, value *big.Int, gasLimit uint32, gasPrice *big.Int, data []byte) *types.Transaction

func NewRandomEVMChainID

func NewRandomEVMChainID() *big.Int

NewRandomEVMChainID returns a suitable random chain ID that will not conflict with fixtures

func NewTestChainScopedConfig

func NewTestChainScopedConfig(t testing.TB, overrideFn func(c *toml.EVMConfig)) config.ChainScopedConfig

func NewWSServer

func NewWSServer(t *testing.T, chainID *big.Int, callback JSONRPCHandler) (ts *testWSServer)

NewWSServer starts a websocket server which invokes callback for each message received. If chainID is set, then eth_chainId calls will be automatically handled.

func WSServerURL

func WSServerURL(t *testing.T, s *httptest.Server) *url.URL

WSServerURL returns a ws:// url for the server

Types

type Awaiter

type Awaiter chan struct{}

func NewAwaiter

func NewAwaiter() Awaiter

func (Awaiter) AssertHappened

func (a Awaiter) AssertHappened(t *testing.T, expected bool)

func (Awaiter) AwaitOrFail

func (a Awaiter) AwaitOrFail(t testing.TB, durationParams ...time.Duration)

func (Awaiter) ItHappened

func (a Awaiter) ItHappened()

type JSONRPCHandler

type JSONRPCHandler func(reqMethod string, reqParams gjson.Result) JSONRPCResponse

JSONRPCHandler is called with the method and request param(s). respResult will be sent immediately. notifyResult is optional, and sent after a short delay.

type JSONRPCResponse

type JSONRPCResponse struct {
	Result, Notify string // raw JSON (i.e. quoted strings etc.)

	Error struct {
		Code    int
		Message string
	}
}

type MockEth added in v2.13.0

type MockEth struct {
	EthClient       *evmclmocks.Client
	CheckFilterLogs func(int64, int64)
	// contains filtered or unexported fields
}

func (*MockEth) NewSub added in v2.13.0

func (m *MockEth) NewSub(t *testing.T) ethereum.Subscription

func (*MockEth) SubsErr added in v2.13.0

func (m *MockEth) SubsErr(err error)

func (*MockEth) SubscribeCallCount added in v2.13.0

func (m *MockEth) SubscribeCallCount() int32

func (*MockEth) UnsubscribeCallCount added in v2.13.0

func (m *MockEth) UnsubscribeCallCount() int32

type RawSub added in v2.13.0

type RawSub[T any] struct {
	// contains filtered or unexported fields
}

func NewRawSub added in v2.13.0

func NewRawSub[T any](ch chan<- T, err <-chan error) RawSub[T]

func (*RawSub[T]) CloseCh added in v2.13.0

func (r *RawSub[T]) CloseCh()

func (*RawSub[T]) TrySend added in v2.13.0

func (r *RawSub[T]) TrySend(t T)

Jump to

Keyboard shortcuts

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