From 0da8332ae17f0f719de6444c8177b9da25338282 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Fri, 10 May 2024 17:34:20 +0200 Subject: [PATCH] changes to tests --- x/bank/keeper/keeper.go | 6 ++++-- x/bank/keeper/keeper_test.go | 26 +++++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index a656b265aa21..1982e884abb9 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -269,8 +269,10 @@ func (k BaseKeeper) SendCoinsFromModuleToAccount( return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule) } - if err := k.IsSendEnabledCoins(ctx, amt...); err != nil { - return err + for _, coin := range amt { + if ok := k.IsSendEnabledDenom(ctx, coin.Denom); !ok { + return fmt.Errorf("denom: %s, is prohibited from being sent at this time", coin.Denom) + } } if k.BlockedAddr(recipientAddr) { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index adfa7a5bb7c6..4da9a063f342 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -177,7 +177,7 @@ func (suite *KeeperTestSuite) mockMintCoins(moduleAcc *authtypes.ModuleAccount) func (suite *KeeperTestSuite) mockSendCoinsFromModuleToAccount(moduleAcc *authtypes.ModuleAccount, accAddr sdk.AccAddress) { suite.authKeeper.EXPECT().GetModuleAddress(moduleAcc.Name).Return(moduleAcc.GetAddress()) - suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc).AnyTimes() } func (suite *KeeperTestSuite) mockBurnCoins(moduleAcc *authtypes.ModuleAccount) { @@ -393,23 +393,15 @@ func (suite *KeeperTestSuite) TestSendCoinsFromModuleToAccount_CoinSendDisabled( suite.mockMintCoins(mintAcc) require.NoError(keeper.MintCoins(ctx, banktypes.MintModuleName, initCoins)) - params := banktypes.Params{ - - SendEnabled: []*banktypes.SendEnabled{ - { - Denom: sdk.DefaultBondDenom, - Enabled: false, - }, - }, - } + keeper.SetSendEnabled(ctx, sdk.DefaultBondDenom, false) - require.NoError(keeper.SetParams(ctx, params)) - - suite.authKeeper.EXPECT().GetModuleAddress(mintAcc.Name).Return(mintAcc.GetAddress()) + suite.authKeeper.EXPECT().GetModuleAddress(mintAcc.Name).Return(mintAcc.GetAddress()).AnyTimes() err := keeper.SendCoinsFromModuleToAccount( - ctx, banktypes.MintModuleName, accAddrs[4], initCoins, + ctx, banktypes.MintModuleName, accAddrs[2], initCoins, ) - require.Contains(err.Error(), "stake transfers are currently disabled") + require.Contains(err.Error(), "stake, is prohibited from being sent at this time") + keeper.SetSendEnabled(ctx, sdk.DefaultBondDenom, true) + } func (suite *KeeperTestSuite) TestSupply_DelegateUndelegateCoins() { @@ -417,6 +409,10 @@ func (suite *KeeperTestSuite) TestSupply_DelegateUndelegateCoins() { require := suite.Require() authKeeper, keeper := suite.authKeeper, suite.bankKeeper + res, err1 := keeper.SendEnabled(ctx, &banktypes.QuerySendEnabledRequest{}) + require.NoError(err1) + fmt.Println(res) + // set initial balances suite.mockMintCoins(mintAcc) require.NoError(keeper.MintCoins(ctx, banktypes.MintModuleName, initCoins))