Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Oct 17, 2024
1 parent 5593905 commit e69dd18
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
21 changes: 10 additions & 11 deletions x/cellarfees/migrations/v1/keeper/query_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,50 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/peggyjv/sommelier/v7/x/cellarfees/migrations/v1/types"
v1types "github.com/peggyjv/sommelier/v7/x/cellarfees/migrations/v1/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

var _ types.QueryServer = Keeper{}

func (k Keeper) QueryParams(c context.Context, req *v1types.QueryParamsRequest) (*v1types.QueryParamsResponse, error) {
func (k Keeper) QueryParams(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

return &v1types.QueryParamsResponse{
return &types.QueryParamsResponse{
Params: k.GetParams(sdk.UnwrapSDKContext(c)),
}, nil
}

func (k Keeper) QueryModuleAccounts(c context.Context, req *v1types.QueryModuleAccountsRequest) (*v1types.QueryModuleAccountsResponse, error) {
func (k Keeper) QueryModuleAccounts(c context.Context, req *types.QueryModuleAccountsRequest) (*types.QueryModuleAccountsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

return &v1types.QueryModuleAccountsResponse{
return &types.QueryModuleAccountsResponse{
FeesAddress: k.GetFeesAccount(sdk.UnwrapSDKContext(c)).GetAddress().String(),
}, nil
}

func (k Keeper) QueryLastRewardSupplyPeak(c context.Context, req *v1types.QueryLastRewardSupplyPeakRequest) (*v1types.QueryLastRewardSupplyPeakResponse, error) {
func (k Keeper) QueryLastRewardSupplyPeak(c context.Context, req *types.QueryLastRewardSupplyPeakRequest) (*types.QueryLastRewardSupplyPeakResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

return &v1types.QueryLastRewardSupplyPeakResponse{LastRewardSupplyPeak: k.GetLastRewardSupplyPeak(sdk.UnwrapSDKContext(c))}, nil
return &types.QueryLastRewardSupplyPeakResponse{LastRewardSupplyPeak: k.GetLastRewardSupplyPeak(sdk.UnwrapSDKContext(c))}, nil
}

func (k Keeper) QueryFeeAccrualCounters(c context.Context, req *v1types.QueryFeeAccrualCountersRequest) (*v1types.QueryFeeAccrualCountersResponse, error) {
func (k Keeper) QueryFeeAccrualCounters(c context.Context, req *types.QueryFeeAccrualCountersRequest) (*types.QueryFeeAccrualCountersResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

return &v1types.QueryFeeAccrualCountersResponse{FeeAccrualCounters: k.GetFeeAccrualCounters(sdk.UnwrapSDKContext(c))}, nil
return &types.QueryFeeAccrualCountersResponse{FeeAccrualCounters: k.GetFeeAccrualCounters(sdk.UnwrapSDKContext(c))}, nil
}

func (k Keeper) QueryAPY(c context.Context, _ *v1types.QueryAPYRequest) (*v1types.QueryAPYResponse, error) {
return &v1types.QueryAPYResponse{
func (k Keeper) QueryAPY(c context.Context, _ *types.QueryAPYRequest) (*types.QueryAPYResponse, error) {
return &types.QueryAPYResponse{
Apy: k.GetAPY(sdk.UnwrapSDKContext(c)).String(),
}, nil
}
3 changes: 1 addition & 2 deletions x/incentives/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ func (suite *KeeperTestSuite) TestBeginBlockerSuccess() {
suite.distributionKeeper.EXPECT().GetFeePool(ctx).Return(pool)

// Mock validators
validators, err := getMockValidators(suite)
require.NoError(err)
validators := suite.getMockValidators()
validator1, validator2 := validators[0], validators[1]

consAddr1, err := validator1.GetConsAddr()
Expand Down
32 changes: 15 additions & 17 deletions x/incentives/keeper/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ var (
}
)

func getMockValidators(suite *KeeperTestSuite) ([]*stakingtypes.Validator, error) {
func (suite *KeeperTestSuite) getMockValidators() []*stakingtypes.Validator {
validator1, err := stakingtypes.NewValidator(sdk.ValAddress([]byte("val1val1val1val1val1")), ConsPubKeys[0], stakingtypes.Description{})
suite.Require().NoError(err)
validator2, err := stakingtypes.NewValidator(sdk.ValAddress([]byte("val2val2val2val2val2")), ConsPubKeys[1], stakingtypes.Description{})
suite.Require().NoError(err)
validator3, err := stakingtypes.NewValidator(sdk.ValAddress([]byte("val3val3val3val3val3")), ConsPubKeys[2], stakingtypes.Description{})
suite.Require().NoError(err)
return []*stakingtypes.Validator{&validator1, &validator2, &validator3}, nil
return []*stakingtypes.Validator{&validator1, &validator2, &validator3}
}

func (suite *KeeperTestSuite) TestGetValidatorInfos() {
ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper

// Create mock validators
validators, err := getMockValidators(suite)
suite.Require().NoError(err)
validators := suite.getMockValidators()
validator1, validator2, validator3 := validators[0], validators[1], validators[2]

consAddr1, err := validator1.GetConsAddr()
Expand Down Expand Up @@ -232,10 +231,10 @@ func (suite *KeeperTestSuite) TestAllocateTokensToValidator() {
event := events[0]
suite.Require().Equal(types.EventTypeIncentivesRewards, event.Type)
suite.Require().Len(event.Attributes, 2)
suite.Require().Equal(sdk.AttributeKeyAmount, string(event.Attributes[0].Key))
suite.Require().Equal(tokens.String(), string(event.Attributes[0].Value))
suite.Require().Equal(types.AttributeKeyValidator, string(event.Attributes[1].Key))
suite.Require().Equal(valAddr.String(), string(event.Attributes[1].Value))
suite.Require().Equal(sdk.AttributeKeyAmount, event.Attributes[0].Key)
suite.Require().Equal(tokens.String(), event.Attributes[0].Value)
suite.Require().Equal(types.AttributeKeyValidator, event.Attributes[1].Key)
suite.Require().Equal(valAddr.String(), event.Attributes[1].Value)
}

func (suite *KeeperTestSuite) TestAllocateTokensToValidatorWithExistingRewards() {
Expand Down Expand Up @@ -275,18 +274,17 @@ func (suite *KeeperTestSuite) TestAllocateTokensToValidatorWithExistingRewards()
event := events[0]
suite.Require().Equal(types.EventTypeIncentivesRewards, event.Type)
suite.Require().Len(event.Attributes, 2)
suite.Require().Equal(sdk.AttributeKeyAmount, string(event.Attributes[0].Key))
suite.Require().Equal(newTokens.String(), string(event.Attributes[0].Value))
suite.Require().Equal(types.AttributeKeyValidator, string(event.Attributes[1].Key))
suite.Require().Equal(valAddr.String(), string(event.Attributes[1].Value))
suite.Require().Equal(sdk.AttributeKeyAmount, event.Attributes[0].Key)
suite.Require().Equal(newTokens.String(), event.Attributes[0].Value)
suite.Require().Equal(types.AttributeKeyValidator, event.Attributes[1].Key)
suite.Require().Equal(valAddr.String(), event.Attributes[1].Value)
}

func (suite *KeeperTestSuite) TestAllocateTokens() {
ctx, incentivesKeeper := suite.ctx, suite.incentivesKeeper

// Create mock validators
validators, err := getMockValidators(suite)
suite.Require().NoError(err)
validators := suite.getMockValidators()
validator1, validator2, validator3 := validators[0], validators[1], validators[2]

// Set up qualifying voters
Expand Down Expand Up @@ -336,9 +334,9 @@ func (suite *KeeperTestSuite) TestAllocateTokens() {
for i, event := range events {
suite.Require().Equal(types.EventTypeIncentivesRewards, event.Type)
suite.Require().Len(event.Attributes, 2)
suite.Require().Equal(sdk.AttributeKeyAmount, string(event.Attributes[0].Key))
suite.Require().Equal(types.AttributeKeyValidator, string(event.Attributes[1].Key))
suite.Require().Equal(qualifyingVoters[i].Validator.GetOperator().String(), string(event.Attributes[1].Value))
suite.Require().Equal(sdk.AttributeKeyAmount, event.Attributes[0].Key)
suite.Require().Equal(types.AttributeKeyValidator, event.Attributes[1].Key)
suite.Require().Equal(qualifyingVoters[i].Validator.GetOperator().String(), event.Attributes[1].Value)
}
}

Expand Down

0 comments on commit e69dd18

Please sign in to comment.