testutils

package
v2.12.0-xlayer-05012024 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 24 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 NewEthClientMock

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

func NewEthClientMockWithDefaultChain

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

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
	}
}

Jump to

Keyboard shortcuts

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