Skip to content

Commit

Permalink
[ioctl] add test cases back (#3803)
Browse files Browse the repository at this point in the history
  • Loading branch information
huof6829 committed Apr 10, 2023
1 parent 64dd415 commit 3988055
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions ioctl/newcmd/action/xrc20transferfrom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3988055

Please sign in to comment.