Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Jan 6, 2025
1 parent 068629b commit 2877f68
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions server/v2/appmanager/appmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (a appManager[T]) DeliverBlock(

return blockResponse, newState, nil
}

func (a appManager[T]) DeliverSims(
ctx context.Context,
block *server.BlockRequest[T],
Expand Down
7 changes: 5 additions & 2 deletions server/v2/stf/sims_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package stf

import (
"context"

"iter"

"cosmossdk.io/core/header"
"cosmossdk.io/core/server"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
"iter"
)

// doSimsTXs constructs a function to simulate transactions in a block execution context using the provided simsBuilder.
Expand All @@ -17,7 +19,8 @@ func (s STF[T]) doSimsTXs(simsBuilder func(ctx context.Context) iter.Seq[T]) doI
newState store.WriterMap,
hi header.Info,
) ([]server.TxResult, error) {
simsCtx := context.WithValue(exCtx, "sims.header.time", hi.Time) // using string key to decouple
const key = "sims.header.time"
simsCtx := context.WithValue(exCtx, key, hi.Time) //nolint: staticcheck // using string key to decouple
var results []server.TxResult
var i int32
for tx := range simsBuilder(simsCtx) {
Expand Down
3 changes: 2 additions & 1 deletion server/v2/stf/stf.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"encoding/json"
"errors"
"fmt"
"iter"
"strings"

"iter"

appmodulev2 "cosmossdk.io/core/appmodule/v2"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/event"
Expand Down
3 changes: 2 additions & 1 deletion server/v2/streaming/examples/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"os"
"path/filepath"

"cosmossdk.io/server/v2/streaming"
"github.com/hashicorp/go-plugin"

"cosmossdk.io/server/v2/streaming"
)

// FilePlugin is the implementation of the baseapp.ABCIListener interface
Expand Down
13 changes: 5 additions & 8 deletions simapp/v2/sim_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type (
)

func SetupTestInstance[T Tx, V SimulationApp[T]](t *testing.T, factory AppFactory[T, V], appConfig depinject.Config) TestInstance[T] {
t.Helper()
nodeHome := t.TempDir()
currentDir, err := os.Getwd()
require.NoError(t, err)
Expand Down Expand Up @@ -168,6 +169,7 @@ func RunWithSeeds[T Tx](t *testing.T, seeds []int64) {
}

func RunWithSeed[T Tx, V SimulationApp[T]](t *testing.T, appFactory AppFactory[T, V], appConfig depinject.Config, tCfg simtypes.Config, seed int64) {
t.Helper()
r := rand.New(rand.NewSource(seed))
testInstance := SetupTestInstance[T, V](t, appFactory, appConfig)
accounts, genesisAppState, chainID, genesisTimestamp := prepareInitialGenesisState(testInstance.App, r, testInstance.BankKeeper, tCfg, testInstance.ModuleManager)
Expand Down Expand Up @@ -248,6 +250,7 @@ func doChainInitWithGenesis[T Tx](
genesisAppState json.RawMessage,
appStore cometbfttypes.Store,
) (*server.BlockResponse, store.Hash) {
t.Helper()
genesisReq := &server.BlockRequest[T]{
Height: 0,
Time: genesisTimestamp,
Expand Down Expand Up @@ -305,6 +308,7 @@ func doMainLoop[T Tx](
txBuilder simsxv2.TXBuilder[T],
stakingKeeper StakingKeeper,
) {
t.Helper()
blockTime := cs.blockTime
activeValidatorSet := cs.activeValidatorSet
if len(activeValidatorSet) == 0 {
Expand Down Expand Up @@ -411,14 +415,7 @@ func doMainLoop[T Tx](
require.NoError(t, resultHandlers[i](v.Error))
}
txTotalCounter += txPerBlockCounter
var removed int
for _, v := range blockRsp.ValidatorUpdates {
if v.Power == 0 {
removed++
}
}
activeValidatorSet = activeValidatorSet.Update(blockRsp.ValidatorUpdates)
// fmt.Printf("active validator set after height %d: %d, %s, %X\n", blockReqN.Height, len(activeValidatorSet), blockReqN.Time, stateRoot)
}
fmt.Println("+++ reporter:\n" + rootReporter.Summary().String())
fmt.Printf("Tx total: %d skipped: %d\n", txTotalCounter, txSkippedCounter)
Expand All @@ -435,7 +432,7 @@ func prepareSimsMsgFactories(
// get all proposal types
proposalRegistry := simsx.NewUniqueTypeRegistry()
for _, n := range moduleNames {
switch xm := modules[n].(type) {
switch xm := modules[n].(type) { // nolint: gocritic // extended in the future
case HasProposalMsgsX:
xm.ProposalMsgsX(weights, proposalRegistry)
// todo: register legacy and v1 msg proposals
Expand Down
3 changes: 1 addition & 2 deletions simsx/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package simsx
import (
"cmp"
"context"
"iter"
"maps"
"math/rand"
"slices"
"strings"
"time"

"iter"

"cosmossdk.io/core/address"
"cosmossdk.io/core/log"

Expand Down
2 changes: 1 addition & 1 deletion simsx/v2/valset_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewValSetHistory(maxElements int) *ValSetHistory {
}

func (h *ValSetHistory) Add(blockTime time.Time, vals WeightedValidators) {
slices.DeleteFunc(vals, func(validator WeightedValidator) bool {
vals = slices.DeleteFunc(vals, func(validator WeightedValidator) bool {
return validator.Power == 0
})
slices.SortFunc(vals, func(a, b WeightedValidator) int {
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/v2/types/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"
)

const (
balancesPrefix = 0x2
)

type fuzzTestSuite struct {
paginationTestSuite
}
Expand Down

0 comments on commit 2877f68

Please sign in to comment.