Documentation
¶
Overview ¶
Package testutil contains utilities for testing the RFQ service.
Index ¶
- Constants
- Variables
- func AdjustAmount(ctx context.Context, amount *big.Int, handler interface{}) (res *big.Int, err error)
- func GetDecimals(ctx context.Context, handler interface{}) (res uint8, err error)
- func MustAdjustAmount(ctx context.Context, tb testing.TB, amount *big.Int, handler interface{}) (res *big.Int)
- func NewDAIDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewFastBridgeDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewMockERC20Deployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewMockFastBridgeDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewUSDCDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewUSDTDeployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- func NewWETH9Deployer(registry deployer.GetOnlyContractRegistry, ...) deployer.ContractDeployer
- type BigIntDecimalHandler
- type DAIDeployer
- type DeployManager
- func (d *DeployManager) GetDAI(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *dai.DaiRef)
- func (d *DeployManager) GetFastBridge(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *fastbridge.FastBridgeRef)
- func (d *DeployManager) GetMockERC20(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *mockerc20.MockERC20Ref)
- func (d *DeployManager) GetMockFastBridge(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *fastbridgemock.FastBridgeMockRef)
- func (d *DeployManager) GetUSDC(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *usdc.USDCRef)
- func (d *DeployManager) GetUSDT(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *usdt.USDTRef)
- func (d *DeployManager) GetWETH9(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *weth9.Weth9Ref)
- func (d *DeployManager) MintToAddress(ctx context.Context, backend backends.SimulatedTestBackend, ...) (adjustedAmount *big.Int)
- type ERC20DecimalHandler
- type FastBridgeDeployer
- type MockERC20Deployer
- type MockFastBridgeDeployer
- type USDCDeployer
- type USDTDeployer
- type WETH9Deployer
Constants ¶
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 )
const MockERC20Decimals uint8 = 10
MockERC20Decimals is the default number of mock erc20 decimals.
const MockERC20Name = "token"
MockERC20Name is the name of hte mock erc20.
Variables ¶
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 ¶
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 ¶
func NewDAIDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
NewDAIDeployer creates a new deployer for dai.
func NewFastBridgeDeployer ¶
func NewFastBridgeDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
NewFastBridgeDeployer deploys a fast bridge contract.
func NewMockERC20Deployer ¶
func NewMockERC20Deployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
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 ¶
func NewUSDCDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
NewUSDCDeployer creates a new deployer for tether.
func NewUSDTDeployer ¶
func NewUSDTDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
NewUSDTDeployer creates a new deployer for tether.
func NewWETH9Deployer ¶
func NewWETH9Deployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer
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 ¶
func (m DAIDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
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 ¶
func (d *DeployManager) GetFastBridge(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *fastbridge.FastBridgeRef)
GetFastBridge gets the pre-created fast bridge contract.
func (*DeployManager) GetMockERC20 ¶
func (d *DeployManager) GetMockERC20(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *mockerc20.MockERC20Ref)
GetMockERC20 gets a mock erc20 deployed on a chain.
func (*DeployManager) GetMockFastBridge ¶
func (d *DeployManager) GetMockFastBridge(ctx context.Context, backend backends.SimulatedTestBackend) (contract contracts.DeployedContract, handle *fastbridgemock.FastBridgeMockRef)
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 ¶
func (f FastBridgeDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
Deploy deploys the fast bridge contract.
type MockERC20Deployer ¶
type MockERC20Deployer struct {
*deployer.BaseDeployer
}
MockERC20Deployer deploys a mock erc20 contract.
func (MockERC20Deployer) Deploy ¶
func (m MockERC20Deployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
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 ¶
func (m MockFastBridgeDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
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 ¶
func (d USDCDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
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 ¶
func (d USDTDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
Deploy deploys the usdt token.
type WETH9Deployer ¶
type WETH9Deployer struct {
*deployer.BaseDeployer
}
WETH9Deployer deploys a mock erc20 contract.
func (WETH9Deployer) Deploy ¶
func (m WETH9Deployer) Deploy(ctx context.Context) (contracts.DeployedContract, error)
Deploy deploys the weth9 contract.