Skip to content

Commit

Permalink
changes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed May 10, 2024
1 parent 65f3143 commit 0da8332
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
6 changes: 4 additions & 2 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 11 additions & 15 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -393,30 +393,26 @@ 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() {
ctx := suite.ctx
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))
Expand Down

0 comments on commit 0da8332

Please sign in to comment.