testutil

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package testutil contains utilities for testing the RFQ service.

Index

Constants

View Source
const (
	// FastBridgeType is the type of the fast bridge contract.
	FastBridgeType contractTypeImpl = iota + 1 // FastBridge
	// MockERC20Type is a mock erc20 contract.
	MockERC20Type // MockERC20
	// FastBridgeMockType is a mock contract for testing fast bridge interactions
	// TODO: rename  contract to MockFastBridge.
	FastBridgeMockType // FastBridgeMock
	// WETH9Type  is the weth 9 contract.
	WETH9Type // WETH9
	// USDTType is the tether type.
	USDTType // USDT
	// USDCType is the type of the usdc contract.
	USDCType // USDC
	// DAIType is the dai contract.
	DAIType // DAI
)
View Source
const MockERC20Decimals uint8 = 10

MockERC20Decimals is the default number of mock erc20 decimals.

View Source
const MockERC20Name = "token"

MockERC20Name is the name of hte mock erc20.

Variables

View Source
var AllContractTypes []contractTypeImpl

AllContractTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.

Functions

func AdjustAmount

func AdjustAmount(ctx context.Context, amount *big.Int, handler interface{}) (res *big.Int, err error)

AdjustAmount multiplies a token by the number of decimals in the amount. this does not use an interface with a Decimals() methods since usdt returns a (non-erc 20 compliant) *big.Int rather than a uint8 for decimals. If the handler is determined to be usdt (via a type switch) that decimals method is called, otherwise the standard decimals method is called.

func GetDecimals

func GetDecimals(ctx context.Context, handler interface{}) (res uint8, err error)

GetDecimals gets decimals from token that adheres to either the tether or the erc-20 standard.

func MustAdjustAmount

func MustAdjustAmount(ctx context.Context, tb testing.TB, amount *big.Int, handler interface{}) (res *big.Int)

MustAdjustAmount multiplies a token by the number of decimals in the amount. see AdjustAmount.

func NewDAIDeployer

NewDAIDeployer creates a new deployer for dai.

func NewFastBridgeDeployer

NewFastBridgeDeployer deploys a fast bridge contract.

func NewMockERC20Deployer

NewMockERC20Deployer creates a new mock erc20 deployer.

func NewMockFastBridgeDeployer

func NewMockFastBridgeDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer

NewMockFastBridgeDeployer deploys a mock fast bridge contract.

func NewUSDCDeployer

NewUSDCDeployer creates a new deployer for tether.

func NewUSDTDeployer

NewUSDTDeployer creates a new deployer for tether.

func NewWETH9Deployer

NewWETH9Deployer creates a new deployer for weth9.

Types

type BigIntDecimalHandler

type BigIntDecimalHandler interface {
	// Decimals gets the decimals from the big int
	Decimals(opts *bind.CallOpts) (*big.Int, error)
}

BigIntDecimalHandler is the decimal handler for tokens which return a *big.Int this is non-standard: but it's done by usdt token (see: https://tether.to/).

type DAIDeployer

type DAIDeployer struct {
	*deployer.BaseDeployer
}

DAIDeployer deploys a mock erc20 contract.

func (DAIDeployer) Deploy

Deploy deploys the dai contract.

type DeployManager

type DeployManager struct {
	*manager.DeployerManager
}

DeployManager wraps DeployManager and allows typed contract handles to be returned.

func NewDeployManager

func NewDeployManager(t *testing.T) *DeployManager

NewDeployManager creates a new DeployManager.

func (*DeployManager) GetDAI

func (d *DeployManager) GetDAI(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *dai.DaiRef)

GetDAI gets the dai contract.

func (*DeployManager) GetFastBridge

GetFastBridge gets the pre-created fast bridge contract.

func (*DeployManager) GetMockERC20

GetMockERC20 gets a mock erc20 deployed on a chain.

func (*DeployManager) GetMockFastBridge

GetMockFastBridge gets the mock fast bridge.

func (*DeployManager) GetUSDC

func (d *DeployManager) GetUSDC(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *usdc.USDCRef)

GetUSDC gets the usdc contract.

func (*DeployManager) GetUSDT

func (d *DeployManager) GetUSDT(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *usdt.USDTRef)

GetUSDT gets the weth9 contract.

func (*DeployManager) GetWETH9

func (d *DeployManager) GetWETH9(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *weth9.Weth9Ref)

GetWETH9 gets the weth9 contract.

func (*DeployManager) MintToAddress

func (d *DeployManager) MintToAddress(ctx context.Context, backend backends.SimulatedTestBackend, token contracts.ContractType, mintToAddress common.Address, amount *big.Int) (adjustedAmount *big.Int)

MintToAddress mints an equal amount of tokens to an address. Amount is multiplied by decimals to ensure events.

type ERC20DecimalHandler

type ERC20DecimalHandler interface {
	// Decimals gets the erc-20 decimals
	Decimals(opts *bind.CallOpts) (uint8, error)
}

ERC20DecimalHandler gets the decimal count from a standard erc20 token.

type FastBridgeDeployer

type FastBridgeDeployer struct {
	*deployer.BaseDeployer
}

FastBridgeDeployer deplyos a fast bridge contract for testing.

func (FastBridgeDeployer) Deploy

Deploy deploys the fast bridge contract.

type MockERC20Deployer

type MockERC20Deployer struct {
	*deployer.BaseDeployer
}

MockERC20Deployer deploys a mock erc20 contract.

func (MockERC20Deployer) Deploy

Deploy deploys a mock erc20 contract.

type MockFastBridgeDeployer

type MockFastBridgeDeployer struct {
	*deployer.BaseDeployer
}

MockFastBridgeDeployer deploys a mock fast bridge contract for testing.

func (MockFastBridgeDeployer) Deploy

Deploy deploys the mock fast bridge contract.

type USDCDeployer

type USDCDeployer struct {
	*deployer.BaseDeployer
}

USDCDeployer deploys the usdc token (https://www.centre.io/usdc) for testing.

func (USDCDeployer) Deploy

Deploy deploys the usdt token.

type USDTDeployer

type USDTDeployer struct {
	*deployer.BaseDeployer
}

USDTDeployer deploys the usdt token (https://tether.to/) for testing.

func (USDTDeployer) Deploy

Deploy deploys the usdt token.

type WETH9Deployer

type WETH9Deployer struct {
	*deployer.BaseDeployer
}

WETH9Deployer deploys a mock erc20 contract.

func (WETH9Deployer) Deploy

Deploy deploys the weth9 contract.

Jump to

Keyboard shortcuts

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