chore: lint v2 (#24118)

This commit is contained in:
Alex | Interchain Labs 2025-03-25 11:57:24 -04:00 committed by GitHub
parent 9acd7716dd
commit b7a20b81f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
87 changed files with 298 additions and 288 deletions

View File

@ -1,26 +1,22 @@
version: "2"
run:
tests: true
timeout: 15m
allow-parallel-runners: true
build-tags:
- e2e
- ledger
- test_ledger_mock
- sims
tests: true
allow-parallel-runners: true
linters:
disable-all: true
default: none
enable:
- copyloopvar
- dogsled
- errcheck
- errorlint
- copyloopvar
- gci
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
@ -28,99 +24,121 @@ linters:
- nolintlint
- revive
- staticcheck
- stylecheck
- thelper
- typecheck
- unconvert
- unused
settings:
dogsled:
max-blank-identifiers: 6
gocritic:
disabled-checks:
- regexpMust
- appendAssign
- ifElseChain
gosec:
excludes:
- G101
- G107
- G404
confidence: medium
misspell:
locale: US
nolintlint:
require-explanation: true
require-specific: false
allow-unused: false
revive:
rules:
- name: redefines-builtin-id
disabled: true
staticcheck:
checks:
- all
unused:
local-variables-are-used: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: 'ST1003:'
- linters:
- staticcheck
text: 'ST1016:'
- linters:
- staticcheck
path: migrations
text: 'SA1019:'
- linters:
- staticcheck
text: 'SA1019: codec.NewAminoCodec is deprecated'
- linters:
- staticcheck
text: 'SA1019: legacybech32.MustMarshalPubKey'
- linters:
- staticcheck
text: 'SA1019: legacybech32.MarshalPubKey'
- linters:
- staticcheck
text: 'SA1019: legacybech32.UnmarshalPubKey'
- linters:
- staticcheck
text: 'SA1019: params.SendEnabled is deprecated'
- linters:
- gosec
text: 'G115: integer overflow conversion'
- linters:
- nolintlint
text: leading space
paths:
- server/grpc/gogoreflection/fix_registration.go
- fix_registration.go
- .*\.pb\.go$
- .*\.pb\.gw\.go$
- .*\.pulsar\.go$
- crypto/keys/secp256k1/internal/*
- types/coin_regex.go
- testutil/testdata
- x/params
- x/crisis
- third_party$
- builtin$
- examples$
issues:
exclude-dirs:
- testutil/testdata
- x/params
- x/crisis
exclude-files:
- server/grpc/gogoreflection/fix_registration.go
- "fix_registration.go"
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.pulsar\\.go$"
- crypto/keys/secp256k1/internal/*
- types/coin_regex.go
exclude-rules:
- text: "ST1003:" # We are fine with our current naming
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:" # Ok with inconsistent receiver names
linters:
- stylecheck
- path: "migrations" # migraitions always use deprecated code
text: "SA1019:"
linters:
- staticcheck
- text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out
linters:
- staticcheck
- text: "SA1019: legacybech32.MustMarshalPubKey" # TODO remove once ready to remove from the sdk
linters:
- staticcheck
- text: "SA1019: legacybech32.MarshalPubKey" # TODO remove once ready to remove from the sdk
linters:
- staticcheck
- text: "SA1019: legacybech32.UnmarshalPubKey" # TODO remove once ready to remove from the sdk
linters:
- staticcheck
- text: "SA1019: params.SendEnabled is deprecated" # TODO remove once ready to remove from the sdk
linters:
- staticcheck
- text: "G115: integer overflow conversion" # We are doing this everywhere.
linters:
- gosec
- text: "leading space"
linters:
- nolintlint
max-issues-per-linter: 10000
max-same-issues: 10000
linters-settings:
gci:
custom-order: true
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
revive:
rules:
- name: redefines-builtin-id
disabled: true
gosec:
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G101 # Potential hardcoded credentials
- G107 # Potential HTTP request made with variable url
- G404 # Use of weak random number generator (math/rand instead of crypto/rand)
exclude-generated: true
confidence: medium
misspell:
locale: US
gofumpt:
extra-rules: true
dogsled:
max-blank-identifiers: 6
nolintlint:
allow-unused: false
require-explanation: true
require-specific: false
gosimple:
checks: ["all"]
gocritic:
disabled-checks:
- regexpMust
- appendAssign
- ifElseChain
unused:
local-variables-are-used: false
formatters:
enable:
- gci
- gofumpt
settings:
gci:
sections:
- standard
- default
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
custom-order: true
gofumpt:
extra-rules: true
exclusions:
generated: lax
paths:
- server/grpc/gogoreflection/fix_registration.go
- fix_registration.go
- .*\.pb\.go$
- .*\.pb\.gw\.go$
- .*\.pulsar\.go$
- crypto/keys/secp256k1/internal/*
- types/coin_regex.go
- testutil/testdata
- x/params
- x/crisis
- third_party$
- builtin$
- examples$

View File

@ -382,11 +382,11 @@ benchmark:
### Linting ###
###############################################################################
golangci_version=v1.64.8
golangci_version=v2.0.0
lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(golangci_version)
lint:
@echo "--> Running linter on all files"

View File

@ -340,11 +340,11 @@ func (app *BaseApp) ApplySnapshotChunk(req *abci.RequestApplySnapshotChunk) (*ab
func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
var mode execMode
switch {
case req.Type == abci.CheckTxType_New:
switch req.Type {
case abci.CheckTxType_New:
mode = execModeCheck
case req.Type == abci.CheckTxType_Recheck:
case abci.CheckTxType_Recheck:
mode = execModeReCheck
default:

View File

@ -937,12 +937,13 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res
anteEvents = events.ToABCIEvents()
}
if mode == execModeCheck {
switch mode {
case execModeCheck:
err = app.mempool.Insert(ctx, tx)
if err != nil {
return gInfo, nil, anteEvents, err
}
} else if mode == execModeFinalize {
case execModeFinalize:
err = app.mempool.Remove(tx)
if err != nil && !errors.Is(err, mempool.ErrTxNotFound) {
return gInfo, nil, anteEvents,

View File

@ -829,11 +829,12 @@ var ctxTypes = []ctxType{QueryCtx, CheckTxCtx}
func (c ctxType) GetCtx(t *testing.T, bapp *baseapp.BaseApp) sdk.Context {
t.Helper()
if c == QueryCtx {
switch c {
case QueryCtx:
ctx, err := bapp.CreateQueryContext(1, false)
require.NoError(t, err)
return ctx
} else if c == CheckTxCtx {
case CheckTxCtx:
return getCheckStateCtx(bapp)
}
// TODO: Not supported yet

View File

@ -56,7 +56,7 @@ func TestGRPCQueryRouter(t *testing.T) {
func TestGRPCRouterHybridHandlers(t *testing.T) {
assertRouterBehaviour := func(helper *baseapp.QueryServiceTestHelper) {
// test getting the handler by name
handlers := helper.GRPCQueryRouter.HybridHandlerByRequestName("testpb.EchoRequest")
handlers := helper.HybridHandlerByRequestName("testpb.EchoRequest")
require.NotNil(t, handlers)
require.Len(t, handlers, 1)
handler := handlers[0]

View File

@ -98,7 +98,7 @@ type voteInfoWrapper struct {
var _ comet.VoteInfo = (*voteInfoWrapper)(nil)
func (v voteInfoWrapper) GetBlockIDFlag() comet.BlockIDFlag {
return comet.BlockIDFlag(v.VoteInfo.BlockIdFlag)
return comet.BlockIDFlag(v.BlockIdFlag)
}
func (v voteInfoWrapper) Validator() comet.Validator {
@ -159,11 +159,11 @@ func (r prepareProposalInfo) GetValidatorsHash() []byte {
}
func (r prepareProposalInfo) GetProposerAddress() []byte {
return r.RequestPrepareProposal.ProposerAddress
return r.ProposerAddress
}
func (r prepareProposalInfo) GetLastCommit() comet.CommitInfo {
return extendedCommitInfoWrapper{r.RequestPrepareProposal.LocalLastCommit}
return extendedCommitInfoWrapper{r.LocalLastCommit}
}
var _ comet.BlockInfo = (*prepareProposalInfo)(nil)
@ -203,7 +203,7 @@ type extendedVoteInfoWrapper struct {
var _ comet.VoteInfo = (*extendedVoteInfoWrapper)(nil)
func (e extendedVoteInfoWrapper) GetBlockIDFlag() comet.BlockIDFlag {
return comet.BlockIDFlag(e.ExtendedVoteInfo.BlockIdFlag)
return comet.BlockIDFlag(e.BlockIdFlag)
}
func (e extendedVoteInfoWrapper) Validator() comet.Validator {

View File

@ -99,7 +99,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
// end of app init
s.ctx = app.BaseApp.NewContext(false)
s.ctx = app.NewContext(false)
s.cdc = cdc
queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, interfaceRegistry)
types.RegisterQueryServer(queryHelper, bankKeeper)

View File

@ -99,7 +99,7 @@ func doParseKey(cmd *cobra.Command, config *sdk.Config, args []string) error {
}
output, _ := cmd.Flags().GetString(flags.FlagOutput)
if !(runFromBech32(outstream, addr, output) || runFromHex(config, outstream, addr, output)) {
if !runFromBech32(outstream, addr, output) && !runFromHex(config, outstream, addr, output) {
return errors.New("couldn't find valid bech32 nor hex data")
}

View File

@ -121,7 +121,7 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
clientCtx = clientCtx.WithOutput(cmd.OutOrStdout())
fd := input.Descriptor().Fields().ByName(protoreflect.Name(flag.GetSignerFieldName(input.Descriptor())))
addressCodec := b.Builder.AddressCodec
addressCodec := b.AddressCodec
// set signer to signer field if empty
if addr := input.Get(fd).String(); addr == "" {
@ -130,9 +130,9 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
// override address codec if validator or consensus address
switch scalarType {
case flag.ValidatorAddressStringScalarType:
addressCodec = b.Builder.ValidatorAddressCodec
addressCodec = b.ValidatorAddressCodec
case flag.ConsensusAddressStringScalarType:
addressCodec = b.Builder.ConsensusAddressCodec
addressCodec = b.ConsensusAddressCodec
}
}

View File

@ -7,15 +7,15 @@ import (
"strings"
"time"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/math"
"cosmossdk.io/x/tx/signing/aminojson"
"github.com/cockroachdb/errors"
"github.com/spf13/cobra"
"google.golang.org/protobuf/reflect/protoreflect"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/client/v2/internal/flags"
"cosmossdk.io/client/v2/internal/util"
"cosmossdk.io/math"
"cosmossdk.io/x/tx/signing/aminojson"
sdk "github.com/cosmos/cosmos-sdk/types"
)

View File

@ -76,10 +76,8 @@ func TestValueCodec[T any](t *testing.T, encoder codec.ValueCodec[T], value T) {
// it in order to make the type known by the MockValueCodec.
func MockValueCodec[T any]() codec.ValueCodec[T] {
typ := reflect.ValueOf(new(T)).Elem().Type()
isInterface := false
if typ.Kind() == reflect.Interface {
isInterface = true
}
isInterface := typ.Kind() == reflect.Interface
return &mockValueCodec[T]{
isInterface: isInterface,
seenTypes: map[string]reflect.Type{},

View File

@ -20,10 +20,10 @@ func TestDefaultGenesis(t *testing.T) {
return w, nil
}))
require.Len(t, writers, 4)
require.Equal(t, `[]`, writers[0].Buffer.String())
require.Equal(t, `[]`, writers[1].Buffer.String())
require.Equal(t, `[]`, writers[2].Buffer.String())
require.Equal(t, `[]`, writers[3].Buffer.String())
require.Equal(t, `[]`, writers[0].String())
require.Equal(t, `[]`, writers[1].String())
require.Equal(t, `[]`, writers[2].String())
require.Equal(t, `[]`, writers[3].String())
}
func TestValidateGenesis(t *testing.T) {
@ -75,10 +75,10 @@ func TestExportGenesis(t *testing.T) {
return w, nil
}))
require.Len(t, writers, 4)
require.Equal(t, expectedItemGenesis, writers[0].Buffer.String())
require.Equal(t, expectedKeySetGenesis, writers[1].Buffer.String())
require.Equal(t, expectedMapGenesis, writers[2].Buffer.String())
require.Equal(t, expectedSequenceGenesis, writers[3].Buffer.String())
require.Equal(t, expectedItemGenesis, writers[0].String())
require.Equal(t, expectedKeySetGenesis, writers[1].String())
require.Equal(t, expectedMapGenesis, writers[2].String())
require.Equal(t, expectedSequenceGenesis, writers[3].String())
}
type testFixture struct {

View File

@ -39,6 +39,6 @@ type genesisWriter struct {
}
func (r genesisWriter) Close() error {
r.sink.m[r.field] = r.Buffer.Bytes()
r.sink.m[r.field] = r.Bytes()
return nil
}

View File

@ -87,7 +87,7 @@ func NewParamsFromPath(path string) (*BIP44Params, error) {
fmt.Errorf("fourth and fifth field in path must not be hardened (ie. not contain the suffix ', got %s and %s", spl[3], spl[4])
}
if !(change == 0 || change == 1) {
if change != 0 && change != 1 {
return nil, fmt.Errorf("change field can only be 0 or 1")
}

View File

@ -48,7 +48,7 @@ func (a *autoCLIKeyringAdapter) List() ([]string, error) {
// LookupAddressByKeyName returns the address of a key stored in the keyring
func (a *autoCLIKeyringAdapter) LookupAddressByKeyName(name string) ([]byte, error) {
record, err := a.Keyring.Key(name)
record, err := a.Key(name)
if err != nil {
return nil, err
}
@ -62,7 +62,7 @@ func (a *autoCLIKeyringAdapter) LookupAddressByKeyName(name string) ([]byte, err
}
func (a *autoCLIKeyringAdapter) GetPubKey(name string) (cryptotypes.PubKey, error) {
record, err := a.Keyring.Key(name)
record, err := a.Key(name)
if err != nil {
return nil, err
}
@ -71,7 +71,7 @@ func (a *autoCLIKeyringAdapter) GetPubKey(name string) (cryptotypes.PubKey, erro
}
func (a *autoCLIKeyringAdapter) Sign(name string, msg []byte, signMode signingv1beta1.SignMode) ([]byte, error) {
record, err := a.Keyring.Key(name)
record, err := a.Key(name)
if err != nil {
return nil, err
}

View File

@ -67,5 +67,5 @@ func (suite *PKSuite) TestMarshal() {
pk := new(PubKey)
err = pk.Unmarshal(buffer, secp256r1, size)
require.NoError(err)
require.True(pk.PublicKey.Equal(&suite.pk.PublicKey))
require.True(pk.Equal(&suite.pk.PublicKey))
}

View File

@ -58,12 +58,12 @@ type ecdsaSK struct {
// Marshal implements customProtobufType.
func (sk ecdsaSK) Marshal() ([]byte, error) {
return sk.PrivKey.Bytes(), nil
return sk.Bytes(), nil
}
// MarshalJSON implements customProtobufType.
func (sk ecdsaSK) MarshalJSON() ([]byte, error) {
b64 := base64.StdEncoding.EncodeToString(sk.PrivKey.Bytes())
b64 := base64.StdEncoding.EncodeToString(sk.Bytes())
return []byte("\"" + b64 + "\""), nil
}

View File

@ -67,12 +67,12 @@ type ecdsaPK struct {
// Marshal implements customProtobufType.
func (pk ecdsaPK) Marshal() ([]byte, error) {
return pk.PubKey.Bytes(), nil
return pk.Bytes(), nil
}
// MarshalJSON implements customProtobufType.
func (pk ecdsaPK) MarshalJSON() ([]byte, error) {
b64 := base64.StdEncoding.EncodeToString(pk.PubKey.Bytes())
b64 := base64.StdEncoding.EncodeToString(pk.Bytes())
return []byte("\"" + b64 + "\""), nil
}

View File

@ -12,6 +12,6 @@ type Edge struct {
}
func (e Edge) render(w io.Writer, indent string) error {
_, err := fmt.Fprintf(w, "%s%q -> %q%s;\n", indent, e.from.name, e.to.name, e.Attributes.String())
_, err := fmt.Fprintf(w, "%s%q -> %q%s;\n", indent, e.from.name, e.to.name, e.String())
return err
}

View File

@ -12,6 +12,6 @@ type Node struct {
}
func (n Node) render(w io.Writer, indent string) error {
_, err := fmt.Fprintf(w, "%s%q%s;\n", indent, n.name, n.Attributes.String())
_, err := fmt.Fprintf(w, "%s%q%s;\n", indent, n.name, n.String())
return err
}

View File

@ -45,7 +45,7 @@ func StructInAndOut(_ float32, _ StructIn, _ byte) (int16, StructOut, int32, err
return int16(0), StructOut{}, int32(0), nil
}
func BadErrorPosition() (error, int) { return nil, 0 } //nolint:stylecheck // Deliberately has error as first of multiple arguments.
func BadErrorPosition() (error, int) { return nil, 0 } //nolint:stylecheck,staticcheck // Deliberately has error as first of multiple arguments.
func BadOptionalFn(_ BadOptional) int { return 0 }

View File

@ -305,7 +305,7 @@ func (d LegacyDec) assertInValidRange() {
// IsInValidRange returns true when the value is between the upper limit of (2^256 * 10^18)
// and the lower limit of -1*(2^256 * 10^18).
func (d LegacyDec) IsInValidRange() bool {
return !(d.GT(upperLimit) || d.LT(lowerLimit))
return !d.GT(upperLimit) && !d.LT(lowerLimit)
}
// Mul multiplication

View File

@ -35,7 +35,7 @@ func NewEventManager(ctx context.Context) event.Manager {
// Emit emits an typed event that is defined in the protobuf file.
// In the future these events will be added to consensus.
func (e Events) Emit(ctx context.Context, event protoiface.MessageV1) error {
return e.EventManagerI.EmitTypedEvent(event)
return e.EmitTypedEvent(event)
}
// EmitKV emits a key value pair event.
@ -46,12 +46,12 @@ func (e Events) EmitKV(ctx context.Context, eventType string, attrs ...event.Att
attributes = append(attributes, sdk.NewAttribute(attr.Key, attr.Value))
}
e.EventManagerI.EmitEvents(sdk.Events{sdk.NewEvent(eventType, attributes...)})
e.EmitEvents(sdk.Events{sdk.NewEvent(eventType, attributes...)})
return nil
}
// Emit emits an typed event that is defined in the protobuf file.
// In the future these events will be added to consensus.
func (e Events) EmitNonConsensus(ctx context.Context, event protoiface.MessageV1) error {
return e.EventManagerI.EmitTypedEvent(event)
return e.EmitTypedEvent(event)
}

View File

@ -279,7 +279,7 @@ func GetConfig(v *viper.Viper) (Config, error) {
// ValidateBasic returns an error if min-gas-prices field is empty in BaseConfig. Otherwise, it returns nil.
func (c Config) ValidateBasic() error {
if c.BaseConfig.MinGasPrices == "" {
if c.MinGasPrices == "" {
return sdkerrors.ErrAppConfig.Wrap("set min gas price in app.toml or flag or env variable")
}
if c.Pruning == pruningtypes.PruningOptionEverything && c.StateSync.SnapshotInterval > 0 {

View File

@ -443,7 +443,7 @@ func TestEmptyMinGasPrices(t *testing.T) {
// Modify app.toml.
appCfgTempFilePath := filepath.Join(tempDir, "config", "app.toml")
appConf := config.DefaultConfig()
appConf.BaseConfig.MinGasPrices = ""
appConf.MinGasPrices = ""
config.WriteConfigFile(appCfgTempFilePath, appConf)
// Run StartCmd.

View File

@ -45,7 +45,7 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd
AppState: appState,
Validators: validators,
Height: height,
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
ConsensusParams: app.GetConsensusParams(ctx),
}, err
}
@ -54,12 +54,9 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd
//
// in favor of export at a block height
func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false
applyAllowedAddrs := len(jailAllowedAddrs) > 0
// check if there is a allowed address list
if len(jailAllowedAddrs) > 0 {
applyAllowedAddrs = true
}
allowedAddrsMap := make(map[string]bool)

View File

@ -368,11 +368,8 @@ func (m *Manager) doRestoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.
return errorsmod.Wrap(err, "multistore restore")
}
for {
if nextItem.Item == nil {
// end of stream
break
}
for nextItem.Item != nil {
metadata := nextItem.GetExtension()
if metadata == nil {
return errorsmod.Wrapf(storetypes.ErrLogic, "unknown snapshot item %T", nextItem.Item)

View File

@ -846,11 +846,11 @@ type (
func (l *EventListener) Subscribe(query string, cb EventConsumer) func() {
ctx, done := context.WithCancel(context.Background())
l.t.Cleanup(done)
eventsChan, err := l.client.WSEvents.Subscribe(ctx, "testing", query)
eventsChan, err := l.client.Subscribe(ctx, "testing", query)
require.NoError(l.t, err)
cleanup := func() {
ctx, _ := context.WithTimeout(ctx, DefaultWaitTime) //nolint:govet // used in cleanup only
go l.client.WSEvents.Unsubscribe(ctx, "testing", query) //nolint:errcheck // used by tests only
ctx, _ := context.WithTimeout(ctx, DefaultWaitTime) //nolint:govet // used in cleanup only
go l.client.Unsubscribe(ctx, "testing", query) //nolint:errcheck // used by tests only
done()
}
go func() {

View File

@ -26,7 +26,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
&accountKeeper)
assert.NilError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
acc := accountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
assert.Assert(t, acc != nil)
}

View File

@ -293,8 +293,8 @@ func TestHandleDoubleSign_TooOld(t *testing.T) {
}},
})
assert.NilError(t, f.app.BaseApp.StoreConsensusParams(ctx, *simtestutil.DefaultConsensusParams))
cp := f.app.BaseApp.GetConsensusParams(ctx)
assert.NilError(t, f.app.StoreConsensusParams(ctx, *simtestutil.DefaultConsensusParams))
cp := f.app.GetConsensusParams(ctx)
ctx = ctx.WithCometInfo(nci)
ctx = ctx.WithConsensusParams(cp)

View File

@ -72,7 +72,7 @@ func TestImportExportQueues(t *testing.T) {
)
assert.NilError(t, err)
ctx := s1.app.BaseApp.NewContext(false)
ctx := s1.app.NewContext(false)
addrs := simtestutil.AddTestAddrs(s1.BankKeeper, s1.StakingKeeper, ctx, 1, valTokens)
_, err = s1.app.FinalizeBlock(&abci.RequestFinalizeBlock{
@ -80,7 +80,7 @@ func TestImportExportQueues(t *testing.T) {
})
assert.NilError(t, err)
ctx = s1.app.BaseApp.NewContext(false)
ctx = s1.app.NewContext(false)
// Create two proposals, put the second into the voting period
proposal1, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
@ -158,7 +158,7 @@ func TestImportExportQueues(t *testing.T) {
})
assert.NilError(t, err)
ctx2 := s2.app.BaseApp.NewContext(false)
ctx2 := s2.app.NewContext(false)
params, err = s2.GovKeeper.Params.Get(ctx2)
assert.NilError(t, err)

View File

@ -36,7 +36,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
)
assert.NilError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
acc := accountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
assert.Assert(t, acc != nil)
}

View File

@ -56,9 +56,9 @@ func initFixture(t assert.TestingT) *fixture {
)
assert.NilError(t, err)
f.ctx = app.BaseApp.NewContext(false)
f.ctx = app.NewContext(false)
queryHelper := &baseapp.QueryServiceTestHelper{
GRPCQueryRouter: app.BaseApp.GRPCQueryRouter(),
GRPCQueryRouter: app.GRPCQueryRouter(),
Ctx: f.ctx,
}
f.appQueryClient = appv1alpha1.NewQueryClient(queryHelper)

View File

@ -242,7 +242,7 @@ func createUpdateStep(oldKey, newKey string, oldEntry *parser.KeyValue) transfor
return nil
}
newEntry.KeyValue.Value = oldEntry.Value
newEntry.Value = oldEntry.Value
return nil
}),
}

View File

@ -433,7 +433,7 @@ func (l *Launcher) doPreUpgrade() error {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
switch exitErr.ProcessState.ExitCode() {
switch exitErr.ExitCode() {
case 1:
l.logger.Info("pre-upgrade command does not exist. continuing the upgrade.")
return nil

View File

@ -322,9 +322,9 @@ func (aa AccAddress) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(aa.String()))
case 'p':
_, _ = s.Write([]byte(fmt.Sprintf("%p", aa)))
_, _ = fmt.Fprintf(s, "%p", aa)
default:
_, _ = s.Write([]byte(fmt.Sprintf("%X", []byte(aa))))
_, _ = fmt.Fprintf(s, "%X", []byte(aa))
}
}
@ -486,9 +486,9 @@ func (va ValAddress) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(va.String()))
case 'p':
_, _ = s.Write([]byte(fmt.Sprintf("%p", va)))
_, _ = fmt.Fprintf(s, "%p", va)
default:
_, _ = s.Write([]byte(fmt.Sprintf("%X", []byte(va))))
_, _ = fmt.Fprintf(s, "%X", []byte(va))
}
}
@ -670,9 +670,9 @@ func (ca ConsAddress) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(ca.String()))
case 'p':
_, _ = s.Write([]byte(fmt.Sprintf("%p", ca)))
_, _ = fmt.Fprintf(s, "%p", ca)
default:
_, _ = s.Write([]byte(fmt.Sprintf("%X", []byte(ca))))
_, _ = fmt.Fprintf(s, "%X", []byte(ca))
}
}

View File

@ -81,7 +81,7 @@ func (s *paginationTestSuite) SetupTest() {
s.NoError(err)
ctx := app.BaseApp.NewContextLegacy(false, cmtproto.Header{Height: 1})
ctx := app.NewContextLegacy(false, cmtproto.Header{Height: 1})
s.ctx, s.bankKeeper, s.accountKeeper, s.cdc, s.app, s.interfaceReg = ctx, bankKeeper, accountKeeper, cdc, app, reg
}

View File

@ -27,7 +27,7 @@ func TestParseQueryResponse(t *testing.T) {
res, err := authclient.ParseQueryResponse(bz)
require.NoError(t, err)
require.Equal(t, 10, int(res.GasInfo.GasUsed))
require.Equal(t, 10, int(res.GasUsed))
require.NotNil(t, res.Result)
res, err = authclient.ParseQueryResponse([]byte("fuzzy"))

View File

@ -26,7 +26,7 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) {
)
require.NoError(b, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
// assumes b.N < 2**24
for i := 0; i < b.N; i++ {
@ -53,7 +53,7 @@ func BenchmarkAccountMapperSetAccount(b *testing.B) {
), &accountKeeper)
require.NoError(b, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
b.ResetTimer()

View File

@ -112,7 +112,7 @@ func (ss StdSignature) GetPubKey() cryptotypes.PubKey {
func (ss StdSignature) MarshalYAML() (interface{}, error) {
pk := ""
if ss.PubKey != nil {
pk = ss.PubKey.String()
pk = ss.String()
}
bz, err := yaml.Marshal(struct {

View File

@ -38,11 +38,11 @@ func (s *StdTxBuilder) SetSignatures(signatures ...signing.SignatureV2) error {
}
func (s *StdTxBuilder) SetFeeAmount(amount sdk.Coins) {
s.StdTx.Fee.Amount = amount
s.Fee.Amount = amount
}
func (s *StdTxBuilder) SetGasLimit(limit uint64) {
s.StdTx.Fee.Gas = limit
s.Fee.Gas = limit
}
// SetMemo implements TxBuilder.SetMemo

View File

@ -73,7 +73,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
legacySubspace := newMockSubspace(authtypes.DefaultParams())
require.NoError(t, v4.Migrate(ctx, storeService, legacySubspace, cdc))
ctx = app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
ctx = app.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
require.NoError(t, stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams()))
lastAccNum := uint64(1000)
createBaseAccount := func(addr sdk.AccAddress) *authtypes.BaseAccount {

View File

@ -69,7 +69,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
randAccNumber := uint64(rand.Intn(100000-10000) + 10000)
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), randAccNumber, 0)
ctx = app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
ctx = app.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
// migrator
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter(), legacySubspace)

View File

@ -24,7 +24,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
&accountKeeper)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
acc := accountKeeper.GetAccount(ctx, types.NewModuleAddress(types.FeeCollectorName))
require.NotNil(t, acc)
}

View File

@ -30,7 +30,7 @@ func RandomGenesisAccounts(simState *module.SimulationState) types.GenesisAccoun
// Only consider making a vesting account once the initial bonded validator
// set is exhausted due to needing to track DelegatedVesting.
if !(int64(i) > simState.NumBonded && simState.Rand.Intn(100) < 50) {
if int64(i) <= simState.NumBonded || simState.Rand.Intn(100) >= 50 {
genesisAccs[i] = bacc
continue
}

View File

@ -48,20 +48,20 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
}
ctx := sdk.UnwrapSDKContext(goCtx)
if err := s.BankKeeper.IsSendEnabledCoins(ctx, msg.Amount...); err != nil {
if err := s.IsSendEnabledCoins(ctx, msg.Amount...); err != nil {
return nil, err
}
if s.BankKeeper.BlockedAddr(to) {
if s.BlockedAddr(to) {
return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
}
if acc := s.AccountKeeper.GetAccount(ctx, to); acc != nil {
if acc := s.GetAccount(ctx, to); acc != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress)
}
baseAccount := authtypes.NewBaseAccountWithAddress(to)
baseAccount = s.AccountKeeper.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
baseAccount = s.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
baseVestingAccount, err := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime)
if err != nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
@ -74,7 +74,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
vestingAccount = types.NewContinuousVestingAccountRaw(baseVestingAccount, ctx.BlockTime().Unix())
}
s.AccountKeeper.SetAccount(ctx, vestingAccount)
s.SetAccount(ctx, vestingAccount)
defer func() {
telemetry.IncrCounter(1, "new", "account")
@ -90,7 +90,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
}
}()
if err = s.BankKeeper.SendCoins(ctx, from, to, msg.Amount); err != nil {
if err = s.SendCoins(ctx, from, to, msg.Amount); err != nil {
return nil, err
}
@ -113,26 +113,26 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *type
}
ctx := sdk.UnwrapSDKContext(goCtx)
if err := s.BankKeeper.IsSendEnabledCoins(ctx, msg.Amount...); err != nil {
if err := s.IsSendEnabledCoins(ctx, msg.Amount...); err != nil {
return nil, err
}
if s.BankKeeper.BlockedAddr(to) {
if s.BlockedAddr(to) {
return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
}
if acc := s.AccountKeeper.GetAccount(ctx, to); acc != nil {
if acc := s.GetAccount(ctx, to); acc != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress)
}
baseAccount := authtypes.NewBaseAccountWithAddress(to)
baseAccount = s.AccountKeeper.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
baseAccount = s.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
vestingAccount, err := types.NewPermanentLockedAccount(baseAccount, msg.Amount)
if err != nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
s.AccountKeeper.SetAccount(ctx, vestingAccount)
s.SetAccount(ctx, vestingAccount)
defer func() {
telemetry.IncrCounter(1, "new", "account")
@ -148,7 +148,7 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *type
}
}()
if err = s.BankKeeper.SendCoins(ctx, from, to, msg.Amount); err != nil {
if err = s.SendCoins(ctx, from, to, msg.Amount); err != nil {
return nil, err
}
@ -183,27 +183,27 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
totalCoins = totalCoins.Add(period.Amount...)
}
if s.BankKeeper.BlockedAddr(to) {
if s.BlockedAddr(to) {
return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress)
}
ctx := sdk.UnwrapSDKContext(goCtx)
if acc := s.AccountKeeper.GetAccount(ctx, to); acc != nil {
if acc := s.GetAccount(ctx, to); acc != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress)
}
if err := s.BankKeeper.IsSendEnabledCoins(ctx, totalCoins...); err != nil {
if err := s.IsSendEnabledCoins(ctx, totalCoins...); err != nil {
return nil, err
}
baseAccount := authtypes.NewBaseAccountWithAddress(to)
baseAccount = s.AccountKeeper.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
baseAccount = s.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
vestingAccount, err := types.NewPeriodicVestingAccount(baseAccount, totalCoins.Sort(), msg.StartTime, msg.VestingPeriods)
if err != nil {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
s.AccountKeeper.SetAccount(ctx, vestingAccount)
s.SetAccount(ctx, vestingAccount)
defer func() {
telemetry.IncrCounter(1, "new", "account")
@ -219,7 +219,7 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
}
}()
if err = s.BankKeeper.SendCoins(ctx, from, to, totalCoins); err != nil {
if err = s.SendCoins(ctx, from, to, totalCoins); err != nil {
return nil, err
}

View File

@ -229,7 +229,7 @@ func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coi
// LockedCoins returns the set of coins that are not spendable (i.e. locked),
// defined as the vesting coins that are not delegated.
func (cva ContinuousVestingAccount) LockedCoins(blockTime time.Time) sdk.Coins {
return cva.BaseVestingAccount.LockedCoinsFromVesting(cva.GetVestingCoins(blockTime))
return cva.LockedCoinsFromVesting(cva.GetVestingCoins(blockTime))
}
// TrackDelegation tracks a desired delegation amount by setting the appropriate
@ -334,7 +334,7 @@ func (pva PeriodicVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
// LockedCoins returns the set of coins that are not spendable (i.e. locked),
// defined as the vesting coins that are not delegated.
func (pva PeriodicVestingAccount) LockedCoins(blockTime time.Time) sdk.Coins {
return pva.BaseVestingAccount.LockedCoinsFromVesting(pva.GetVestingCoins(blockTime))
return pva.LockedCoinsFromVesting(pva.GetVestingCoins(blockTime))
}
// TrackDelegation tracks a desired delegation amount by setting the appropriate
@ -433,7 +433,7 @@ func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
// LockedCoins returns the set of coins that are not spendable (i.e. locked),
// defined as the vesting coins that are not delegated.
func (dva DelayedVestingAccount) LockedCoins(blockTime time.Time) sdk.Coins {
return dva.BaseVestingAccount.LockedCoinsFromVesting(dva.GetVestingCoins(blockTime))
return dva.LockedCoinsFromVesting(dva.GetVestingCoins(blockTime))
}
// TrackDelegation tracks a desired delegation amount by setting the appropriate
@ -489,7 +489,7 @@ func (plva PermanentLockedAccount) GetVestingCoins(_ time.Time) sdk.Coins {
// LockedCoins returns the set of coins that are not spendable (i.e. locked),
// defined as the vesting coins that are not delegated.
func (plva PermanentLockedAccount) LockedCoins(_ time.Time) sdk.Coins {
return plva.BaseVestingAccount.LockedCoinsFromVesting(plva.OriginalVesting)
return plva.LockedCoinsFromVesting(plva.OriginalVesting)
}
// TrackDelegation tracks a desired delegation amount by setting the appropriate

View File

@ -61,7 +61,7 @@ func (suite *SimTestSuite) SetupTest() {
)
suite.Require().NoError(err)
suite.app = app
suite.ctx = app.BaseApp.NewContext(false)
suite.ctx = app.NewContext(false)
}
func (suite *SimTestSuite) TestWeightedOperations() {

View File

@ -374,7 +374,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
genAccs := []authtypes.GenesisAccount{acc1}
s := createTestSuite(t, genAccs)
ctx := s.App.BaseApp.NewContext(false)
ctx := s.App.NewContext(false)
require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 101))))
require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("stake", 100000))))
addr1Str := addr1.String()

View File

@ -2286,10 +2286,7 @@ func (suite *KeeperTestSuite) TestIterateSendEnabledEntries() {
suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) {
bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) {
seen = append(seen, denom)
exp := true
if strings.HasSuffix(denom, "false") {
exp = false
}
exp := !strings.HasSuffix(denom, "false")
require.Equal(exp, sendEnabled, denom)
return false

View File

@ -61,7 +61,7 @@ func (suite *SimTestSuite) SetupTest() {
suite.NoError(err)
suite.ctx = suite.app.BaseApp.NewContext(false)
suite.ctx = suite.app.NewContext(false)
}
// TestWeightedOperations tests the weights of the operations.

View File

@ -276,7 +276,7 @@ func (suite *SimTestSuite) SetupTest() {
suite.NoError(err)
suite.ctx = suite.app.BaseApp.NewContext(false)
suite.ctx = suite.app.NewContext(false)
genesisVals, err := suite.stakingKeeper.GetAllValidators(suite.ctx)
suite.Require().NoError(err)

View File

@ -28,7 +28,7 @@ func NewQuerier(k Keeper) Querier {
func (q Querier) EpochInfos(ctx context.Context, _ *types.QueryEpochInfosRequest) (*types.QueryEpochInfosResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
epochs, err := q.Keeper.AllEpochInfos(sdkCtx)
epochs, err := q.AllEpochInfos(sdkCtx)
return &types.QueryEpochInfosResponse{
Epochs: epochs,
}, err
@ -43,7 +43,7 @@ func (q Querier) CurrentEpoch(ctx context.Context, req *types.QueryCurrentEpochR
return nil, status.Error(codes.InvalidArgument, "identifier is empty")
}
info, err := q.Keeper.EpochInfo.Get(ctx, req.Identifier)
info, err := q.EpochInfo.Get(ctx, req.Identifier)
if err != nil {
return nil, errors.New("not available identifier")
}

View File

@ -86,14 +86,15 @@ func (s *KeeperTestSuite) TestHooksPanicRecovery() {
hooks := types.NewMultiEpochHooks(hookRefs...)
if epochActionSelector == 0 {
switch epochActionSelector {
case 0:
err := hooks.BeforeEpochStart(s.Ctx, "id", 0)
if tc.expErr {
s.Require().Error(err)
} else {
s.Require().NoError(err)
}
} else if epochActionSelector == 1 {
case 1:
err := hooks.AfterEpochEnd(s.Ctx, "id", 0)
if tc.expErr {
s.Require().Error(err)

View File

@ -40,7 +40,7 @@ func (suite *GenesisTestSuite) SetupTest() {
&evidenceKeeper)
require.NoError(suite.T(), err)
suite.ctx = app.BaseApp.NewContextLegacy(false, cmtproto.Header{Height: 1})
suite.ctx = app.NewContextLegacy(false, cmtproto.Header{Height: 1})
suite.keeper = evidenceKeeper
}

View File

@ -82,7 +82,7 @@ func (k msgServer) RevokeAllowance(goCtx context.Context, msg *feegrant.MsgRevok
return nil, err
}
err = k.Keeper.revokeAllowance(ctx, granter, grantee)
err = k.revokeAllowance(ctx, granter, grantee)
if err != nil {
return nil, err
}

View File

@ -79,7 +79,7 @@ func (suite *SimTestSuite) SetupTest() {
)
suite.Require().NoError(err)
suite.ctx = suite.app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
suite.ctx = suite.app.NewContextLegacy(false, cmtproto.Header{Time: time.Now()})
}
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {

View File

@ -146,7 +146,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {
// the deposit at this point since the proposal is converted to regular.
// As a result, the deposits are either deleted or refunded in all cases
// EXCEPT when an expedited proposal fails.
if !(proposal.Expedited && !passes) {
if !proposal.Expedited || passes {
if burnDeposits {
err = keeper.DeleteAndBurnDeposits(ctx, proposal.Id)
} else {

View File

@ -24,7 +24,7 @@ import (
func TestUnregisteredProposal_InactiveProposalFails(t *testing.T) {
suite := createTestSuite(t)
ctx := suite.App.BaseApp.NewContext(false)
ctx := suite.App.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens)
// manually set proposal in store
@ -52,7 +52,7 @@ func TestUnregisteredProposal_InactiveProposalFails(t *testing.T) {
func TestUnregisteredProposal_ActiveProposalFails(t *testing.T) {
suite := createTestSuite(t)
ctx := suite.App.BaseApp.NewContext(false)
ctx := suite.App.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens)
// manually set proposal in store
@ -84,7 +84,7 @@ func TestUnregisteredProposal_ActiveProposalFails(t *testing.T) {
func TestTickExpiredDepositPeriod(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens)
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
@ -136,7 +136,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens)
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
@ -208,7 +208,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
func TestTickPassedDepositPeriod(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens)
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
@ -271,7 +271,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
depositMultiplier := getDepositMultiplier(tc.expedited)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens.Mul(math.NewInt(depositMultiplier)))
@ -363,7 +363,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
depositMultiplier := getDepositMultiplier(tc.expedited)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens.Mul(math.NewInt(depositMultiplier)))
@ -426,7 +426,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
func TestEndBlockerProposalHandlerFailed(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 1, valTokens)
SortAddresses(addrs)
@ -508,7 +508,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
depositMultiplier := getDepositMultiplier(true)
addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 3, valTokens.Mul(math.NewInt(depositMultiplier)))
params, err := suite.GovKeeper.Params.Get(ctx)

View File

@ -15,7 +15,7 @@ import (
func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) {
suite := createTestSuite(t)
app := suite.App
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
require.Panics(t, func() {
gov.InitGenesis(ctx, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, &v1.GenesisState{
Deposits: v1.Deposits{

View File

@ -377,9 +377,10 @@ func TestChargeDeposit(t *testing.T) {
for _, tc := range testCases {
for i := 0; i < 3; i++ {
testName := func(i int) string {
if i == 0 {
switch i {
case 0:
return fmt.Sprintf("%s and dest address is %s", tc.name, "nil")
} else if i == 1 {
case 1:
return fmt.Sprintf("%s and dest address is normal address", tc.name)
}
return fmt.Sprintf("%s and dest address is community address", tc.name)

View File

@ -256,11 +256,11 @@ func (q queryServer) TallyResult(ctx context.Context, req *v1.QueryTallyResultRe
var tallyResult v1.TallyResult
switch {
case proposal.Status == v1.StatusDepositPeriod:
switch proposal.Status {
case v1.StatusDepositPeriod:
tallyResult = v1.EmptyTallyResult()
case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected || proposal.Status == v1.StatusFailed:
case v1.StatusPassed, v1.StatusRejected, v1.StatusFailed:
tallyResult = *proposal.FinalTallyResult
default:

View File

@ -100,7 +100,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos
"submit proposal",
)
votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.Id, proposer, msg.GetInitialDeposit())
votingStarted, err := k.AddDeposit(ctx, proposal.Id, proposer, msg.GetInitialDeposit())
if err != nil {
return nil, err
}
@ -160,11 +160,11 @@ func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegac
}
// Ensure that the content has a respective handler
if !k.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) {
if !k.legacyRouter.HasRoute(content.ProposalRoute()) {
return nil, errors.Wrap(govtypes.ErrNoProposalHandlerExists, content.ProposalRoute())
}
handler := k.Keeper.legacyRouter.GetRoute(content.ProposalRoute())
handler := k.legacyRouter.GetRoute(content.ProposalRoute())
if err := handler(ctx, content); err != nil {
return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err)
}
@ -184,7 +184,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp
}
ctx := sdk.UnwrapSDKContext(goCtx)
err = k.Keeper.AddVote(ctx, msg.ProposalId, accAddr, v1.NewNonSplitVoteOption(msg.Option), msg.Metadata)
err = k.AddVote(ctx, msg.ProposalId, accAddr, v1.NewNonSplitVoteOption(msg.Option), msg.Metadata)
if err != nil {
return nil, err
}
@ -229,7 +229,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted)
}
ctx := sdk.UnwrapSDKContext(goCtx)
err := k.Keeper.AddVote(ctx, msg.ProposalId, accAddr, msg.Options, msg.Metadata)
err := k.AddVote(ctx, msg.ProposalId, accAddr, msg.Options, msg.Metadata)
if err != nil {
return nil, err
}
@ -249,7 +249,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
}
ctx := sdk.UnwrapSDKContext(goCtx)
votingStarted, err := k.Keeper.AddDeposit(ctx, msg.ProposalId, accAddr, msg.Amount)
votingStarted, err := k.AddDeposit(ctx, msg.ProposalId, accAddr, msg.Amount)
if err != nil {
return nil, err
}

View File

@ -434,7 +434,7 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) {
&res.TxConfig, &res.AccountKeeper, &res.BankKeeper, &res.GovKeeper, &res.StakingKeeper, &res.DistributionKeeper)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(isCheckTx)
ctx := app.NewContext(isCheckTx)
res.App = app
return res, ctx

View File

@ -115,7 +115,7 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) {
_, _ = s.Write([]byte(status.String()))
default:
// TODO: Do this conversion more directly
_, _ = s.Write([]byte(fmt.Sprintf("%v", byte(status))))
_, _ = fmt.Fprintf(s, "%v", byte(status))
}
}

View File

@ -147,6 +147,6 @@ func (vo VoteOption) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(vo.String()))
default:
_, _ = s.Write([]byte(fmt.Sprintf("%v", byte(vo))))
_, _ = fmt.Fprintf(s, "%v", byte(vo))
}
}

View File

@ -142,7 +142,7 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(status.String()))
default:
_, _ = s.Write([]byte(fmt.Sprintf("%v", byte(status))))
_, _ = fmt.Fprintf(s, "%v", byte(status))
}
}

View File

@ -122,6 +122,6 @@ func (vo VoteOption) Format(s fmt.State, verb rune) {
case 's':
_, _ = s.Write([]byte(vo.String()))
default:
_, _ = s.Write([]byte(fmt.Sprintf("%v", byte(vo))))
_, _ = fmt.Fprintf(s, "%v", byte(vo))
}
}

View File

@ -106,7 +106,7 @@ func (a PrimaryKeyTable) Has(store storetypes.KVStore, primaryKey RowID) bool {
// Contains returns true when an object with same type and primary key is persisted in this table.
func (a PrimaryKeyTable) Contains(store storetypes.KVStore, obj PrimaryKeyed) bool {
if err := assertCorrectType(a.table.model, obj); err != nil {
if err := assertCorrectType(a.model, obj); err != nil {
return false
}
return a.table.Has(store, PrimaryKey(obj))

View File

@ -409,7 +409,8 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error {
}
proposalID := proposal.Id
if proposal.Status == group.PROPOSAL_STATUS_ABORTED || proposal.Status == group.PROPOSAL_STATUS_WITHDRAWN {
switch proposal.Status {
case group.PROPOSAL_STATUS_ABORTED, group.PROPOSAL_STATUS_WITHDRAWN:
if err := k.pruneProposal(ctx, proposalID); err != nil {
return err
}
@ -424,7 +425,7 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error {
}); err != nil {
return err
}
} else if proposal.Status == group.PROPOSAL_STATUS_SUBMITTED {
case group.PROPOSAL_STATUS_SUBMITTED:
if err := k.doTallyAndUpdate(ctx, &proposal, electorate, policyInfo); err != nil {
return errorsmod.Wrap(err, "doTallyAndUpdate")
}

View File

@ -1895,7 +1895,7 @@ func (s *TestSuite) TestSubmitProposal() {
s.Require().NoError(err)
id := res.ProposalId
if !(spec.expProposal.ExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS) {
if spec.expProposal.ExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS {
// then all data persisted
proposalRes, err := s.groupKeeper.Proposal(s.ctx, &group.QueryProposalRequest{ProposalId: id})
s.Require().NoError(err)
@ -2410,7 +2410,7 @@ func (s *TestSuite) TestVote() {
}
s.Require().NoError(err)
if !(spec.expExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS) {
if spec.expExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS {
// vote is stored and all data persisted
res, err := s.groupKeeper.VoteByProposalVoter(sdkCtx, &group.QueryVoteByProposalVoterRequest{
ProposalId: spec.req.ProposalId,
@ -2762,7 +2762,7 @@ func (s *TestSuite) TestExecProposal() {
}
s.Require().NoError(err)
if !(spec.expExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS) {
if spec.expExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS {
// and proposal is updated
res, err := s.groupKeeper.Proposal(sdkCtx, &group.QueryProposalRequest{ProposalId: proposalID})

View File

@ -58,7 +58,7 @@ func (s *IntegrationTestSuite) SetupTest() {
)
s.Require().NoError(err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
ctx = ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()})

View File

@ -58,7 +58,7 @@ func (suite *SimTestSuite) SetupTest() {
suite.Require().NoError(err)
suite.app = app
suite.ctx = app.BaseApp.NewContext(false)
suite.ctx = app.NewContext(false)
}
func (suite *SimTestSuite) TestWeightedOperations() {

View File

@ -25,7 +25,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
), &accountKeeper)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
acc := accountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
require.NotNil(t, acc)
}

View File

@ -60,7 +60,7 @@ func (suite *SimTestSuite) SetupTest() {
suite.Require().NoError(err)
suite.app = app
suite.ctx = app.BaseApp.NewContext(false)
suite.ctx = app.NewContext(false)
}
func (suite *SimTestSuite) TestWeightedOperations() {

View File

@ -141,12 +141,13 @@ func RandomRequestFinalizeBlock(
mVal.livenessState = params.LivenessTransitionMatrix().NextState(r, mVal.livenessState)
signed := true
if mVal.livenessState == 1 {
switch mVal.livenessState {
case 1:
// spotty connection, 50% probability of success
// See https://github.com/golang/go/issues/23804#issuecomment-365370418
// for reasoning behind computing like this
signed = r.Int63()%2 == 0
} else if mVal.livenessState == 2 {
case 2:
// offline
signed = false
}

View File

@ -43,7 +43,7 @@ func TestBeginBlocker(t *testing.T) {
)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
pks := simtestutil.CreateTestPubKeys(1)
simtestutil.AddTestAddrsFromPubKeys(bankKeeper, stakingKeeper, ctx, pks, stakingKeeper.TokensFromConsensusPower(ctx, 200))

View File

@ -103,7 +103,7 @@ func TestSlashingMsgs(t *testing.T) {
require.True(math.IntEq(t, bondTokens, validator.BondedTokens()))
unjailMsg := &types.MsgUnjail{ValidatorAddr: sdk.ValAddress(addr1).String()}
ctxCheck = app.BaseApp.NewContext(true)
ctxCheck = app.NewContext(true)
_, err = slashingKeeper.GetValidatorSigningInfo(ctxCheck, sdk.ConsAddress(valAddr))
require.NoError(t, err)

View File

@ -38,7 +38,7 @@ func TestSlashRedelegation(t *testing.T) {
require.NoError(t, err)
// get sdk context, staking msg server and bond denom
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
stakingMsgServer := stakingkeeper.NewMsgServerImpl(stakingKeeper)
bondDenom, err := stakingKeeper.BondDenom(ctx)
require.NoError(t, err)

View File

@ -99,7 +99,7 @@ func (suite *SimTestSuite) SetupTest() {
suite.Require().NoError(err)
suite.app = app
suite.ctx = app.BaseApp.NewContext(false)
suite.ctx = app.NewContext(false)
// remove genesis validator account
suite.accounts = accounts[1:]

View File

@ -61,7 +61,7 @@ func TestStakingMsgs(t *testing.T) {
),
startupCfg, &bankKeeper, &stakingKeeper)
require.NoError(t, err)
ctxCheck := app.BaseApp.NewContext(true)
ctxCheck := app.NewContext(true)
require.True(t, sdk.Coins{genCoin}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1)))
require.True(t, sdk.Coins{genCoin}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr2)))
@ -81,7 +81,7 @@ func TestStakingMsgs(t *testing.T) {
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
require.NoError(t, err)
ctxCheck = app.BaseApp.NewContext(true)
ctxCheck = app.NewContext(true)
validator, err := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1))
require.NoError(t, err)
@ -100,7 +100,7 @@ func TestStakingMsgs(t *testing.T) {
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1)
require.NoError(t, err)
ctxCheck = app.BaseApp.NewContext(true)
ctxCheck = app.NewContext(true)
validator, err = stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1))
require.NoError(t, err)
require.Equal(t, description, validator.Description)
@ -113,7 +113,7 @@ func TestStakingMsgs(t *testing.T) {
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2)
require.NoError(t, err)
ctxCheck = app.BaseApp.NewContext(true)
ctxCheck = app.NewContext(true)
require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr2)))
_, err = stakingKeeper.GetDelegation(ctxCheck, addr2, sdk.ValAddress(addr1))
require.NoError(t, err)
@ -125,7 +125,7 @@ func TestStakingMsgs(t *testing.T) {
require.NoError(t, err)
// delegation should exist anymore
ctxCheck = app.BaseApp.NewContext(true)
ctxCheck = app.NewContext(true)
_, err = stakingKeeper.GetDelegation(ctxCheck, addr2, sdk.ValAddress(addr1))
require.ErrorIs(t, err, types.ErrNoDelegation)

View File

@ -34,7 +34,7 @@ func (k Querier) Validators(ctx context.Context, req *types.QueryValidatorsReque
}
// validate the provided status, return all the validators if the status is empty
if req.Status != "" && !(req.Status == types.Bonded.String() || req.Status == types.Unbonded.String() || req.Status == types.Unbonding.String()) {
if req.Status != "" && (req.Status != types.Bonded.String() && req.Status != types.Unbonded.String() && req.Status != types.Unbonding.String()) {
return nil, status.Errorf(codes.InvalidArgument, "invalid validator status %s", req.Status)
}

View File

@ -24,7 +24,7 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
), &accountKeeper)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
acc := accountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.BondedPoolName))
require.NotNil(t, acc)

View File

@ -64,9 +64,9 @@ func TestRandomizedGenState(t *testing.T) {
require.Equal(t, "BOND_STATUS_UNBONDED", stakingGenesis.Validators[2].Status.String())
require.Equal(t, "1000", stakingGenesis.Validators[2].Tokens.String())
require.Equal(t, "1000.000000000000000000", stakingGenesis.Validators[2].DelegatorShares.String())
require.Equal(t, "0.292059246265731326", stakingGenesis.Validators[2].Commission.CommissionRates.Rate.String())
require.Equal(t, "0.330000000000000000", stakingGenesis.Validators[2].Commission.CommissionRates.MaxRate.String())
require.Equal(t, "0.038337453731274481", stakingGenesis.Validators[2].Commission.CommissionRates.MaxChangeRate.String())
require.Equal(t, "0.292059246265731326", stakingGenesis.Validators[2].Commission.Rate.String())
require.Equal(t, "0.330000000000000000", stakingGenesis.Validators[2].Commission.MaxRate.String())
require.Equal(t, "0.038337453731274481", stakingGenesis.Validators[2].Commission.MaxChangeRate.String())
require.Equal(t, "1", stakingGenesis.Validators[2].MinSelfDelegation.String())
}

View File

@ -96,7 +96,7 @@ func (s *SimTestSuite) SetupTest() {
app, err := simtestutil.SetupWithConfiguration(cfg, startupCfg, &s.txConfig, &bankKeeper, &accountKeeper, &mintKeeper, &distrKeeper, &stakingKeeper)
require.NoError(s.T(), err)
ctx := app.BaseApp.NewContext(false)
ctx := app.NewContext(false)
s.Require().NoError(mintKeeper.Params.Set(ctx, minttypes.DefaultParams()))
s.Require().NoError(mintKeeper.Minter.Set(ctx, minttypes.DefaultInitialMinter()))

View File

@ -28,10 +28,7 @@ func (sr boolValueRenderer) Parse(_ context.Context, screens []Screen) (protoref
return protoreflect.Value{}, fmt.Errorf("expected single screen: %v", screens)
}
res := false
if screens[0].Content == "True" {
res = true
}
res := screens[0].Content == "True"
return protoreflect.ValueOfBool(res), nil
}