testutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package testutil provides utilities for testing the RFQ relayer. TODO: deduplicate w/ rfq/quoting-api/testutil & combine these into one package

Package testutil implements utilities for testing the RFQ Quoter. TODO: deduplicate with

Index

Constants

View Source
const (
	// AnvilMaxRetries is the maximum number of times to retry creating an Anvil backend.
	AnvilMaxRetries = 3
	// AnvilMaxTimeToWait is the maximum time to wait for an Anvil backend to be created.
	AnvilMaxTimeToWait = 3
)
View Source
const (
	// DefaultMintAmount is the default amount of tokens to mint.
	DefaultMintAmount = params.Ether
	// NumberOfTokens is the number of tokens to create.
	NumberOfTokens = 2
)

Variables

This section is empty.

Functions

func GenerateTestLog

func GenerateTestLog() *types.Log

GenerateTestLog generates a test log.

func NewAnvilBackend

func NewAnvilBackend(ctx context.Context, t *testing.T, chainID uint32) backends.SimulatedTestBackend

NewAnvilBackend creates a new instance of the Anvil backend with a given chain. Because NewAnvilBackend sometimes fails or times out, it will retry a few times if it does not return within 5 seconds.

func NewEVMClientFromAnvil

func NewEVMClientFromAnvil(ctx context.Context, backend backends.SimulatedTestBackend, handler metrics.Handler) (client.EVM, error)

NewEVMClientFromAnvil creates a new instance of the EVM client with a given (anvil) backend.

Types

type ITestContractHandler

type ITestContractHandler interface {
	// ChainID returns the chain ID of the contract handler.
	ChainID() uint32
	// FastBridgeAddress returns the address of the fast bridge contract.
	FastBridgeAddress() common.Address
	// Tokens returns the list of tokens.
	Tokens() []TokenContract
	// FBExecuteBridge executes the bridge function on the fast bridge contract.
	FBExecuteBridge(ctx context.Context, bridgeParams bindings.IFastBridgeBridgeParams) (*types.Transaction, error)
	// FBExecuteRelay executes the relay function on the fast bridge contract.
	FBExecuteRelay(ctx context.Context, request []byte) (*types.Transaction, error)
	// FBExecuteProve executes the prove function on the fast bridge contract.
	FBExecuteProve(ctx context.Context, request []byte, destTxHash [32]byte) (*types.Transaction, error)
	// FBExecuteClaim executes the claim function on the fast bridge contract. Will likely be unused.
	FBExecuteClaim(ctx context.Context, request []byte, to common.Address) (*types.Transaction, error)
}

ITestContractHandler is the interface for the handling contracts on a given chain.

func NewTestContractHandlerImpl

func NewTestContractHandlerImpl(ctx context.Context, anvilBackend backends.SimulatedTestBackend, testWallet wallet.Wallet, chainID uint32) (ITestContractHandler, error)

NewTestContractHandlerImpl creates a new instance of the ITestContractHandler interface.

type TestContractHandlerImpl

type TestContractHandlerImpl struct {
	// contains filtered or unexported fields
}

TestContractHandlerImpl is the implementation of the ITestContractHandler interface.

func (*TestContractHandlerImpl) ChainID

func (t *TestContractHandlerImpl) ChainID() uint32

ChainID returns the chain ID of the contract handler.

func (*TestContractHandlerImpl) FBExecuteBridge

FBExecuteBridge executes the bridge function on the fast bridge contract.

func (*TestContractHandlerImpl) FBExecuteClaim

func (t *TestContractHandlerImpl) FBExecuteClaim(ctx context.Context, request []byte, to common.Address) (*types.Transaction, error)

FBExecuteClaim executes the claim function on the fast bridge contract. Will likely be unused.

func (*TestContractHandlerImpl) FBExecuteProve

func (t *TestContractHandlerImpl) FBExecuteProve(ctx context.Context, request []byte, destTxHash [32]byte) (*types.Transaction, error)

FBExecuteProve executes the prove function on the fast bridge contract.

func (*TestContractHandlerImpl) FBExecuteRelay

func (t *TestContractHandlerImpl) FBExecuteRelay(ctx context.Context, request []byte) (*types.Transaction, error)

FBExecuteRelay executes the relay function on the fast bridge contract.

func (*TestContractHandlerImpl) FastBridgeAddress

func (t *TestContractHandlerImpl) FastBridgeAddress() common.Address

FastBridgeAddress returns the address of the fast bridge contract.

func (*TestContractHandlerImpl) Tokens

func (t *TestContractHandlerImpl) Tokens() []TokenContract

Tokens returns the list of tokens.

type TokenContract

type TokenContract struct {
	Erc20Address  common.Address
	Erc20Contract *bindings.MockERC20
}

TokenContract is a struct containing the address and contract of a token.

Jump to

Keyboard shortcuts

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