erc20

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 46 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// XMPLCoin is a dummy coin used for testing purposes.
	XMPLCoin = sdk.NewCoins(sdk.NewInt64Coin(tokenDenom, 1e18))
)

Functions

func GenerateAddress

func GenerateAddress() common.Address

GenerateAddress generates an Ethereum address.

func NewAddrKey

func NewAddrKey() (common.Address, *ethsecp256k1.PrivKey)

NewAddrKey generates an Ethereum address and its corresponding private key.

func TestIntegrationTestSuite

func TestIntegrationTestSuite(t *testing.T, create network.CreateEvmApp, options ...network.ConfigOption)

Types

type CallType

type CallType int

CallType indicates which type of contract call is made during the integration tests.

type ContractData

type ContractData struct {
	Address common.Address
	ABI     abi.ABI
}

ContractData is a helper struct to hold the address and ABI for a given contract.

type ContractsData

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

ContractsData is a helper struct to hold the addresses and ABIs for the different contract instances that are subject to testing here.

func (ContractsData) GetContractData

func (cd ContractsData) GetContractData(callType CallType) ContractData

GetContractData is a helper function to return the contract data for a given call type.

type ExpectedBalance

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

ExpectedBalance is a helper struct to check the balances of accounts.

type IntegrationTestSuite

type IntegrationTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

func NewIntegrationTestSuite

func NewIntegrationTestSuite(create network.CreateEvmApp, options ...network.ConfigOption) *IntegrationTestSuite

func (*IntegrationTestSuite) ExpectAllowanceForContract

func (is *IntegrationTestSuite) ExpectAllowanceForContract(
	callType CallType, contractData ContractsData, owner, spender common.Address, expAmount *big.Int,
)

ExpectAllowanceForContract is a helper function to check that a SendAuthorization exists for a given owner and spender combination for a given amount and optionally an access list.

func (*IntegrationTestSuite) ExpectBalances

func (is *IntegrationTestSuite) ExpectBalances(expBalances []ExpectedBalance)

ExpectBalances is a helper function to check if the balances of the given accounts are as expected.

func (*IntegrationTestSuite) ExpectBalancesForContract

func (is *IntegrationTestSuite) ExpectBalancesForContract(callType CallType, contractData ContractsData, expBalances []ExpectedBalance)

ExpectBalancesForContract is a helper function to check expected balances for given accounts depending on the call type.

func (*IntegrationTestSuite) ExpectBalancesForERC20

func (is *IntegrationTestSuite) ExpectBalancesForERC20(callType CallType, contractData ContractsData, expBalances []ExpectedBalance)

ExpectBalancesForERC20 is a helper function to check expected balances for given accounts when using the ERC20 contract.

func (*IntegrationTestSuite) ExpectTrueToBeReturned

func (is *IntegrationTestSuite) ExpectTrueToBeReturned(res *evmtypes.MsgEthereumTxResponse, methodName string)

ExpectTrueToBeReturned is a helper function to check that the precompile returns true in the ethereum transaction response.

func (*IntegrationTestSuite) MintERC20

func (is *IntegrationTestSuite) MintERC20(callType CallType, contractData ContractsData, receiver common.Address, amount *big.Int) error

MintERC20 is a helper function to mint tokens on the ERC20 contract.

NOTE: we are checking that there was a Transfer event emitted (which happens on minting).

func (*IntegrationTestSuite) SetupTest

func (is *IntegrationTestSuite) SetupTest()

type PrecompileTestSuite

type PrecompileTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

PrecompileTestSuite is the implementation of the TestSuite interface for ERC20 precompile unit tests.

func NewPrecompileTestSuite

func NewPrecompileTestSuite(create network.CreateEvmApp, options ...network.ConfigOption) *PrecompileTestSuite

func (*PrecompileTestSuite) SetupTest

func (s *PrecompileTestSuite) SetupTest()

func (*PrecompileTestSuite) TestAllowance

func (s *PrecompileTestSuite) TestAllowance()

func (*PrecompileTestSuite) TestApprove

func (s *PrecompileTestSuite) TestApprove()

func (*PrecompileTestSuite) TestBalanceOf

func (s *PrecompileTestSuite) TestBalanceOf()

func (*PrecompileTestSuite) TestDecimals

func (s *PrecompileTestSuite) TestDecimals()

func (*PrecompileTestSuite) TestEmitApprovalEvent

func (s *PrecompileTestSuite) TestEmitApprovalEvent()

func (*PrecompileTestSuite) TestEmitTransferEvent

func (s *PrecompileTestSuite) TestEmitTransferEvent()

func (*PrecompileTestSuite) TestIsTransaction

func (s *PrecompileTestSuite) TestIsTransaction()

func (*PrecompileTestSuite) TestNameSymbol

func (s *PrecompileTestSuite) TestNameSymbol()

TestNameSymbolDecimals tests the Name and Symbol methods of the ERC20 precompile.

NOTE: we test both methods in the same test because they need the same testcases and the same setup.

func (*PrecompileTestSuite) TestParseAllowanceArgs

func (s *PrecompileTestSuite) TestParseAllowanceArgs()

func (*PrecompileTestSuite) TestParseApproveArgs

func (s *PrecompileTestSuite) TestParseApproveArgs()

func (*PrecompileTestSuite) TestParseBalanceOfArgs

func (s *PrecompileTestSuite) TestParseBalanceOfArgs()

func (*PrecompileTestSuite) TestParseTransferArgs

func (s *PrecompileTestSuite) TestParseTransferArgs()

func (*PrecompileTestSuite) TestParseTransferFromArgs

func (s *PrecompileTestSuite) TestParseTransferFromArgs()

func (*PrecompileTestSuite) TestRequiredGas

func (s *PrecompileTestSuite) TestRequiredGas()

func (*PrecompileTestSuite) TestSend

func (s *PrecompileTestSuite) TestSend()

func (*PrecompileTestSuite) TestTotalSupply

func (s *PrecompileTestSuite) TestTotalSupply()

func (*PrecompileTestSuite) TestTransfer

func (s *PrecompileTestSuite) TestTransfer()

func (*PrecompileTestSuite) TestTransferFrom

func (s *PrecompileTestSuite) TestTransferFrom()

Jump to

Keyboard shortcuts

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