From 3988055cc60e0428a9cfb55840aa376692ddd323 Mon Sep 17 00:00:00 2001 From: huofei <68298506@qq.com> Date: Tue, 11 Apr 2023 04:02:49 +0800 Subject: [PATCH] [ioctl] add test cases back (#3803) --- ioctl/newcmd/action/xrc20transferfrom_test.go | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ioctl/newcmd/action/xrc20transferfrom_test.go b/ioctl/newcmd/action/xrc20transferfrom_test.go index 54b7bc60e0..32f9581e3c 100644 --- a/ioctl/newcmd/action/xrc20transferfrom_test.go +++ b/ioctl/newcmd/action/xrc20transferfrom_test.go @@ -70,16 +70,15 @@ func TestNewXrc20TransferFromCmd(t *testing.T) { Return(&iotexapi.ReadContractResponse{Data: contractData}, nil).AnyTimes() api.EXPECT().GetAccount(gomock.Any(), gomock.Any(), gomock.Any()). Return(&iotexapi.GetAccountResponse{ - AccountMeta: &iotextypes.AccountMeta{PendingNonce: 100}, + AccountMeta: &iotextypes.AccountMeta{ + PendingNonce: 100, + Balance: balance, + }, }, nil).AnyTimes() api.EXPECT().GetChainMeta(gomock.Any(), gomock.Any()). Return(&iotexapi.GetChainMetaResponse{}, nil).AnyTimes() - - api.EXPECT().GetAccount(gomock.Any(), gomock.Any()). - Return(&iotexapi.GetAccountResponse{ - AccountMeta: &iotextypes.AccountMeta{Balance: balance}, - }, nil).AnyTimes() - api.EXPECT().SendAction(gomock.Any(), gomock.Any()).Return(&iotexapi.SendActionResponse{}, nil).AnyTimes() + api.EXPECT().SendAction(gomock.Any(), gomock.Any()). + Return(&iotexapi.SendActionResponse{}, nil).AnyTimes() cli.EXPECT().Config().Return(config.Config{ Explorer: "iotexscan", @@ -133,6 +132,16 @@ func TestNewXrc20TransferFromCmd(t *testing.T) { []string{dftOwner, dftRecipient, dftAmount}, newcmd(dftContract, wrongContractData, dftOwner, dftBalance), fmt.Sprintf("failed to parse amount: failed to convert string into int64: strconv.ParseInt: parsing \"%s\": invalid syntax", wrongContractData), + }, { + "BalanceNotEnough", + []string{dftOwner, dftRecipient, dftAmount}, + newcmd(dftContract, dftContractData, accountAddr.String(), "0"), + "failed to pass balance check: balance is not enough", + }, { + "ShouldPass", + []string{dftOwner, dftRecipient, dftAmount}, + newcmd(dftContract, dftContractData, accountAddr.String(), dftBalance), + "", }} for _, test := range tests {