chore: fix linting script (#18233)
This commit is contained in:
parent
90723b76f9
commit
79b70bed51
3
.github/workflows/lint.yml
vendored
3
.github/workflows/lint.yml
vendored
@ -32,6 +32,8 @@ jobs:
|
||||
id: lint_long
|
||||
run: |
|
||||
nix develop -c make lint
|
||||
env:
|
||||
NIX: 1
|
||||
- uses: technote-space/get-diff-action@v6.1.2
|
||||
if: steps.lint_long.outcome == 'skipped'
|
||||
id: git_diff_all
|
||||
@ -49,3 +51,4 @@ jobs:
|
||||
env:
|
||||
GIT_DIFF: ${{ env.GIT_DIFF }}
|
||||
LINT_DIFF: 1
|
||||
NIX: 1
|
||||
|
||||
@ -6,14 +6,17 @@ run:
|
||||
exclude-dir: testutil/testdata
|
||||
skip-files:
|
||||
- server/grpc/gogoreflection/fix_registration.go
|
||||
- tests/e2e/client/grpc/cmtservice/service_test.go
|
||||
- "fix_registration.go"
|
||||
- ".*\\.pb\\.go$"
|
||||
- ".*\\.pb\\.gw\\.go$"
|
||||
- ".*\\.pulsar\\.go$"
|
||||
- crypto/keys/secp256k1/internal/*
|
||||
|
||||
build-tags:
|
||||
- rocksdb
|
||||
- e2e
|
||||
- ledger
|
||||
- test_ledger_mock
|
||||
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
|
||||
@ -32,6 +32,7 @@ func TestPublicKeyUnsafe(t *testing.T) {
|
||||
}
|
||||
|
||||
func checkDefaultPubKey(t *testing.T, priv types.LedgerPrivKey) {
|
||||
t.Helper()
|
||||
require.NotNil(t, priv)
|
||||
expectedPkStr := "PubKeySecp256k1{034FEF9CD7C4C63588D3B03FEB5281B9D232CBA34D6F3D71AEE59211FFBFE1FE87}"
|
||||
require.Equal(t, "eb5ae98721034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe87",
|
||||
|
||||
@ -9,8 +9,15 @@ lint_module() {
|
||||
local root="$1"
|
||||
shift
|
||||
cd "$(dirname "$root")" &&
|
||||
echo "linting $(grep "^module" go.mod) [$(date -Iseconds -u)]" &&
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@"
|
||||
echo "linting $(grep "^module" go.mod) [$(date -Iseconds -u)]" &&
|
||||
if [[ -z "${NIX:-}" ]]; then
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=e2e,ledger,test_ledger_mock
|
||||
else
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=rocksdb,e2e,ledger,test_ledger_mock
|
||||
fi
|
||||
if [[ "$(grep "^module" go.mod)" == "module cosmossdk.io/simapp" ]]; then
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=app_v1
|
||||
fi
|
||||
}
|
||||
export -f lint_module
|
||||
|
||||
@ -31,7 +38,14 @@ else
|
||||
for f in $(dirname $(echo "$GIT_DIFF" | tr -d "'") | uniq); do
|
||||
echo "linting $f [$(date -Iseconds -u)]" &&
|
||||
cd $f &&
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" &&
|
||||
if [[ -z "${NIX:-}" ]]; then
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=e2e,ledger,test_ledger_mock
|
||||
else
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=rocksdb,e2e,ledger,test_ledger_mock
|
||||
fi
|
||||
if [[ $f == simapp || $f == simapp/simd/cmd ]]; then
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=app_v1
|
||||
fi
|
||||
cd $REPO_ROOT
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -9,6 +9,11 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
|
||||
"cosmossdk.io/client/v2/autocli"
|
||||
@ -24,6 +29,11 @@ import (
|
||||
"cosmossdk.io/x/feegrant"
|
||||
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
|
||||
feegrantmodule "cosmossdk.io/x/feegrant/module"
|
||||
"cosmossdk.io/x/gov"
|
||||
govclient "cosmossdk.io/x/gov/client"
|
||||
govkeeper "cosmossdk.io/x/gov/keeper"
|
||||
govtypes "cosmossdk.io/x/gov/types"
|
||||
govv1beta1 "cosmossdk.io/x/gov/types/v1beta1"
|
||||
"cosmossdk.io/x/group"
|
||||
groupkeeper "cosmossdk.io/x/group/keeper"
|
||||
groupmodule "cosmossdk.io/x/group/module"
|
||||
@ -37,16 +47,7 @@ import (
|
||||
"cosmossdk.io/x/upgrade"
|
||||
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
|
||||
upgradetypes "cosmossdk.io/x/upgrade/types"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"cosmossdk.io/x/gov"
|
||||
govclient "cosmossdk.io/x/gov/client"
|
||||
govkeeper "cosmossdk.io/x/gov/keeper"
|
||||
govtypes "cosmossdk.io/x/gov/types"
|
||||
govv1beta1 "cosmossdk.io/x/gov/types/v1beta1"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@ -74,7 +75,6 @@ import (
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
|
||||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -143,8 +143,7 @@ type SimApp struct {
|
||||
interfaceRegistry types.InterfaceRegistry
|
||||
|
||||
// keys to access the substores
|
||||
keys map[string]*storetypes.KVStoreKey
|
||||
tkeys map[string]*storetypes.TransientStoreKey
|
||||
keys map[string]*storetypes.KVStoreKey
|
||||
|
||||
// keepers
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
@ -207,7 +206,7 @@ func NewSimApp(
|
||||
})
|
||||
appCodec := codec.NewProtoCodec(interfaceRegistry)
|
||||
legacyAmino := codec.NewLegacyAmino()
|
||||
txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes)
|
||||
txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes)
|
||||
|
||||
std.RegisterLegacyAminoCodec(legacyAmino)
|
||||
std.RegisterInterfaces(interfaceRegistry)
|
||||
@ -290,12 +289,12 @@ func NewSimApp(
|
||||
)
|
||||
|
||||
// optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper)
|
||||
enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL)
|
||||
txConfigOpts := tx.ConfigOptions{
|
||||
enabledSignModes := append(authtx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL)
|
||||
txConfigOpts := authtx.ConfigOptions{
|
||||
EnabledSignModes: enabledSignModes,
|
||||
TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper),
|
||||
}
|
||||
txConfig, err := tx.NewTxConfigWithOptions(
|
||||
txConfig, err := authtx.NewTxConfigWithOptions(
|
||||
appCodec,
|
||||
txConfigOpts,
|
||||
)
|
||||
@ -613,7 +612,9 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*ab
|
||||
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap())
|
||||
if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
|
||||
}
|
||||
|
||||
|
||||
@ -5,11 +5,12 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/simapp"
|
||||
"cosmossdk.io/simapp/params"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/config"
|
||||
|
||||
@ -6,9 +6,11 @@ package auth
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
func TestE2ETestSuite(t *testing.T) {
|
||||
|
||||
@ -6,10 +6,11 @@ package client
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
func TestE2ETestSuite(t *testing.T) {
|
||||
|
||||
@ -8,16 +8,16 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
_ "cosmossdk.io/x/gov"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
qtypes "github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
@ -92,7 +92,6 @@ func (s *E2ETestSuite) TestQueryLatestBlock() {
|
||||
s.Require().NoError(err)
|
||||
var blockInfoRes cmtservice.GetLatestBlockResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
|
||||
s.Require().Equal(types.ConsAddress(blockInfoRes.Block.Header.ProposerAddress).String(), blockInfoRes.SdkBlock.Header.ProposerAddress)
|
||||
s.Require().Contains(blockInfoRes.SdkBlock.Header.ProposerAddress, "cosmosvalcons")
|
||||
}
|
||||
|
||||
|
||||
@ -7,13 +7,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
v1 "cosmossdk.io/x/gov/types/v1"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
v1 "cosmossdk.io/x/gov/types/v1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
func TestE2ETestSuite(t *testing.T) {
|
||||
|
||||
@ -6,10 +6,11 @@ package group
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
func TestE2ETestSuite(t *testing.T) {
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
@ -95,10 +96,12 @@ func TestExportCmd_Height(t *testing.T) {
|
||||
|
||||
// Fast forward to block `tc.fastForward`.
|
||||
for i := int64(2); i <= tc.fastForward; i++ {
|
||||
app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
Height: i,
|
||||
})
|
||||
app.Commit()
|
||||
assert.NilError(t, err)
|
||||
_, err = app.Commit()
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
output := &bytes.Buffer{}
|
||||
@ -180,16 +183,18 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, ge
|
||||
err = genutil.ExportGenesisFile(&appGenesis, serverCtx.Config.GenesisFile())
|
||||
assert.NilError(t, err)
|
||||
|
||||
app.InitChain(&abci.RequestInitChain{
|
||||
_, err = app.InitChain(&abci.RequestInitChain{
|
||||
Validators: []abci.ValidatorUpdate{},
|
||||
ConsensusParams: simtestutil.DefaultConsensusParams,
|
||||
AppStateBytes: appGenesis.AppState,
|
||||
},
|
||||
)
|
||||
app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
Height: 1,
|
||||
})
|
||||
app.Commit()
|
||||
assert.NilError(t, err)
|
||||
_, err = app.Commit()
|
||||
assert.NilError(t, err)
|
||||
|
||||
cmd := server.ExportCmd(func(_ log.Logger, _ dbm.DB, _ io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOptions types.AppOptions, modulesToExport []string) (types.ExportedApp, error) {
|
||||
var simApp *simapp.SimApp
|
||||
|
||||
@ -6,9 +6,11 @@ package testutil
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
)
|
||||
|
||||
func TestE2ETestSuite(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user