Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: lint tests #676

Merged
merged 6 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
run:
timeout: 5m
tests: true
modules-download-mode: readonly
skip-files:
- ./*_test.go

linters:
disable-all: true
enable:
- gofmt
- goimports
- gofumpt
- misspell
- revive
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- gosec
- gocyclo

issues:
exclude-use-default: false
Expand All @@ -37,4 +32,4 @@ linters-settings:
disabled: true
errcheck:
check-type-assertions: true


1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
#### Bug Fixes

- (rollapp) [#471](https://github.com/dymensionxyz/dymension/issues/471) Validate rollapp token metadata
- (hygene) [#676](https://github.com/dymensionxyz/dymension/pull/676) lint tests
- (ibc) [#678](https://github.com/dymensionxyz/dymension/pull/678) apply a pfm patch

___
Expand Down
2 changes: 1 addition & 1 deletion app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
return sdk.ChainAnteDecorators(
ethante.NewEthSetUpContextDecorator(options.EvmKeeper),

//FIXME: need to allow universal fees for Eth as well
// FIXME: need to allow universal fees for Eth as well

Check warning on line 20 in app/ante/handlers.go

View check run for this annotation

Codecov / codecov/patch

app/ante/handlers.go#L20

Added line #L20 was not covered by tests
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
ethante.NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice

Expand Down
6 changes: 3 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func New(

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
Expand Down Expand Up @@ -946,7 +946,7 @@ func New(
TxFeesKeeper: app.TxFeesKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
MaxTxGasWanted: maxGasWanted,
ExtensionOptionChecker: nil, //uses default
ExtensionOptionChecker: nil, // uses default
})
if err != nil {
panic(err)
Expand Down Expand Up @@ -1007,7 +1007,7 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

//exclude the streamer as we want him to be able to get external incentives
// exclude the streamer as we want him to be able to get external incentives
modAccAddrs[authtypes.NewModuleAddress(streamermoduletypes.ModuleName).String()] = false
return modAccAddrs
}
Expand Down
4 changes: 1 addition & 3 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ var DefaultConsensusParams = &abci.ConsensusParams{
},
}

var (
TestChainID = "dymension_100-1"
)
var TestChainID = "dymension_100-1"

// SetupOptions defines arguments that are passed into `Simapp` constructor.
type SetupOptions struct {
Expand Down
2 changes: 1 addition & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (suite *KeeperTestHelper) CreateDefaultSequencer(ctx sdk.Context, rollappId
pkAny1, err := codectypes.NewAnyWithValue(pubkey1)
suite.Require().Nil(err)

//fund account
// fund account
err = bankutil.FundAccount(suite.App.BankKeeper, ctx, addr1, sdk.NewCoins(bond))
suite.Require().Nil(err)

Expand Down
1 change: 0 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
func (app *App) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {

// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

Expand Down
3 changes: 0 additions & 3 deletions app/upgrades/v3/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ func GetStoreUpgrades() *storetypes.StoreUpgrades {
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,

) upgradetypes.UpgradeHandler {

return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

logger := ctx.Logger().With("upgrade", UpgradeName)

// Start running the module migrations
Expand Down
2 changes: 1 addition & 1 deletion cmd/dymd/cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func InspectCmd(appExporter types.AppExporter, appCreator types.AppCreator, defa
return err
}

//TODO: fix to flag
// TODO: fix to flag
if len(args) > 0 && args[0] == "tendermint" {
return getTendermintState(serverCtx.Config)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dymd/cmd/inspect_tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getTendermintState(config *cfg.Config) error {
fmt.Printf("%+v\n", latestBlock)

if bh != state.LastBlockHeight {
//priniting block for state height
// priniting block for state height
fmt.Println("LOADING BLOCK FOR STATE HEIGHT")
block := blockStore.LoadBlock(state.LastBlockHeight)
if block == nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/dymd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig
txCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
)

}

// queryCommand returns the sub-command to send queries to the app
Expand Down
7 changes: 2 additions & 5 deletions simulation/simapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
bk types.BankKeeper,
ak types.AccountKeeper,
futureOperation []simtypes.FutureOperation,
bExpectedError bool) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {

bExpectedError bool,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {

Check warning on line 59 in simulation/simapp.go

View check run for this annotation

Codecov / codecov/patch

simulation/simapp.go#L59

Added line #L59 was not covered by tests
spendableCoins := bk.SpendableCoins(*ctx, simAccount.Address)

if spendableCoins.Empty() {
Expand Down Expand Up @@ -90,7 +90,6 @@
if err != nil {
panic(err)
}

}
return operationMsg, futureOperation, err
}
Expand Down Expand Up @@ -134,7 +133,6 @@
[]uint64{account.GetSequence()},
txCtx.SimAccount.PrivKey,
)

if err != nil {
return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate mock tx"), nil, err
}
Expand All @@ -145,5 +143,4 @@
}

return simtypes.NewOperationMsg(txCtx.Msg, true, "", txCtx.Cdc), nil, nil

}
1 change: 0 additions & 1 deletion testutil/keeper/delayedack.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ type SequencerKeeperStub struct{}

func (SequencerKeeperStub) GetSequencer(ctx sdk.Context, sequencerAddress string) (val sequencertypes.Sequencer, found bool) {
return sequencertypes.Sequencer{}, false

}

func DelayedackKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
Expand Down
2 changes: 1 addition & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func DefaultConfig() network.Config {
cfg := network.DefaultConfig()
encoding := app.MakeEncodingConfig()

//FIXME: add rand tmrand.Uint64() to chainID
// FIXME: add rand tmrand.Uint64() to chainID
cfg.ChainID = "dymension_1000-1"
cfg.AppConstructor = func(val network.Validator) servertypes.Application {
return app.New(
Expand Down
2 changes: 1 addition & 1 deletion x/common/types/key_rollapp_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var _ binary.ByteOrder

const (
//KeySeparator defines the separator for keys
// KeySeparator defines the separator for keys
KeySeparator = "/"
// // RollappPacketKeyPrefix is the prefix to retrieve all RollappPackets
// RollappPacketKeyPrefix = "RollappPacket/value/"
Expand Down
3 changes: 2 additions & 1 deletion x/delayedack/eibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ func (im IBCMiddleware) eIBCDemandOrderHandler(ctx sdk.Context, rollappPacket co
// calculates the demand order price, and creates a new demand order.
// It returns the created demand order or an error if there is any.
func (im IBCMiddleware) createDemandOrderFromIBCPacket(fungibleTokenPacketData transfertypes.FungibleTokenPacketData,
rollappPacket *commontypes.RollappPacket, eibcMetaData types.EIBCMetadata) (*eibctypes.DemandOrder, error) {
rollappPacket *commontypes.RollappPacket, eibcMetaData types.EIBCMetadata,
) (*eibctypes.DemandOrder, error) {
// Validate the fungible token packet data as we're going to use it to create the demand order
if err := fungibleTokenPacketData.ValidateBasic(); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion x/delayedack/keeper/fraud.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (k Keeper) HandleFraud(ctx sdk.Context, rollappID string) error {
err := k.writeFailedAck(ctx, rollappPacket, errString)
if err != nil {
logger.Error("failed to write failed ack", "rollappID", rollappID, "packetId", packetId, "error", errString)
//don't return here as it's nice to have
// don't return here as it's nice to have
}
}

Expand Down
10 changes: 4 additions & 6 deletions x/delayedack/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func NewKeeper(
clientKeeper types.ClientKeeper,
eibcKeeper types.EIBCKeeper,
bankKeeper types.BankKeeper,

) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
Expand Down Expand Up @@ -189,7 +188,6 @@ func (k *Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string

// VallidateRollappId checks that the rollappid from the ibc connection matches the rollapp checking the sequencer registered with the consensus state validator set
func (k *Keeper) ValidateRollappId(ctx sdk.Context, rollapp, portID, channelID string) error {

// Get the sequencer from the latest state info update and check the validator set hash
// from the headers match with the sequencer for the rollapp
// As the assumption the sequencer is honest we don't check the packet proof height.
Expand All @@ -212,19 +210,19 @@ func (k *Keeper) ValidateRollappId(ctx sdk.Context, rollapp, portID, channelID s
return err
}

//Gets sequencer information from the sequencer address found in the latest state info
// Gets sequencer information from the sequencer address found in the latest state info
sequencer, found := k.sequencerKeeper.GetSequencer(ctx, stateInfo.Sequencer)
if !found {
return sdkerrors.Wrapf(sequencertypes.ErrUnknownSequencer, "sequencer %s not found for the rollapp %s", stateInfo.Sequencer, rollapp)
}

//Gets the validator set hash made out of the pub key for the sequencer
// Gets the validator set hash made out of the pub key for the sequencer
seqPubKeyHash, err := sequencer.GetDymintPubKeyHash()
if err != nil {
return err
}

//It compares the validator set hash from the consensus state with the one we recreated from the sequencer. If its true it means the chain corresponds to the rollapp chain
// It compares the validator set hash from the consensus state with the one we recreated from the sequencer. If its true it means the chain corresponds to the rollapp chain
if !bytes.Equal(tmConsensusState.NextValidatorsHash, seqPubKeyHash) {
errMsg := fmt.Sprintf("consensus state does not match: consensus state validators %x, rollapp sequencer %x",
tmConsensusState.NextValidatorsHash, stateInfo.Sequencer)
Expand Down Expand Up @@ -258,7 +256,7 @@ func (k Keeper) getTmConsensusState(ctx sdk.Context, portID string, channelID st
return &tenderminttypes.ConsensusState{}, err
}

//TODO(srene) : consensus state is only obtained when getting it for latestheight. this can be an issue when sequencer changes. i have to figure out why is only returned for latest height
// TODO(srene) : consensus state is only obtained when getting it for latestheight. this can be an issue when sequencer changes. i have to figure out why is only returned for latest height

consensusState, found := k.clientKeeper.GetClientConsensusState(ctx, connectionEnd.GetClientID(), clientState.GetLatestHeight())
if !found {
Expand Down
3 changes: 1 addition & 2 deletions x/delayedack/proof_height_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types"
)

type IBCProofHeightDecorator struct {
}
type IBCProofHeightDecorator struct{}

func NewIBCProofHeightDecorator() IBCProofHeightDecorator {
return IBCProofHeightDecorator{}
Expand Down
6 changes: 2 additions & 4 deletions x/delayedack/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (

var _ paramtypes.ParamSet = (*Params)(nil)

var (
// KeyEpochIdentifier is the key for the epoch identifier
KeyEpochIdentifier = []byte("EpochIdentifier")
)
// KeyEpochIdentifier is the key for the epoch identifier
var KeyEpochIdentifier = []byte("EpochIdentifier")

const (
defaultEpochIdentifier = "hour"
Expand Down
4 changes: 1 addition & 3 deletions x/denommetadata/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import (
"github.com/dymensionxyz/dymension/v3/x/denommetadata/types"
)

var (
DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())
)
var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())

// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion x/denommetadata/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (im IBCMiddleware) OnRecvPacket(
Denom: du.Denom,
Exponent: du.Exponent,
}
//base denom_unit should be the same as baseDenom
// base denom_unit should be the same as baseDenom
if newDu.Exponent == 0 {
newDu.Denom = voucherDenom
newDu.Aliases = append(newDu.Aliases, du.Denom)
Expand Down
2 changes: 0 additions & 2 deletions x/denommetadata/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Keeper struct {

// NewKeeper returns a new instance of the denommetadata keeper
func NewKeeper(bankKeeper types.BankKeeper) *Keeper {

return &Keeper{
bankKeeper: bankKeeper,
hooks: nil,
Expand All @@ -37,7 +36,6 @@ func (k *Keeper) CreateDenomMetadata(ctx sdk.Context, metadata banktypes.Metadat
return err
}
return nil

}

func (k *Keeper) UpdateDenomMetadata(ctx sdk.Context, metadata banktypes.Metadata) error {
Expand Down
2 changes: 0 additions & 2 deletions x/denommetadata/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {

}

// GetTxCmd returns the module's root tx command.
Expand Down Expand Up @@ -131,7 +130,6 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
// InitGenesis performs the module's genesis initialization.
// Returns an empty ValidatorUpdate array.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {

return []abci.ValidatorUpdate{}
}

Expand Down
2 changes: 0 additions & 2 deletions x/denommetadata/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func NewDenomMetadataProposalHandler(k *keeper.Keeper) govtypes.Handler {

// HandleCreateDenomMetadataProposal is a handler for executing a passed denom metadata creation proposal
func HandleCreateDenomMetadataProposal(ctx sdk.Context, k *keeper.Keeper, p *types.CreateDenomMetadataProposal) error {

for _, metadata := range p.TokenMetadata {
err := k.CreateDenomMetadata(ctx, metadata)
if err != nil {
Expand All @@ -35,7 +34,6 @@ func HandleCreateDenomMetadataProposal(ctx sdk.Context, k *keeper.Keeper, p *typ

// HandleUpdateDenomMetadataProposal is a handler for executing a passed denom metadata update proposal
func HandleUpdateDenomMetadataProposal(ctx sdk.Context, k *keeper.Keeper, p *types.UpdateDenomMetadataProposal) error {

for _, metadata := range p.TokenMetadata {
err := k.UpdateDenomMetadata(ctx, metadata)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion x/denommetadata/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ func DefaultGenesis() *GenesisState {
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {

return nil
}
7 changes: 4 additions & 3 deletions x/denommetadata/types/proposal_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ const (
)

// Assert CreateDenomMetadataProposal implements govtypes.Content at compile-time
var _ govtypes.Content = &CreateDenomMetadataProposal{}
var _ govtypes.Content = &UpdateDenomMetadataProposal{}
var (
_ govtypes.Content = &CreateDenomMetadataProposal{}
_ govtypes.Content = &UpdateDenomMetadataProposal{}
)

func init() {
govtypes.RegisterProposalType(ProposalTypeCreateDenomMetadata)
govtypes.RegisterProposalType(ProposalTypeUpdateDenomMetadata)

}

// NewCreateMetadataProposal creates a new create denommetadata proposal.
Expand Down
1 change: 0 additions & 1 deletion x/eibc/client/cli/query_command_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func CmdListDemandOrdersByStatus() *cobra.Command {
res, err := queryClient.DemandOrdersByStatus(context.Background(), &types.QueryDemandOrdersByStatusRequest{
Status: status,
})

if err != nil {
return err
}
Expand Down
Loading
Loading