ethtest

package
v1.27.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: LGPL-3.0, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Contracts registry to have some contracts on hand during testing
	Contracts = ethartifact.NewContractRegistry()
)
View Source
var DefaultTestchainOptions = TestchainOptions{
	NodeURL: "http://localhost:8545",
}

Functions

func ContractCall

func ContractCall(provider *ethrpc.Provider, contractAddress common.Address, contractABI abi.ABI, result interface{}, method string, args ...interface{}) ([]byte, error)

func ContractQuery

func ContractQuery(provider *ethrpc.Provider, contractAddress common.Address, inputExpr, outputExpr string, args []string) ([]string, error)

func ContractTransact

func ContractTransact(wallet *ethwallet.Wallet, contractAddress common.Address, contractABI abi.ABI, method string, args ...interface{}) (*types.Receipt, error)

func DummyAddr

func DummyAddr() common.Address

DummyAddr returns a dummy address

func DummyPrivateKey

func DummyPrivateKey(seed uint64) string

DummyPrivateKey returns random private key in hex used with ethwallet

func ETHValue

func ETHValue(ether float64) *big.Int

func ETHValueBigInt

func ETHValueBigInt(ether *big.Int) *big.Int

func GetBalance

func GetBalance(t *testing.T, wallet *ethwallet.Wallet) *big.Int

func PrepareBlastSendTransactions

func PrepareBlastSendTransactions(ctx context.Context, fromWallets []*ethwallet.Wallet, toAddresses []common.Address, values []*big.Int) ([]*ethtxn.TransactionRequest, []*types.Transaction, error)

func RandomSeed

func RandomSeed() uint64

func SendTransaction

func SendTransaction(t *testing.T, wallet *ethwallet.Wallet, to common.Address, data []byte, ethValue *big.Int) (*types.Transaction, ethtxn.WaitReceipt)

func SendTransactionAndWaitForReceipt

func SendTransactionAndWaitForReceipt(t *testing.T, wallet *ethwallet.Wallet, to common.Address, data []byte, ethValue *big.Int) (*types.Transaction, *types.Receipt)

func WalletAddresses

func WalletAddresses(wallets []*ethwallet.Wallet) []common.Address

Types

type ERC20Mock

type ERC20Mock struct {
	Contract *ethcontract.Contract
	// contains filtered or unexported fields
}

func DeployERC20Mock

func DeployERC20Mock(t *testing.T, testchain *Testchain) (*ERC20Mock, *types.Receipt)

func (*ERC20Mock) GetBalance

func (c *ERC20Mock) GetBalance(t *testing.T, account ethkit.Address, expectedAmount int64)

func (*ERC20Mock) Mint

func (c *ERC20Mock) Mint(t *testing.T, wallet *ethwallet.Wallet, amount int64) *types.Receipt

func (*ERC20Mock) Transfer

func (c *ERC20Mock) Transfer(t *testing.T, owner *ethwallet.Wallet, to ethkit.Address, amount int64) *types.Receipt

type Reorgme

type Reorgme struct {
}

type Testchain

type Testchain struct {
	Provider *ethrpc.Provider // provider rpc to the test chain
	// contains filtered or unexported fields
}

func NewTestchain

func NewTestchain(opts ...TestchainOptions) (*Testchain, error)

func (*Testchain) ChainID

func (c *Testchain) ChainID() *big.Int

func (*Testchain) Deploy

func (c *Testchain) Deploy(t *testing.T, contractName string, contractConstructorArgs ...interface{}) (*ethcontract.Contract, *types.Receipt)

Deploy will deploy a contract registered in `Contracts` registry using the standard deployment method. Each Deploy call will instanitate a new contract on the test chain.

func (*Testchain) DummyWallet

func (c *Testchain) DummyWallet(seed uint64) (*ethwallet.Wallet, error)

func (*Testchain) DummyWallets

func (c *Testchain) DummyWallets(nWallets uint64, startingSeed uint64) ([]*ethwallet.Wallet, error)

func (*Testchain) FundAddress

func (c *Testchain) FundAddress(addr common.Address, optBalanceTarget ...float64) error

func (*Testchain) FundAddresses

func (c *Testchain) FundAddresses(addrs []common.Address, optBalanceTarget ...float64) error

func (*Testchain) FundWallets

func (c *Testchain) FundWallets(minBalance float64, wallets ...*ethwallet.Wallet) error

func (*Testchain) GetDeployTransactor

func (c *Testchain) GetDeployTransactor() (*bind.TransactOpts, error)

GetDeployTransactor returns a account transactor typically used for deploying contracts

func (*Testchain) GetDeployWallet

func (c *Testchain) GetDeployWallet() *ethwallet.Wallet

func (*Testchain) GetRelayerWallet

func (c *Testchain) GetRelayerWallet() *ethwallet.Wallet

GetRelayerWallet is the wallet dedicated EOA wallet to relaying transactions

func (*Testchain) MustFundAddress

func (c *Testchain) MustFundAddress(addr common.Address, optBalanceTarget ...float64)

func (*Testchain) MustWallet

func (c *Testchain) MustWallet(optAccountIndex ...uint32) *ethwallet.Wallet

func (*Testchain) RandomNonce

func (c *Testchain) RandomNonce() *big.Int

func (*Testchain) WaitMined

func (c *Testchain) WaitMined(txn common.Hash) error

func (*Testchain) Wallet

func (c *Testchain) Wallet() (*ethwallet.Wallet, error)

type TestchainOptions

type TestchainOptions struct {
	NodeURL string
}

Jump to

Keyboard shortcuts

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