Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 committed Sep 8, 2023
1 parent 439e2a2 commit 331f302
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 88 deletions.
82 changes: 0 additions & 82 deletions tests/integration/distribution/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,88 +709,6 @@ func TestMsgUpdateParams(t *testing.T) {
}
}

func TestMsgCommunityPoolSpend(t *testing.T) {
t.Parallel()
f := initFixture(t)

require.NoError(t, f.distrKeeper.Params.Set(f.sdkCtx, distrtypes.DefaultParams()))
initialFeePool := sdk.NewDecCoins(sdk.DecCoin{Denom: "stake", Amount: math.LegacyNewDec(10000)})
require.NoError(t, f.distrKeeper.FeePool.Set(f.sdkCtx, distrtypes.FeePool{
CommunityPool: initialFeePool,
}))

initTokens := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(100))
err := f.bankKeeper.MintCoins(f.sdkCtx, distrtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)))
require.NoError(t, err)

recipient := sdk.AccAddress([]byte("addr1"))

testCases := []struct {
name string
msg *distrtypes.MsgCommunityPoolSpend
expErr bool
expErrMsg string
}{
{
name: "invalid authority",
msg: &distrtypes.MsgCommunityPoolSpend{
Authority: "invalid",
Recipient: recipient.String(),
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
},
expErr: true,
expErrMsg: "invalid authority",
},
{
name: "invalid recipient",
msg: &distrtypes.MsgCommunityPoolSpend{
Authority: f.distrKeeper.GetAuthority(),
Recipient: "invalid",
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
},
expErr: true,
expErrMsg: "decoding bech32 failed",
},
{
name: "valid message",
msg: &distrtypes.MsgCommunityPoolSpend{
Authority: f.distrKeeper.GetAuthority(),
Recipient: recipient.String(),
Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))),
},
expErr: false,
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
res, err := f.app.RunMsg(
tc.msg,
integration.WithAutomaticFinalizeBlock(),
integration.WithAutomaticCommit(),
)
if tc.expErr {
assert.ErrorContains(t, err, tc.expErrMsg)
} else {
assert.NilError(t, err)
assert.Assert(t, res != nil)

// check the result
result := distrtypes.MsgCommunityPoolSpend{}
err = f.cdc.Unmarshal(res.Value, &result)
assert.NilError(t, err)

// query the community pool to verify it has been updated
communityPool, err := f.distrKeeper.FeePool.Get(f.sdkCtx)
require.NoError(t, err)
newPool, negative := initialFeePool.SafeSub(sdk.NewDecCoinsFromCoins(tc.msg.Amount...))
assert.Assert(t, negative == false)
assert.DeepEqual(t, communityPool.CommunityPool, newPool)
}
})
}
}

func TestMsgDepositValidatorRewardsPool(t *testing.T) {
t.Parallel()
f := initFixture(t)
Expand Down
4 changes: 2 additions & 2 deletions x/distribution/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD
}

// CommunityPool queries the community pool coins
func (k Querier) CommunityPool(ctx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { //nolint:staticcheck
func (k Querier) CommunityPool(ctx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { //nolint:staticcheck // we're using a deprecated call for compatibility
pool, err := k.FeePool.Get(ctx)
if err != nil {
return nil, err
}

return &types.QueryCommunityPoolResponse{Pool: pool.CommunityPool}, nil //nolint:staticcheck
return &types.QueryCommunityPoolResponse{Pool: pool.CommunityPool}, nil //nolint:staticcheck // we're using a deprecated call for compatibility
}
8 changes: 4 additions & 4 deletions x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (k msgServer) WithdrawValidatorCommission(ctx context.Context, msg *types.M
return &types.MsgWithdrawValidatorCommissionResponse{Amount: amount}, nil
}

func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundCommunityPool) (*types.MsgFundCommunityPoolResponse, error) { //nolint:staticcheck
func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundCommunityPool) (*types.MsgFundCommunityPoolResponse, error) { //nolint:staticcheck // we're using a deprecated call for compatibility
if err := validateAmount(msg.Amount); err != nil {
return nil, err
}
Expand All @@ -126,7 +126,7 @@ func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundComm

}

return &types.MsgFundCommunityPoolResponse{}, nil //nolint:staticcheck
return &types.MsgFundCommunityPoolResponse{}, nil //nolint:staticcheck // we're using a deprecated call for compatibility
}

func (k msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
Expand All @@ -150,7 +150,7 @@ func (k msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams)
return &types.MsgUpdateParamsResponse{}, nil
}

func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommunityPoolSpend) (*types.MsgCommunityPoolSpendResponse, error) { //nolint:staticcheck
func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommunityPoolSpend) (*types.MsgCommunityPoolSpendResponse, error) { //nolint:staticcheck // we're using a deprecated call for compatibility
if err := k.validateAuthority(msg.Authority); err != nil {
return nil, err
}
Expand All @@ -175,7 +175,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni
logger := k.Logger(ctx)
logger.Info("transferred from the community pool to recipient", "amount", msg.Amount.String(), "recipient", msg.Recipient)

return &types.MsgCommunityPoolSpendResponse{}, nil //nolint:staticcheck
return &types.MsgCommunityPoolSpendResponse{}, nil //nolint:staticcheck // we're using a deprecated call for compatibility
}

func (k msgServer) DepositValidatorRewardsPool(ctx context.Context, msg *types.MsgDepositValidatorRewardsPool) (*types.MsgDepositValidatorRewardsPoolResponse, error) {
Expand Down

0 comments on commit 331f302

Please sign in to comment.