diff --git a/CHANGELOG.md b/CHANGELOG.md index 1db3132f9..f910d5001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -213,6 +213,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10633](https://github.com/cosmos/cosmos-sdk/pull/10633) Fixed authorization not found error when executing message. * [#11222](https://github.com/cosmos/cosmos-sdk/pull/11222) reject query with block height in the future * [#11229](https://github.com/cosmos/cosmos-sdk/pull/11229) Handled the error message of `transaction encountered error` from tendermint. +* (x/authz) [\#11252](https://github.com/cosmos/cosmos-sdk/pull/11252) Allow insufficient funds error for authz simulation ### State Machine Breaking diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 81a00d5cd..3247a0735 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -250,7 +250,7 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe msg := []sdk.Msg{banktype.NewMsgSend(granterAddr, granteeAddr, coins)} authorization, err := targetGrant.GetAuthorization() - if err != nil{ + if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err } @@ -259,17 +259,13 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "not a send authorization"), nil, nil } - if sendAuth.SpendLimit.IsAllLTE(coins) { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "over spend limit"), nil, nil - } - - res, err := sendAuth.Accept(ctx, msg[0]) + _, err = sendAuth.Accept(ctx, msg[0]) if err != nil { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err - } - - if !res.Accept { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "expired or invalid grant"), nil, nil + if sdkerrors.ErrInsufficientFunds.Is(err) { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, nil + } else { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err + } } msgExec := authz.NewMsgExec(granteeAddr, msg) @@ -278,9 +274,9 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "fee error"), nil, err } + txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) - tx, err := helpers.GenTx( txCfg, []sdk.Msg{&msgExec},