Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions tests/integration/x/erc20/test_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ func (s *KeeperTestSuite) TestConvertERC20IntoCoinsForNativeToken() {
existingAcc := &statedb.Account{Nonce: uint64(1), Balance: uint256.NewInt(1)}
balance := make([]uint8, 32)
mockEVMKeeper.On("EstimateGasInternal", mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.EstimateGasResponse{Gas: uint64(200)}, nil)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
mockEVMKeeper.On("CallEVMWithData", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("forced ApplyMessage error"))
mockEVMKeeper.On("GetAccountWithoutBalance", mock.Anything, mock.Anything).Return(existingAcc, nil)
Expand Down Expand Up @@ -171,7 +170,7 @@ func (s *KeeperTestSuite) TestConvertERC20IntoCoinsForNativeToken() {
balance := make([]uint8, 32)
balance[31] = uint8(1)
mockEVMKeeper.On("EstimateGasInternal", mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.EstimateGasResponse{Gas: uint64(200)}, nil)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Twice()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Twice()
mockEVMKeeper.On("CallEVMWithData", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("forced balance error"))
mockEVMKeeper.On("GetAccountWithoutBalance", mock.Anything, mock.Anything).Return(existingAcc, nil)
mockEVMKeeper.On("IsContract", mock.Anything, mock.Anything).Return(true)
Expand Down Expand Up @@ -199,8 +198,7 @@ func (s *KeeperTestSuite) TestConvertERC20IntoCoinsForNativeToken() {
existingAcc := &statedb.Account{Nonce: uint64(1), Balance: uint256.NewInt(1)}
balance := make([]uint8, 32)
mockEVMKeeper.On("EstimateGasInternal", mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.EstimateGasResponse{Gas: uint64(200)}, nil)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
mockEVMKeeper.On("CallEVMWithData", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{}, nil)
mockEVMKeeper.On("GetAccountWithoutBalance", mock.Anything, mock.Anything).Return(existingAcc, nil)
mockEVMKeeper.On("IsContract", mock.Anything, mock.Anything).Return(true)
Expand Down Expand Up @@ -228,8 +226,7 @@ func (s *KeeperTestSuite) TestConvertERC20IntoCoinsForNativeToken() {
existingAcc := &statedb.Account{Nonce: uint64(1), Balance: uint256.NewInt(1)}
balance := make([]uint8, 32)
mockEVMKeeper.On("EstimateGasInternal", mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.EstimateGasResponse{Gas: uint64(200)}, nil)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
mockEVMKeeper.On("CallEVMWithData", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil)
mockEVMKeeper.On("GetAccountWithoutBalance", mock.Anything, mock.Anything).Return(existingAcc, nil)
Expand Down
85 changes: 41 additions & 44 deletions tests/integration/x/erc20/test_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

func expectViewCallEVM(mockEVMKeeper *erc20mocks.EVMKeeper, _ interface{}, _ ...interface{}) *mock.Call {
return mockEVMKeeper.On(
"CallEVMViewWithData",
mock.Anything, // context
mock.Anything, // from
mock.Anything, // contract
mock.Anything, // ABI-encoded data
mock.Anything, // gas cap
)
}

func (s *KeeperTestSuite) TestQueryERC20() {
var (
contract common.Address
Expand Down Expand Up @@ -84,17 +95,15 @@ func (s *KeeperTestSuite) TestBalanceOf() {
{
"Failed to call Evm",
func() {
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("forced ApplyMessage error"))
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("forced ApplyMessage error"))
},
int64(0),
false,
},
{
"Incorrect res",
func() {
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
},
int64(0),
false,
Expand All @@ -104,8 +113,7 @@ func (s *KeeperTestSuite) TestBalanceOf() {
func() {
balance := make([]uint8, 32)
balance[31] = uint8(10)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: balance}, nil).Once()
},
int64(10),
true,
Expand Down Expand Up @@ -147,16 +155,14 @@ func (s *KeeperTestSuite) TestQueryERC20ForceFail() {
{
"Failed to call Evm",
func() {
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("forced ApplyMessage error"))
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(nil, fmt.Errorf("forced ApplyMessage error"))
},
false,
},
{
"Incorrect res",
func() {
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
},
false,
},
Expand All @@ -165,19 +171,16 @@ func (s *KeeperTestSuite) TestQueryERC20ForceFail() {
func() {
ret := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 67, 111, 105, 110, 32, 84, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
mockEVMKeeper.On("ApplyMessage", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{VmError: "Error"}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{VmError: "Error"}, nil).Once()
},
false,
},
{
"incorrect symbol res",
func() {
ret := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 67, 111, 105, 110, 32, 84, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
},
false,
},
Expand All @@ -186,12 +189,9 @@ func (s *KeeperTestSuite) TestQueryERC20ForceFail() {
func() {
ret := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 67, 111, 105, 110, 32, 84, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
retSymbol := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 67, 84, 75, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: retSymbol}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{VmError: "Error"}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: retSymbol}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{VmError: "Error"}, nil).Once()
},
false,
},
Expand All @@ -200,12 +200,9 @@ func (s *KeeperTestSuite) TestQueryERC20ForceFail() {
func() {
ret := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 67, 111, 105, 110, 32, 84, 111, 107, 101, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
retSymbol := []uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 67, 84, 75, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: retSymbol}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: ret}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: retSymbol}, nil).Once()
expectViewCallEVM(mockEVMKeeper, mock.Anything).Return(&evmtypes.MsgEthereumTxResponse{Ret: []uint8{0, 0}}, nil).Once()
},
false,
},
Expand Down Expand Up @@ -287,11 +284,11 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
symbolData := createStringData("MKR")
decimalsData := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}

mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: nameData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "symbol").
expectViewCallEVM(mockEVMKeeper, "symbol").
Return(&evmtypes.MsgEthereumTxResponse{Ret: symbolData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "decimals").
expectViewCallEVM(mockEVMKeeper, "decimals").
Return(&evmtypes.MsgEthereumTxResponse{Ret: decimalsData}, nil).Once()
},
types.ERC20Data{Name: "Maker", Symbol: "MKR", Decimals: 18},
Expand All @@ -305,11 +302,11 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
decimalsData := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}

// First call tries string unpacking (will fail), then tries bytes32 (will succeed)
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: nameData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "symbol").
expectViewCallEVM(mockEVMKeeper, "symbol").
Return(&evmtypes.MsgEthereumTxResponse{Ret: symbolData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "decimals").
expectViewCallEVM(mockEVMKeeper, "decimals").
Return(&evmtypes.MsgEthereumTxResponse{Ret: decimalsData}, nil).Once()
},
types.ERC20Data{Name: "Maker", Symbol: "MKR", Decimals: 18},
Expand All @@ -322,11 +319,11 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
symbolData := createBytes32Data("MKR")
decimalsData := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}

mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: nameData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "symbol").
expectViewCallEVM(mockEVMKeeper, "symbol").
Return(&evmtypes.MsgEthereumTxResponse{Ret: symbolData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "decimals").
expectViewCallEVM(mockEVMKeeper, "decimals").
Return(&evmtypes.MsgEthereumTxResponse{Ret: decimalsData}, nil).Once()
},
types.ERC20Data{Name: "Maker", Symbol: "MKR", Decimals: 18},
Expand All @@ -346,11 +343,11 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {

decimalsData := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}

mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: nameData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "symbol").
expectViewCallEVM(mockEVMKeeper, "symbol").
Return(&evmtypes.MsgEthereumTxResponse{Ret: symbolData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "decimals").
expectViewCallEVM(mockEVMKeeper, "decimals").
Return(&evmtypes.MsgEthereumTxResponse{Ret: decimalsData}, nil).Once()
},
types.ERC20Data{Name: "Maker", Symbol: "MKR", Decimals: 18},
Expand All @@ -359,7 +356,7 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
{
"EVM call fails for name",
func() {
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(nil, fmt.Errorf("EVM call failed")).Once()
},
types.ERC20Data{},
Expand All @@ -370,7 +367,7 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
func() {
invalidData := []byte{0xFF, 0xFF} // Invalid data that will fail both unpacking methods

mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: invalidData}, nil).Once()
},
types.ERC20Data{},
Expand All @@ -381,9 +378,9 @@ func (s *KeeperTestSuite) TestQueryERC20Bytes32Fallback() {
func() {
nameData := createStringData("Maker")

mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "name").
expectViewCallEVM(mockEVMKeeper, "name").
Return(&evmtypes.MsgEthereumTxResponse{Ret: nameData}, nil).Once()
mockEVMKeeper.On("CallEVM", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "symbol").
expectViewCallEVM(mockEVMKeeper, "symbol").
Return(nil, fmt.Errorf("EVM call failed")).Once()
},
types.ERC20Data{},
Expand Down
Loading