Skip to content

Commit

Permalink
update test and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
expertdicer committed Oct 31, 2023
1 parent ca410f8 commit f970e0e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
10 changes: 10 additions & 0 deletions ante/gov_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// initial deposit must be greater than or equal to 10% of the minimum deposit
Expand Down Expand Up @@ -53,6 +54,15 @@ func (g GovPreventSpamDecorator) ValidateGovMsgs(ctx sdk.Context, msgs []sdk.Msg
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "insufficient initial deposit amount - required: %v", minInitialDeposit)
}
}
if msg, ok := m.(*govv1beta1.MsgSubmitProposal); ok {
// prevent messages with insufficient initial deposit amount
depositParams := g.govKeeper.GetDepositParams(ctx)
minInitialDeposit := g.calcMinInitialDeposit(depositParams.MinDeposit)
initialDeposit := sdk.NewCoins(msg.InitialDeposit...)
if initialDeposit.IsAllLT(minInitialDeposit) {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "insufficient initial deposit amount - required: %v", minInitialDeposit)
}
}

return nil
}
Expand Down
3 changes: 1 addition & 2 deletions ante/gov_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type GovAnteHandlerTestSuite struct {
}

func (s *GovAnteHandlerTestSuite) SetupTest() {
app := migalooapp.Setup(false)
app := migalooapp.SetupMigalooAppWithValSet(s.T())
ctx := app.BaseApp.NewContext(false, tmproto.Header{
ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)),
Height: 1,
Expand Down Expand Up @@ -73,7 +73,6 @@ func (s *GovAnteHandlerTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() {
content, ok := govv1beta1.ContentFromProposalType(tc.title, tc.description, tc.proposalType)
s.Require().True(ok)
s.Require().NotNil(content)

msg, err := govv1beta1.NewMsgSubmitProposal(
content,
tc.initialDeposit,
Expand Down
6 changes: 3 additions & 3 deletions x/globalfee/ante/antetest/fee_test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package antetest
import (
"fmt"

tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -15,6 +13,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/suite"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

migalooaapp "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/x/globalfee"
Expand All @@ -31,7 +31,7 @@ type IntegrationTestSuite struct {
}

func (s *IntegrationTestSuite) SetupTest() {
app := migalooaapp.Setup(false, s.T())
app := migalooaapp.SetupMigalooAppWithValSet(s.T())
ctx := app.BaseApp.NewContext(false, tmproto.Header{
ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)),
Height: 1,
Expand Down
2 changes: 1 addition & 1 deletion x/globalfee/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package ante
import (
"errors"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/x/globalfee/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/x/globalfee/types"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/x/globalfee"
)
Expand Down
16 changes: 8 additions & 8 deletions x/globalfee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
})
}

func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error {
func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error {
var data types.GenesisState
err := marshaler.UnmarshalJSON(message, &data)
if err != nil {
Expand All @@ -51,10 +51,10 @@ func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, config client
return nil
}

func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
func (a AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {
}

func (a AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) {
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
}

func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
Expand All @@ -69,7 +69,7 @@ func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}

func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {
func (a AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {
}

type AppModule struct {
Expand Down Expand Up @@ -99,7 +99,7 @@ func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) jso
return marshaler.MustMarshalJSON(&genState)
}

func (a AppModule) RegisterInvariants(registry sdk.InvariantRegistry) {
func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {
}

func (a AppModule) Route() sdk.Route {
Expand All @@ -110,18 +110,18 @@ func (a AppModule) QuerierRoute() string {
return types.QuerierRoute
}

func (a AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier {
func (a AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return nil
}

func (a AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), NewGrpcQuerier(a.paramSpace))
}

func (a AppModule) BeginBlock(context sdk.Context, block abci.RequestBeginBlock) {
func (a AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {
}

func (a AppModule) EndBlock(context sdk.Context, block abci.RequestEndBlock) []abci.ValidatorUpdate {
func (a AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return nil
}

Expand Down

0 comments on commit f970e0e

Please sign in to comment.