Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitys7 committed Oct 9, 2024
1 parent 844c50d commit 56fc9b4
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 109 deletions.
19 changes: 10 additions & 9 deletions test/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,48 @@ import (
"os"
"path/filepath"

dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
multistaking "github.com/realio-tech/multi-staking-module/x/multi-staking"
multistakingkeeper "github.com/realio-tech/multi-staking-module/x/multi-staking/keeper"
multistakingtypes "github.com/realio-tech/multi-staking-module/x/multi-staking/types"
"github.com/spf13/cast"

"cosmossdk.io/log"
simappparams "cosmossdk.io/simapp/params"

storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/evidence"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
evidencetypes "cosmossdk.io/x/evidence/types"
"cosmossdk.io/x/feegrant"
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
feegrantmodule "cosmossdk.io/x/feegrant/module"
"cosmossdk.io/x/tx/signing"
"cosmossdk.io/x/upgrade"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
Expand Down Expand Up @@ -85,17 +93,10 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"cosmossdk.io/log"
"cosmossdk.io/x/tx/signing"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
tmos "github.com/cometbft/cometbft/libs/os"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/std"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/cosmos/gogoproto/proto"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
)

Expand Down
1 change: 1 addition & 0 deletions test/simapp/app_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package simapp

import (
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down
24 changes: 17 additions & 7 deletions test/simapp/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"log"

storetypes "cosmossdk.io/store/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

storetypes "cosmossdk.io/store/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
)

Expand All @@ -32,6 +33,9 @@ func (app *SimApp) ExportAppStateAndValidators(
}

genState, err := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
if err != nil {
return servertypes.ExportedApp{}, err
}
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
Expand Down Expand Up @@ -175,22 +179,28 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetRedelegation(ctx, red)
return false
err = app.StakingKeeper.SetRedelegation(ctx, red)
return err != nil
})
if err != nil {
panic(err)
}

// iterate through unbonding delegations, reset creation height
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
return false
err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
return err != nil
})
if err != nil {
panic(err)
}

// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
Expand Down
18 changes: 11 additions & 7 deletions test/simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import (
"os"
"testing"

dbm "github.com/cosmos/cosmos-db"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"

"cosmossdk.io/log"
"cosmossdk.io/store"
storetypes "cosmossdk.io/store/types"
evidencetypes "cosmossdk.io/x/evidence/types"

"github.com/cosmos/cosmos-sdk/baseapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
Expand All @@ -25,11 +30,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
dbm "github.com/cosmos/cosmos-db"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/rs/zerolog"
)

// Get flags every time the simulator is run
Expand Down Expand Up @@ -157,8 +158,10 @@ func TestAppImportExport(t *testing.T) {

ctxA := app.NewContext(true)
ctxB := newApp.NewContext(true)
newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
_, err = newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
require.NoError(t, err)
err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
require.NoError(t, err)

fmt.Printf("comparing stores...\n")

Expand Down Expand Up @@ -256,9 +259,10 @@ func TestAppSimulationAfterImport(t *testing.T) {
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "SimApp", newApp.Name())

newApp.InitChain(&abci.RequestInitChain{
_, err = newApp.InitChain(&abci.RequestInitChain{
AppStateBytes: exported.AppState,
})
require.NoError(t, err)

_, _, err = simulation.SimulateFromSeed(
t,
Expand Down
2 changes: 1 addition & 1 deletion test/simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"

dbm "github.com/cosmos/cosmos-db"
rosettaCmd "github.com/cosmos/rosetta/cmd"
"github.com/realio-tech/multi-staking-module/test/simapp"
"github.com/spf13/cast"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -37,7 +38,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
rosettaCmd "github.com/cosmos/rosetta/cmd"

tmcfg "github.com/cometbft/cometbft/config"
tmcli "github.com/cometbft/cometbft/libs/cli"
Expand Down
5 changes: 3 additions & 2 deletions test/simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (

"github.com/spf13/cobra"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/testutil"
Expand All @@ -29,13 +32,11 @@ import (
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"cosmossdk.io/math"
tmconfig "github.com/cometbft/cometbft/config"
tmos "github.com/cometbft/cometbft/libs/os"
tmrand "github.com/cometbft/cometbft/libs/rand"
"github.com/cometbft/cometbft/types"
tmtime "github.com/cometbft/cometbft/types/time"
"github.com/cosmos/cosmos-sdk/runtime"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion test/simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str

privKey := secp256k1.GenPrivKeyFromSecret(privkeySeed)

a, ok := acc.GetCachedValue().(authtypes.AccountI)
a, ok := acc.GetCachedValue().(sdk.AccountI)
if !ok {
panic("expected account")
}
Expand Down
16 changes: 10 additions & 6 deletions test/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import (
"encoding/json"
"time"

dbm "github.com/cosmos/cosmos-db"
multistakingtypes "github.com/realio-tech/multi-staking-module/x/multi-staking/types"

"cosmossdk.io/log"
"cosmossdk.io/math"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
Expand All @@ -15,12 +19,9 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"cosmossdk.io/log"
"cosmossdk.io/math"
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
)

// DefaultConsensusParams defines the default Tendermint consensus params used in
Expand Down Expand Up @@ -73,15 +74,18 @@ func SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet) *SimApp {
stateBytes, _ := json.MarshalIndent(genesisState, "", " ")

// init chain will set the validator set and initialize the genesis accounts
app.InitChain(
_, err := app.InitChain(
&abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
if err != nil {
panic(err)
}

_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -144,7 +148,7 @@ func genesisStateWithValSet(app *SimApp, genesisState GenesisState, valSet *tmty
locks = append(locks, lockRecord)
lockCoins = lockCoins.Add(valMsCoin.ToCoin())

pk, _ := cryptocodec.FromTmPubKeyInterface(val.PubKey)
pk, _ := cryptocodec.FromCmtPubKeyInterface(val.PubKey)
pkAny, _ := codectypes.NewAnyWithValue(pk)
validator := stakingtypes.Validator{
OperatorAddress: sdk.ValAddress(val.Address).String(),
Expand Down
9 changes: 5 additions & 4 deletions test/simapp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"fmt"
"os"

dbm "github.com/cosmos/cosmos-db"
"github.com/rs/zerolog"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/rs/zerolog"
)

// SetupSimulation creates the config, db (levelDB), temporary directory and logger for
Expand Down
3 changes: 2 additions & 1 deletion x/multi-staking/client/cli/proposal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cli

import (
sdkmath "cosmossdk.io/math"
"github.com/realio-tech/multi-staking-module/x/multi-staking/types"
"github.com/spf13/cobra"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
3 changes: 2 additions & 1 deletion x/multi-staking/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cli

import (
"cosmossdk.io/core/address"
"github.com/realio-tech/multi-staking-module/x/multi-staking/types"
"github.com/spf13/cobra"

"cosmossdk.io/core/address"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
)
Expand Down
3 changes: 2 additions & 1 deletion x/multi-staking/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func (suite *KeeperTestSuite) TestMsUnlockEndBlocker() {
// height 3
suite.NextBlock(time.Second)

suite.app.SlashingKeeper.Slash(suite.ctx, valConsAddr, tc.slashFactor, slashedPow, 2)
err = suite.app.SlashingKeeper.Slash(suite.ctx, valConsAddr, tc.slashFactor, slashedPow, 2)
require.NoError(suite.T(), err)
} else {
// height 3
suite.NextBlock(time.Second)
Expand Down
3 changes: 2 additions & 1 deletion x/multi-staking/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package keeper_test

import (
dbm "github.com/cosmos/cosmos-db"
"github.com/realio-tech/multi-staking-module/test/simapp"

"cosmossdk.io/log"

abci "github.com/cometbft/cometbft/abci/types"
dbm "github.com/cosmos/cosmos-db"
)

func (suite *KeeperTestSuite) TestImportExportGenesis() {
Expand Down
3 changes: 2 additions & 1 deletion x/multi-staking/keeper/invartiants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package keeper_test
import (
"time"

"cosmossdk.io/math"
"github.com/realio-tech/multi-staking-module/test"
"github.com/realio-tech/multi-staking-module/x/multi-staking/keeper"
"github.com/realio-tech/multi-staking-module/x/multi-staking/types"

"cosmossdk.io/math"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down
Loading

0 comments on commit 56fc9b4

Please sign in to comment.