From 200a4efd484ea2ab17cbe98a7f4d400fd5c0f4f7 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Thu, 11 Jul 2024 02:28:27 +0900 Subject: [PATCH] test: Add erc20/MsgConvertERC20 test --- app/signer_test.go | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/signer_test.go b/app/signer_test.go index 5011d7b6..c488d113 100644 --- a/app/signer_test.go +++ b/app/signer_test.go @@ -3,17 +3,21 @@ package app import ( "testing" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + protov2 "google.golang.org/protobuf/proto" + "cosmossdk.io/x/tx/signing" - coinswapapi "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" - coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - protov2 "google.golang.org/protobuf/proto" -) -func TestMsgSwapOrderSigners(t *testing.T) { + coinswapv1 "github.com/Canto-Network/Canto/v7/api/canto/coinswap/v1" + erc20v1 "github.com/Canto-Network/Canto/v7/api/canto/erc20/v1" + coinswaptypes "github.com/Canto-Network/Canto/v7/x/coinswap/types" + erc20types "github.com/Canto-Network/Canto/v7/x/erc20/types" +) +func TestDefineCustomGetSigners(t *testing.T) { addr := "canto13e9t6s6ra8caz5zzmy5w9v23dm2dr5nrr9sz03" accAddr, err := sdk.AccAddressFromBech32(addr) require.NoError(t, err) @@ -26,7 +30,8 @@ func TestMsgSwapOrderSigners(t *testing.T) { Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), }, } - signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapapi.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&erc20v1.MsgConvertERC20{}), erc20types.GetSignersFromMsgConvertERC20V2) + signingOptions.DefineCustomGetSigners(protov2.MessageName(&coinswapv1.MsgSwapOrder{}), coinswaptypes.CreateGetSignersFromMsgSwapOrderV2(&signingOptions)) ctx, err := signing.NewContext(signingOptions) require.NoError(t, err) @@ -37,12 +42,19 @@ func TestMsgSwapOrderSigners(t *testing.T) { want [][]byte wantErr bool }{ + { + name: "MsgConvertERC20", + msg: &erc20v1.MsgConvertERC20{ + Sender: common.BytesToAddress(accAddr.Bytes()).String(), + }, + want: [][]byte{accAddr.Bytes()}, + }, { name: "MsgSwapOrder", - msg: &coinswapapi.MsgSwapOrder{ - Input: &coinswapapi.Input{Address: addr}, + msg: &coinswapv1.MsgSwapOrder{ + Input: &coinswapv1.Input{Address: addr}, }, - want: [][]byte{accAddr}, + want: [][]byte{accAddr.Bytes()}, }, } for _, test := range tests {