diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index e0ea2751c420..fe61bf565cfa 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -382,7 +382,6 @@ func (k BaseKeeper) MintCoins(ctx context.Context, moduleName string, amounts sd // It will panic if the module account does not exist or is unauthorized. func (k BaseKeeper) BurnCoins(ctx context.Context, address []byte, amounts sdk.Coins) error { acc := k.ak.GetAccount(ctx, address) - fmt.Println("acc", fmt.Sprintf("%x", address)) if acc == nil { return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "account %x does not exist", address) } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 7871cc419036..d6721d9f1ba3 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -195,7 +195,6 @@ func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.Ba } func (suite *KeeperTestSuite) mockSendCoins(ctx context.Context, sender sdk.AccountI, receiver sdk.AccAddress) { - fmt.Println(sender.GetAddress(), receiver) suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) } @@ -248,7 +247,6 @@ func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx context.Context, acc, mAcc } suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) - suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) } func (suite *KeeperTestSuite) TestAppendSendRestriction() { @@ -564,13 +562,13 @@ func (suite *KeeperTestSuite) TestSupply_BurnCoins() { supplyAfterInflation, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) - authKeeper.EXPECT().GetAccount(ctx, []byte{}).Return(nil).AnyTimes() - require.Error(keeper.BurnCoins(ctx, []byte{}, initCoins), "no module account") + authKeeper.EXPECT().GetAccount(ctx, []byte{}).Return(nil).MaxTimes(1) + require.Error(keeper.BurnCoins(ctx, []byte{}, initCoins), "no account") - authKeeper.EXPECT().GetAccount(ctx, minterAcc.GetAddress()).Return(nil).AnyTimes() + authKeeper.EXPECT().GetAccount(ctx, minterAcc.GetAddress()).Return(minterAcc).MaxTimes(1) require.Error(keeper.BurnCoins(ctx, minterAcc.GetAddress(), initCoins), "invalid permission") - authKeeper.EXPECT().GetAccount(ctx, randomAcc.GetAddress()).Return(nil).AnyTimes() + authKeeper.EXPECT().GetAccount(ctx, randomAcc.GetAddress()).Return(randomAcc) require.Error(keeper.BurnCoins(ctx, randomAcc.GetAddress(), supplyAfterInflation), "random permission") suite.mockBurnCoins(burnerAcc) @@ -591,7 +589,6 @@ func (suite *KeeperTestSuite) TestSupply_BurnCoins() { supplyAfterInflation, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) - authKeeper.EXPECT().GetAccount(ctx, multiPermAcc.GetAddress()).Return(nil).AnyTimes() suite.mockSendCoins(ctx, minterAcc, multiPermAcc.GetAddress()) require.NoError(keeper.SendCoins(ctx, minterAcc.GetAddress(), multiPermAcc.GetAddress(), initCoins)) diff --git a/x/bank/keeper/msg_server.go b/x/bank/keeper/msg_server.go index c6e50c255fd1..6aef4e8fc03f 100644 --- a/x/bank/keeper/msg_server.go +++ b/x/bank/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "github.com/hashicorp/go-metrics" @@ -190,7 +191,7 @@ func (k msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBu var coins sdk.Coins for _, coin := range msg.Amount { - coins = append(coins, sdk.NewCoin(coin.Denom, coin.Amount)) + coins = coins.Add(sdk.NewCoin(coin.Denom, coin.Amount)) } if base, ok := k.Keeper.(BaseKeeper); ok { @@ -205,7 +206,7 @@ func (k msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBu if !coins.IsValid() { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, coins.String()) } - + fmt.Println("coins", coins) if !coins.IsAllPositive() { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidCoins, coins.String()) }