diff --git a/go.mod b/go.mod index 3d845089dce1..d9ecde71c851 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ require ( github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.6.0 - github.com/google/gofuzz v1.2.0 github.com/gorilla/handlers v1.5.2 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 diff --git a/simapp/app_test.go b/simapp/app_test.go index 437ba69e7a9c..f3418d7ab239 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -37,11 +37,11 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil/mock" "github.com/cosmos/cosmos-sdk/testutil/network" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/x/genutil" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestSimAppExportAndBlockedAddrs(t *testing.T) { diff --git a/simapp/go.mod b/simapp/go.mod index a478b2ba9923..194b9fde3eed 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -45,6 +45,11 @@ require ( google.golang.org/protobuf v1.33.0 ) +require ( + golang.org/x/sync v0.7.0 + google.golang.org/grpc v1.63.2 +) + require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20240130113600-88ef6483f90f.1 // indirect buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect @@ -203,7 +208,6 @@ require ( golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/oauth2 v0.19.0 // indirect - golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect @@ -213,7 +217,6 @@ require ( google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/grpc v1.63.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index e4d01fcd44f4..32c67ca2e88b 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -12,10 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/server" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var FlagEnableBenchStreamingValue bool @@ -33,7 +33,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { config := simcli.NewConfigFromFlags() config.ChainID = SimAppChainID - db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "goleveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue) + db, dir, logger, skip, err := helper.SetupSimulation(config, "goleveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue) if err != nil { b.Fatalf("simulation setup failed: %s", err.Error()) } @@ -67,9 +67,9 @@ func BenchmarkFullAppSimulation(b *testing.B) { b, os.Stdout, app.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(app, app.AppCodec(), config), + helper.SimulationOperations(app, app.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -77,7 +77,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { ) // export state and simParams before the simulation error is checked - if err = simtestutil.CheckExportSimulation(app, config, simParams); err != nil { + if err = helper.CheckExportSimulation(app, config, simParams); err != nil { b.Fatal(err) } @@ -86,6 +86,6 @@ func BenchmarkFullAppSimulation(b *testing.B) { } if config.Commit { - simtestutil.PrintStats(db) + helper.PrintStats(db) } } diff --git a/simapp/sim_test.go b/simapp/sim_test.go index afb570914e34..2c92faaa193a 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -28,10 +28,11 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/server" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // SimAppChainID hardcoded chainID for simulation @@ -64,9 +65,9 @@ func TestFullAppSimulation(t *testing.T) { t, os.Stdout, app.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(app, app.AppCodec(), config), + helper.SimulationOperations(app, app.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -74,12 +75,12 @@ func TestFullAppSimulation(t *testing.T) { ) // export state and simParams before the simulation error is checked - err := simtestutil.CheckExportSimulation(app, config, simParams) + err := helper.CheckExportSimulation(app, config, simParams) require.NoError(t, err) require.NoError(t, simErr) if config.Commit { - simtestutil.PrintStats(db) + helper.PrintStats(db) } } @@ -91,9 +92,9 @@ func TestAppImportExport(t *testing.T) { t, os.Stdout, app.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(app, app.AppCodec(), config), + helper.SimulationOperations(app, app.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -101,12 +102,12 @@ func TestAppImportExport(t *testing.T) { ) // export state and simParams before the simulation error is checked - err := simtestutil.CheckExportSimulation(app, config, simParams) + err := helper.CheckExportSimulation(app, config, simParams) require.NoError(t, err) require.NoError(t, simErr) if config.Commit { - simtestutil.PrintStats(db) + helper.PrintStats(db) } t.Log("exporting genesis...\n") @@ -116,7 +117,7 @@ func TestAppImportExport(t *testing.T) { t.Log("importing genesis...\n") - newDB, newDir, _, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) + newDB, newDir, _, _, err := helper.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) require.NoError(t, err, "simulation setup failed") defer func() { @@ -175,11 +176,11 @@ func TestAppImportExport(t *testing.T) { storeA := ctxA.KVStore(appKeyA) storeB := ctxB.KVStore(appKeyB) - failedKVAs, failedKVBs := simtestutil.DiffKVStores(storeA, storeB, skipPrefixes[keyName]) + failedKVAs, failedKVBs := helper.DiffKVStores(storeA, storeB, skipPrefixes[keyName]) require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare %s, key stores %s and %s", keyName, appKeyA, appKeyB) t.Logf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), appKeyA, appKeyB) - if !assert.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(keyName, app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) { + if !assert.Equal(t, 0, len(failedKVAs), helper.GetSimulationLog(keyName, app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) { for _, v := range failedKVAs { t.Logf("store mismatch: %q\n", v) } @@ -196,9 +197,9 @@ func TestAppSimulationAfterImport(t *testing.T) { t, os.Stdout, app.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(app, app.AppCodec(), config), + helper.SimulationOperations(app, app.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -207,11 +208,11 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, simErr) // export state and simParams before the simulation error is checked - err := simtestutil.CheckExportSimulation(app, config, simParams) + err := helper.CheckExportSimulation(app, config, simParams) require.NoError(t, err) if config.Commit { - simtestutil.PrintStats(db) + helper.PrintStats(db) } if stopEarly { @@ -226,7 +227,7 @@ func TestAppSimulationAfterImport(t *testing.T) { t.Logf("importing genesis...\n") - newDB, newDir, _, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) + newDB, newDir, _, _, err := helper.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue) require.NoError(t, err, "simulation setup failed") defer func() { @@ -249,9 +250,9 @@ func TestAppSimulationAfterImport(t *testing.T) { t, os.Stdout, newApp.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(newApp, newApp.AppCodec(), config), + helper.SimulationOperations(newApp, newApp.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -265,7 +266,7 @@ func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simt config := simcli.NewConfigFromFlags() config.ChainID = SimAppChainID - db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue) + db, dir, logger, skip, err := helper.SetupSimulation(config, "leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue) if skip { t.Skip(msg) } @@ -276,7 +277,7 @@ func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simt require.NoError(t, os.RemoveAll(dir)) }) - appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions := make(helper.AppOptionsMap, 0) appOptions[flags.FlagHome] = dir // ensure a unique folder appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue @@ -357,9 +358,9 @@ func TestAppStateDeterminism(t *testing.T) { t, os.Stdout, app.BaseApp, - simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), + helper.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simtestutil.SimulationOperations(app, app.AppCodec(), config), + helper.SimulationOperations(app, app.AppCodec(), config), BlockedAddresses(), config, app.AppCodec(), @@ -368,7 +369,7 @@ func TestAppStateDeterminism(t *testing.T) { require.NoError(t, err) if config.Commit { - simtestutil.PrintStats(db) + helper.PrintStats(db) } appHash := app.LastCommitID().Hash diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 2b66d8cbe577..9fa66138df70 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -21,9 +21,9 @@ import ( addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // NewRootCmd creates a new root command for simd. It is called once in the diff --git a/simapp/simd/cmd/root_di.go b/simapp/simd/cmd/root_di.go index cfc8407edc11..90d1a66a9b4d 100644 --- a/simapp/simd/cmd/root_di.go +++ b/simapp/simd/cmd/root_di.go @@ -25,8 +25,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/types/module" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // NewRootCmd creates a new root command for simd. It is called once in the main function. diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 184a0ac5fdc9..1b2fca83e4a2 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -29,6 +29,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // SetupOptions defines arguments that are passed into `Simapp` constructor. @@ -41,7 +42,7 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { db := dbm.NewMemDB() - appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions := make(helper.AppOptionsMap, 0) appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod @@ -73,7 +74,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio app := NewSimApp(options.Logger, options.DB, nil, true, options.AppOpts) genesisState := app.DefaultGenesis() - genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) + genesisState, err = helper.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) require.NoError(t, err) if !isCheckTx { @@ -84,7 +85,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio // Initialize the chain _, err = app.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, + ConsensusParams: helper.DefaultConsensusParams, AppStateBytes: stateBytes, }) require.NoError(t, err) @@ -126,7 +127,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs t.Helper() app, genesisState := setup(true, 5) - genesisState, err := simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, genAccs, balances...) + genesisState, err := helper.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, genAccs, balances...) require.NoError(t, err) stateBytes, err := json.MarshalIndent(genesisState, "", " ") @@ -135,7 +136,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs // init chain will set the validator set and initialize the genesis accounts _, err = app.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, + ConsensusParams: helper.DefaultConsensusParams, AppStateBytes: stateBytes, }, ) @@ -176,7 +177,7 @@ func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState { } genesisState := app.DefaultGenesis() - genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) + genesisState, err = helper.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) require.NoError(t, err) return genesisState @@ -224,12 +225,12 @@ func NewTestNetworkFixture() network.TestFixture { } defer os.RemoveAll(dir) - app := NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir)) + app := NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, helper.NewAppOptionsWithFlagHome(dir)) appCtr := func(val network.ValidatorI) servertypes.Application { return NewSimApp( val.GetCtx().Logger, dbm.NewMemDB(), nil, true, - simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir), + helper.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir), bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices), bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)), diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go index 1d5e6b7f2a34..a38aeaf4f04b 100644 --- a/tests/e2e/auth/suite.go +++ b/tests/e2e/auth/suite.go @@ -1047,6 +1047,7 @@ func (s *E2ETestSuite) TestCLIMultisign() { } return clientCtx.Codec.UnmarshalJSON(resp, &balRes) }, 3) + fmt.Println("RetryForBlocks err", err) s.Require().NoError(err) s.Require().True(sendTokens.Amount.Equal(balRes.Balances.AmountOf(s.cfg.BondDenom))) diff --git a/tests/e2e/authz/tx.go b/tests/e2e/authz/tx.go index fe3bc7131e3a..178dae6727fe 100644 --- a/tests/e2e/authz/tx.go +++ b/tests/e2e/authz/tx.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" + e2etestutil "github.com/cosmos/cosmos-sdk/tests/e2e/utils" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -84,7 +85,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(s.network.WaitForNextBlock()) var response sdk.TxResponse s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, 0)) // Create new account in the keyring. s.grantee[2] = s.createAccount("grantee3") @@ -128,7 +129,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(s.network.WaitForNextBlock()) s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, 0)) } func (s *E2ETestSuite) createAccount(uid string) sdk.AccAddress { @@ -217,7 +218,7 @@ func (s *E2ETestSuite) TestExecAuthorizationWithExpiration() { s.Require().NoError(err) var response sdk.TxResponse s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, response.TxHash, authz.ErrNoAuthorizationFound.ABCICode())) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, response.TxHash, authz.ErrNoAuthorizationFound.ABCICode())) } func (s *E2ETestSuite) TestNewExecGenericAuthorized() { @@ -317,7 +318,7 @@ func (s *E2ETestSuite) TestNewExecGenericAuthorized() { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, tc.expectedCode)) } }) } @@ -433,7 +434,7 @@ func (s *E2ETestSuite) TestNewExecGrantAuthorized() { default: s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) } }) } @@ -632,7 +633,7 @@ func (s *E2ETestSuite) TestExecDelegateAuthorization() { var response sdk.TxResponse s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) } }) } @@ -699,7 +700,7 @@ func (s *E2ETestSuite) TestExecDelegateAuthorization() { var response sdk.TxResponse s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) } }) } @@ -854,7 +855,7 @@ func (s *E2ETestSuite) TestExecUndelegateAuthorization() { var response sdk.TxResponse s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) } }) } @@ -922,7 +923,7 @@ func (s *E2ETestSuite) TestExecUndelegateAuthorization() { var response sdk.TxResponse s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), response.TxHash, tc.expectedCode)) } }) } diff --git a/tests/e2e/baseapp/block_gas_test.go b/tests/e2e/baseapp/block_gas_test.go index 0098c2d48650..9c7751f1c3bd 100644 --- a/tests/e2e/baseapp/block_gas_test.go +++ b/tests/e2e/baseapp/block_gas_test.go @@ -31,12 +31,12 @@ import ( baseapputil "github.com/cosmos/cosmos-sdk/tests/e2e/baseapp" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" txtypes "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var blockMaxGas = uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) diff --git a/tests/e2e/baseapp/utils.go b/tests/e2e/baseapp/utils.go index f776de1e03dc..d72ebf18c3ba 100644 --- a/tests/e2e/baseapp/utils.go +++ b/tests/e2e/baseapp/utils.go @@ -19,9 +19,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/mock" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/x/consensus" + sims "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts @@ -49,7 +49,7 @@ func GenesisStateWithSingleValidator(t *testing.T, codec codec.Codec, builder *r genesisState := builder.DefaultGenesis() // sus - genesisState, err = simtestutil.GenesisStateWithValSet(codec, genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) + genesisState, err = sims.GenesisStateWithValSet(codec, genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) require.NoError(t, err) return genesisState diff --git a/tests/e2e/genutil/export_test.go b/tests/e2e/genutil/export_test.go index 2a317981251a..e9e7aeefbf82 100644 --- a/tests/e2e/genutil/export_test.go +++ b/tests/e2e/genutil/export_test.go @@ -12,23 +12,34 @@ import ( "os" "path" "testing" + "time" + abci_server "github.com/cometbft/cometbft/abci/server" abci "github.com/cometbft/cometbft/abci/types" dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cobra" + "github.com/stretchr/testify/require" "gotest.tools/v3/assert" "cosmossdk.io/log" "cosmossdk.io/simapp" + "cosmossdk.io/x/staking" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/server" + servercmtlog "github.com/cosmos/cosmos-sdk/server/log" + "github.com/cosmos/cosmos-sdk/server/mock" "github.com/cosmos/cosmos-sdk/server/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestExportCmd_ConsensusParams(t *testing.T) { @@ -221,3 +232,37 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, ge func createConfigFolder(dir string) error { return os.Mkdir(path.Join(dir, "config"), 0o700) } + +func TestStartStandAlone(t *testing.T) { + home := t.TempDir() + logger := log.NewNopLogger() + interfaceRegistry := codectypes.NewInterfaceRegistry() + marshaler := codec.NewProtoCodec(interfaceRegistry) + err := genutiltest.ExecInitCmd(module.NewManager( + staking.NewAppModule(codec.NewProtoCodec(interfaceRegistry), nil, nil, nil), + genutil.NewAppModule(codec.NewProtoCodec(interfaceRegistry), nil, nil, nil, nil, nil), + ), home, marshaler) + require.NoError(t, err) + + app, err := mock.NewApp(home, logger) + require.NoError(t, err) + + svrAddr, _, closeFn, err := network.FreeTCPAddr() + require.NoError(t, err) + require.NoError(t, closeFn()) + + cmtApp := server.NewCometABCIWrapper(app) + svr, err := abci_server.NewServer(svrAddr, "socket", cmtApp) + require.NoError(t, err, "error creating listener") + + svr.SetLogger(servercmtlog.CometLoggerWrapper{Logger: logger.With("module", "abci-server")}) + err = svr.Start() + require.NoError(t, err) + + timer := time.NewTimer(time.Duration(2) * time.Second) + for range timer.C { + err = svr.Stop() + require.NoError(t, err) + break + } +} diff --git a/x/genutil/gentx_test.go b/tests/e2e/genutil/gentx_test.go similarity index 99% rename from x/genutil/gentx_test.go rename to tests/e2e/genutil/gentx_test.go index 324ce95c6093..1995bc744d41 100644 --- a/x/genutil/gentx_test.go +++ b/tests/e2e/genutil/gentx_test.go @@ -22,12 +22,12 @@ import ( codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltestutil "github.com/cosmos/cosmos-sdk/x/genutil/testutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var ( diff --git a/tests/e2e/gov/tx.go b/tests/e2e/gov/tx.go index 9c7e5959db0e..9c37e56ece18 100644 --- a/tests/e2e/gov/tx.go +++ b/tests/e2e/gov/tx.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/client/flags" + e2etestutil "github.com/cosmos/cosmos-sdk/tests/e2e/utils" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -51,13 +52,13 @@ func (s *E2ETestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens).String())) s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) // vote for proposal out, err = govclitestutil.MsgVote(val.GetClientCtx(), val.GetAddress().String(), "1", "yes") s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) // create a proposal with a small deposit minimumAcceptedDep := v1.DefaultMinDepositTokens.ToLegacyDec().Mul(v1.DefaultMinDepositRatio).Ceil().TruncateInt() @@ -67,7 +68,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) // create a proposal3 with deposit out, err = govclitestutil.MsgSubmitLegacyProposal(val.GetClientCtx(), val.GetAddress().String(), @@ -75,7 +76,7 @@ func (s *E2ETestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens).String())) s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) // create a proposal4 with deposit to check the cancel proposal cli tx out, err = govclitestutil.MsgSubmitLegacyProposal(val.GetClientCtx(), val.GetAddress().String(), @@ -83,13 +84,13 @@ func (s *E2ETestSuite) SetupSuite() { fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens).String())) s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) // vote for proposal3 as val out, err = govclitestutil.MsgVote(val.GetClientCtx(), val.GetAddress().String(), "3", "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05") s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, 0)) } func (s *E2ETestSuite) TearDownSuite() { @@ -177,7 +178,7 @@ func (s *E2ETestSuite) TestNewCmdSubmitProposal() { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) } }) } @@ -273,7 +274,7 @@ func (s *E2ETestSuite) TestNewCmdSubmitLegacyProposal() { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) } }) } @@ -370,7 +371,7 @@ func (s *E2ETestSuite) TestNewCmdWeightedVote() { } else { s.Require().NoError(err) s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode)) } }) } diff --git a/tests/e2e/group/suite.go b/tests/e2e/group/suite.go index 2dd59828f719..ec69c266f6a4 100644 --- a/tests/e2e/group/suite.go +++ b/tests/e2e/group/suite.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" + e2etestutil "github.com/cosmos/cosmos-sdk/tests/e2e/utils" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -111,7 +112,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(err, out.String()) txResp := sdk.TxResponse{} s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) s.group = &group.GroupInfo{Id: 1, Admin: val.GetAddress().String(), Metadata: validMetadata, TotalWeight: "3", Version: 1} @@ -145,7 +146,7 @@ func (s *E2ETestSuite) SetupSuite() { ) s.Require().NoError(err, out.String()) s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/group/v1/group_policies_by_group/1", val.GetAPIAddress())) s.Require().NoError(err) @@ -169,7 +170,7 @@ func (s *E2ETestSuite) SetupSuite() { ) s.Require().NoError(err, out.String()) s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) msg := &group.MsgVote{ ProposalId: uint64(1), @@ -181,7 +182,7 @@ func (s *E2ETestSuite) SetupSuite() { out, err = clitestutil.SubmitTestTx(val.GetClientCtx(), msg, val.GetAddress(), clitestutil.TestTxConfig{}) s.Require().NoError(err, out.String()) s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) resp, err = testutil.GetRequest(fmt.Sprintf("%s/cosmos/group/v1/proposal/1", val.GetAPIAddress())) s.Require().NoError(err) @@ -258,7 +259,7 @@ func (s *E2ETestSuite) createGroupThresholdPolicyWithBalance(adminAddress, group txResp := sdk.TxResponse{} s.Require().NoError(err, out.String()) s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().NoError(clitestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) + s.Require().NoError(e2etestutil.CheckTxCode(s.network, val.GetClientCtx(), txResp.TxHash, 0)) resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/group/v1/group_policies_by_group/%s", val.GetAPIAddress(), groupID)) s.Require().NoError(err) diff --git a/types/query/filtered_pagination_test.go b/tests/e2e/query/filtered_pagination_test.go similarity index 100% rename from types/query/filtered_pagination_test.go rename to tests/e2e/query/filtered_pagination_test.go diff --git a/types/query/fuzz_test.go b/tests/e2e/query/fuzz_test.go similarity index 100% rename from types/query/fuzz_test.go rename to tests/e2e/query/fuzz_test.go diff --git a/types/query/pagination_test.go b/tests/e2e/query/pagination_test.go similarity index 99% rename from types/query/pagination_test.go rename to tests/e2e/query/pagination_test.go index a35257ccabfa..c740509ef467 100644 --- a/types/query/pagination_test.go +++ b/tests/e2e/query/pagination_test.go @@ -26,11 +26,11 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - testutilsims "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/cosmos-sdk/x/consensus" + testutilsims "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) const ( diff --git a/tests/e2e/tx/benchmarks_test.go b/tests/e2e/tx/benchmarks_test.go index 7cd0acae62b2..10deb3906b66 100644 --- a/tests/e2e/tx/benchmarks_test.go +++ b/tests/e2e/tx/benchmarks_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" clienttx "github.com/cosmos/cosmos-sdk/client/tx" + e2etestutil "github.com/cosmos/cosmos-sdk/tests/e2e/utils" "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -145,7 +146,7 @@ func NewE2EBenchmarkSuite(tb testing.TB) *E2EBenchmarkSuite { assert.NilError(tb, val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &tr)) assert.Equal(tb, uint32(0), tr.Code) - resp, err := cli.GetTxResponse(s.network, val.GetClientCtx(), tr.TxHash) + resp, err := e2etestutil.GetTxResponse(s.network, val.GetClientCtx(), tr.TxHash) assert.NilError(tb, err) s.txHeight = resp.Height return s diff --git a/tests/e2e/tx/service_test.go b/tests/e2e/tx/service_test.go index b9c500cf53de..7be7b1ae6658 100644 --- a/tests/e2e/tx/service_test.go +++ b/tests/e2e/tx/service_test.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + e2etestutil "github.com/cosmos/cosmos-sdk/tests/e2e/utils" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -109,7 +110,7 @@ func (s *E2ETestSuite) SetupSuite() { s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out1.Bytes(), &tr)) s.Require().Equal(uint32(0), tr.Code) - resp, err := cli.GetTxResponse(s.network, val.GetClientCtx(), tr.TxHash) + resp, err := e2etestutil.GetTxResponse(s.network, val.GetClientCtx(), tr.TxHash) s.Require().NoError(err) s.txHeight = resp.Height } diff --git a/testutil/cli/tx.go b/tests/e2e/utils/utils.go similarity index 84% rename from testutil/cli/tx.go rename to tests/e2e/utils/utils.go index 1adf81bd0e07..47ab227c7c23 100644 --- a/testutil/cli/tx.go +++ b/tests/e2e/utils/utils.go @@ -1,4 +1,4 @@ -package cli +package utils import ( "fmt" @@ -7,10 +7,12 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" ) +// Can move to e2e // CheckTxCode verifies that the transaction result returns a specific code // Takes a network, wait for two blocks and fetch the transaction from its hash func CheckTxCode(network network.NetworkI, clientCtx client.Context, txHash string, expectedCode uint32) error { @@ -22,7 +24,7 @@ func CheckTxCode(network network.NetworkI, clientCtx client.Context, txHash stri } cmd := authcli.QueryTxCmd() - out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)}) + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)}) if err != nil { return err } @@ -50,7 +52,7 @@ func GetTxResponse(network network.NetworkI, clientCtx client.Context, txHash st } cmd := authcli.QueryTxCmd() - out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)}) + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)}) if err != nil { return sdk.TxResponse{}, err } diff --git a/tests/go.mod b/tests/go.mod index 197a4f8eb706..e0a9a8d77998 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -48,6 +48,7 @@ require ( cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000 cosmossdk.io/x/staking v0.0.0-20240226161501-23359a0b6d91 github.com/google/go-cmp v0.6.0 + github.com/google/gofuzz v1.2.0 github.com/jhump/protoreflect v1.16.0 ) diff --git a/x/auth/keeper/keeper_bench_test.go b/tests/integration/auth/keeper/keeper_bench_test.go similarity index 96% rename from x/auth/keeper/keeper_bench_test.go rename to tests/integration/auth/keeper/keeper_bench_test.go index c45ccdf43c7f..01246ebdb975 100644 --- a/x/auth/keeper/keeper_bench_test.go +++ b/tests/integration/auth/keeper/keeper_bench_test.go @@ -10,8 +10,8 @@ import ( "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/testutil" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func BenchmarkAccountMapperGetAccountFound(b *testing.B) { diff --git a/x/auth/module_test.go b/tests/integration/auth/keeper/module_test.go similarity index 84% rename from x/auth/module_test.go rename to tests/integration/auth/keeper/module_test.go index 5c2d8402f787..e1b347fa0b59 100644 --- a/x/auth/module_test.go +++ b/tests/integration/auth/keeper/module_test.go @@ -1,4 +1,4 @@ -package auth_test +package keeper_test import ( "testing" @@ -11,9 +11,10 @@ import ( "cosmossdk.io/x/auth/testutil" "cosmossdk.io/x/auth/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) +// Can move to tests/integration func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { var accountKeeper keeper.AccountKeeper app, err := simtestutil.SetupAtGenesis( diff --git a/tests/integration/bank/app_test.go b/tests/integration/bank/app_test.go index 7043b1eb0be6..5ad7a754ba6e 100644 --- a/tests/integration/bank/app_test.go +++ b/tests/integration/bank/app_test.go @@ -32,10 +32,10 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" _ "github.com/cosmos/cosmos-sdk/x/consensus" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type ( diff --git a/tests/integration/bank/bench_test.go b/tests/integration/bank/bench_test.go index 89b4d458cfee..b1857ca16398 100644 --- a/tests/integration/bank/bench_test.go +++ b/tests/integration/bank/bench_test.go @@ -18,9 +18,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var moduleAccAddr = authtypes.NewModuleAddress(stakingtypes.BondedPoolName) diff --git a/tests/integration/distribution/module_test.go b/tests/integration/distribution/module_test.go index b1523a825e73..482409b9534d 100644 --- a/tests/integration/distribution/module_test.go +++ b/tests/integration/distribution/module_test.go @@ -11,7 +11,7 @@ import ( authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/distribution/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { diff --git a/tests/integration/evidence/genesis_test.go b/tests/integration/evidence/genesis_test.go index c2cb89c406fc..e87c403f3ae6 100644 --- a/tests/integration/evidence/genesis_test.go +++ b/tests/integration/evidence/genesis_test.go @@ -16,8 +16,8 @@ import ( "cosmossdk.io/x/evidence/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type GenesisTestSuite struct { diff --git a/tests/integration/evidence/keeper/infraction_test.go b/tests/integration/evidence/keeper/infraction_test.go index 4e40b006faf4..869f8bb6ba64 100644 --- a/tests/integration/evidence/keeper/infraction_test.go +++ b/tests/integration/evidence/keeper/infraction_test.go @@ -49,10 +49,10 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/integration" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var ( diff --git a/tests/integration/gov/common_test.go b/tests/integration/gov/common_test.go index 65a66cf52cf4..da889da3f24c 100644 --- a/tests/integration/gov/common_test.go +++ b/tests/integration/gov/common_test.go @@ -26,9 +26,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/x/consensus" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var ( diff --git a/tests/integration/gov/genesis_test.go b/tests/integration/gov/genesis_test.go index 8959cd3335bb..059fa7110168 100644 --- a/tests/integration/gov/genesis_test.go +++ b/tests/integration/gov/genesis_test.go @@ -34,6 +34,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/x/consensus" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type suite struct { @@ -61,12 +62,12 @@ func TestImportExportQueues(t *testing.T) { var err error s1 := suite{} - s1.app, err = simtestutil.SetupWithConfiguration( + s1.app, err = helper.SetupWithConfiguration( depinject.Configs( appConfig, depinject.Supply(log.NewNopLogger()), ), - simtestutil.DefaultStartUpConfig(), + helper.DefaultStartUpConfig(), &s1.AccountKeeper, &s1.BankKeeper, &s1.GovKeeper, &s1.StakingKeeper, &s1.cdc, &s1.appBuilder, ) assert.NilError(t, err) @@ -123,9 +124,9 @@ func TestImportExportQueues(t *testing.T) { s2 := suite{} db := dbm.NewMemDB() - conf2 := simtestutil.DefaultStartUpConfig() + conf2 := helper.DefaultStartUpConfig() conf2.DB = db - s2.app, err = simtestutil.SetupWithConfiguration( + s2.app, err = helper.SetupWithConfiguration( depinject.Configs( appConfig, depinject.Supply(log.NewNopLogger()), @@ -142,7 +143,7 @@ func TestImportExportQueues(t *testing.T) { _, err = s2.app.InitChain( &abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, + ConsensusParams: helper.DefaultConsensusParams, AppStateBytes: stateBytes, }, ) diff --git a/tests/integration/gov/module_test.go b/tests/integration/gov/module_test.go index c1d41a0b6cb5..2f43343a0a2e 100644 --- a/tests/integration/gov/module_test.go +++ b/tests/integration/gov/module_test.go @@ -15,12 +15,12 @@ import ( _ "cosmossdk.io/x/protocolpool" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { var accountKeeper authkeeper.AccountKeeper - app, err := simtestutil.SetupAtGenesis( + app, err := helper.SetupAtGenesis( depinject.Configs( configurator.NewAppConfig( configurator.AccountsModule(), diff --git a/x/group/keeper/abci_test.go b/tests/integration/group/keeper/abci_test.go similarity index 99% rename from x/group/keeper/abci_test.go rename to tests/integration/group/keeper/abci_test.go index 0db99839d51c..dd8085bf4347 100644 --- a/x/group/keeper/abci_test.go +++ b/tests/integration/group/keeper/abci_test.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type IntegrationTestSuite struct { @@ -46,7 +47,7 @@ func TestIntegrationTestSuite(t *testing.T) { } func (s *IntegrationTestSuite) SetupTest() { - app, err := simtestutil.Setup( + app, err := helper.Setup( depinject.Configs( grouptestutil.AppConfig, depinject.Supply(log.NewNopLogger()), diff --git a/x/group/simulation/operations_test.go b/tests/integration/group/simulation/operations_test.go similarity index 99% rename from x/group/simulation/operations_test.go rename to tests/integration/group/simulation/operations_test.go index 19b8a1cb0f51..0a4c51109e4e 100644 --- a/x/group/simulation/operations_test.go +++ b/tests/integration/group/simulation/operations_test.go @@ -23,9 +23,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/tests/integration/mint/module_test.go b/tests/integration/mint/module_test.go index 59a5c091a9f5..512d904d4878 100644 --- a/tests/integration/mint/module_test.go +++ b/tests/integration/mint/module_test.go @@ -11,13 +11,13 @@ import ( authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/mint/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { var accountKeeper authkeeper.AccountKeeper - app, err := simtestutil.SetupAtGenesis( + app, err := helper.SetupAtGenesis( depinject.Configs( AppConfig, depinject.Supply(log.NewNopLogger()), diff --git a/tests/integration/runtime/query_test.go b/tests/integration/runtime/query_test.go index de3e3e7457d4..04ff5e4423f0 100644 --- a/tests/integration/runtime/query_test.go +++ b/tests/integration/runtime/query_test.go @@ -23,9 +23,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/x/consensus" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type fixture struct { diff --git a/tests/integration/slashing/abci_test.go b/tests/integration/slashing/abci_test.go index 51facaf45cbc..dc48d11410de 100644 --- a/tests/integration/slashing/abci_test.go +++ b/tests/integration/slashing/abci_test.go @@ -21,6 +21,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // TestBeginBlocker is a unit test function that tests the behavior of the BeginBlocker function. @@ -35,7 +36,7 @@ func TestBeginBlocker(t *testing.T) { slashingKeeper slashingkeeper.Keeper ) - app, err := simtestutil.Setup( + app, err := helper.Setup( depinject.Configs( AppConfig, depinject.Supply(log.NewNopLogger()), diff --git a/tests/integration/slashing/keeper/slash_redelegation_test.go b/tests/integration/slashing/keeper/slash_redelegation_test.go index d50a012765e5..a83fbd22d31e 100644 --- a/tests/integration/slashing/keeper/slash_redelegation_test.go +++ b/tests/integration/slashing/keeper/slash_redelegation_test.go @@ -22,8 +22,8 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/tests/integration/slashing" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestSlashRedelegation(t *testing.T) { diff --git a/tests/integration/slashing/slashing_test.go b/tests/integration/slashing/slashing_test.go index bec39e2449f8..274e5ef18d36 100644 --- a/tests/integration/slashing/slashing_test.go +++ b/tests/integration/slashing/slashing_test.go @@ -22,8 +22,8 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/configurator" - "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var ( @@ -47,9 +47,9 @@ func TestSlashingMsgs(t *testing.T) { acc1 := &authtypes.BaseAccount{ Address: addrStr, } - accs := []sims.GenesisAccount{{GenesisAccount: acc1, Coins: sdk.Coins{genCoin}}} + accs := []helper.GenesisAccount{{GenesisAccount: acc1, Coins: sdk.Coins{genCoin}}} - startupCfg := sims.DefaultStartUpConfig() + startupCfg := helper.DefaultStartUpConfig() startupCfg.GenesisAccounts = accs var ( @@ -59,7 +59,7 @@ func TestSlashingMsgs(t *testing.T) { txConfig client.TxConfig ) - app, err := sims.SetupWithConfiguration( + app, err := helper.SetupWithConfiguration( depinject.Configs( configurator.NewAppConfig( configurator.AccountsModule(), @@ -93,7 +93,7 @@ func TestSlashingMsgs(t *testing.T) { require.NoError(t, err) headerInfo := header.Info{Height: app.LastBlockHeight() + 1} - _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) + _, _, err = helper.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) @@ -112,7 +112,7 @@ func TestSlashingMsgs(t *testing.T) { // unjail should fail with unknown validator headerInfo = header.Info{Height: app.LastBlockHeight() + 1} - _, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) + _, _, err = helper.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) require.Error(t, err) require.True(t, errors.Is(types.ErrValidatorNotJailed, err)) } diff --git a/tests/integration/staking/keeper/vote_extensions_test.go b/tests/integration/staking/keeper/vote_extensions_test.go index 08f5c25bcf17..0efb29d674a7 100644 --- a/tests/integration/staking/keeper/vote_extensions_test.go +++ b/tests/integration/staking/keeper/vote_extensions_test.go @@ -22,6 +22,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) const chainID = "chain-id-123" @@ -34,7 +35,7 @@ func TestValidateVoteExtensions(t *testing.T) { f := initFixture(t) // enable vote extensions - cp := simtestutil.DefaultConsensusParams + cp := helper.DefaultConsensusParams cp.Abci = &cmtproto.ABCIParams{VoteExtensionsEnableHeight: 1} f.sdkCtx = f.sdkCtx.WithConsensusParams(*cp).WithHeaderInfo(header.Info{Height: 2, ChainID: chainID}) diff --git a/tests/integration/staking/module_test.go b/tests/integration/staking/module_test.go index cd864646062e..e729363d011c 100644 --- a/tests/integration/staking/module_test.go +++ b/tests/integration/staking/module_test.go @@ -11,7 +11,7 @@ import ( authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/staking/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { diff --git a/tests/integration/staking/simulation/operations_test.go b/tests/integration/staking/simulation/operations_test.go index 38bfa26232ea..4be032ec297e 100644 --- a/tests/integration/staking/simulation/operations_test.go +++ b/tests/integration/staking/simulation/operations_test.go @@ -36,10 +36,10 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/tests/integration/staking" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/tests/integration/store/rootmulti/rollback_test.go b/tests/integration/store/rootmulti/rollback_test.go index 60303fdee99a..594ccf698873 100644 --- a/tests/integration/store/rootmulti/rollback_test.go +++ b/tests/integration/store/rootmulti/rollback_test.go @@ -12,7 +12,7 @@ import ( "cosmossdk.io/log" "cosmossdk.io/simapp" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func TestRollback(t *testing.T) { diff --git a/tests/integration/tx/context_test.go b/tests/integration/tx/context_test.go index ffe21c2053cb..5e3ac2e62970 100644 --- a/tests/integration/tx/context_test.go +++ b/tests/integration/tx/context_test.go @@ -14,7 +14,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/tests/integration/tx/internal/pulsar/testpb" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func ProvideCustomGetSigners() signing.CustomGetSigner { diff --git a/tests/sims/authz/operations_test.go b/tests/sims/authz/operations_test.go index 0a2ef3354859..698dbed2bb0c 100644 --- a/tests/sims/authz/operations_test.go +++ b/tests/sims/authz/operations_test.go @@ -32,11 +32,11 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" _ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring _ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var AppConfig = configurator.NewAppConfig( diff --git a/tests/sims/bank/operations_test.go b/tests/sims/bank/operations_test.go index 3373aaf453e2..b183d251665a 100644 --- a/tests/sims/bank/operations_test.go +++ b/tests/sims/bank/operations_test.go @@ -23,10 +23,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" _ "github.com/cosmos/cosmos-sdk/x/consensus" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/tests/sims/distribution/operations_test.go b/tests/sims/distribution/operations_test.go index 70e7f8eb4ec8..91b6b82bef0a 100644 --- a/tests/sims/distribution/operations_test.go +++ b/tests/sims/distribution/operations_test.go @@ -24,9 +24,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // TestWeightedOperations tests the weights of the operations. diff --git a/tests/sims/feegrant/operations_test.go b/tests/sims/feegrant/operations_test.go index 9da29e67b53b..fdd0695cbcc0 100644 --- a/tests/sims/feegrant/operations_test.go +++ b/tests/sims/feegrant/operations_test.go @@ -31,11 +31,11 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" _ "github.com/cosmos/cosmos-sdk/x/consensus" _ "github.com/cosmos/cosmos-sdk/x/genutil" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/tests/sims/gov/operations_test.go b/tests/sims/gov/operations_test.go index 9c28bd6d86b5..93b4d75a7afd 100644 --- a/tests/sims/gov/operations_test.go +++ b/tests/sims/gov/operations_test.go @@ -33,10 +33,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil/configurator" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" _ "github.com/cosmos/cosmos-sdk/x/consensus" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var ( diff --git a/tests/sims/nft/operations_test.go b/tests/sims/nft/operations_test.go index ee2e92603645..7ce824db5775 100644 --- a/tests/sims/nft/operations_test.go +++ b/tests/sims/nft/operations_test.go @@ -23,9 +23,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/tests/sims/protocolpool/operations_test.go b/tests/sims/protocolpool/operations_test.go index bdfaf0970c90..5ad556e0c1cf 100644 --- a/tests/sims/protocolpool/operations_test.go +++ b/tests/sims/protocolpool/operations_test.go @@ -20,9 +20,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type suite struct { diff --git a/tests/sims/slashing/operations_test.go b/tests/sims/slashing/operations_test.go index 411308c2f06e..7a6a5e47a8b1 100644 --- a/tests/sims/slashing/operations_test.go +++ b/tests/sims/slashing/operations_test.go @@ -34,9 +34,9 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) type SimTestSuite struct { diff --git a/testutil/integration/router.go b/testutil/integration/router.go index 94262363726a..20203bd622f7 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -3,9 +3,11 @@ package integration import ( "context" "fmt" + "time" cmtabcitypes "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" "cosmossdk.io/core/address" @@ -14,18 +16,19 @@ import ( "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" - authtx "cosmossdk.io/x/auth/tx" - authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + cdctestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + addresstypes "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) const appName = "integration-app" @@ -59,7 +62,8 @@ func NewIntegrationApp( moduleManager := module.NewManagerFromMap(modules) moduleManager.RegisterInterfaces(interfaceRegistry) - txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), addressCodec, validatorCodec, authtx.DefaultSignModes) + txConfig := moduletestutil.MakeTestTxConfig(cdctestutil.CodecOptions{}) + // txConfig := authtx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), addressCodec, validatorCodec, authtx.DefaultSignModes) bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName)) bApp.MountKVStores(keys) @@ -89,7 +93,7 @@ func NewIntegrationApp( if keys[consensusparamtypes.StoreKey] != nil { // set baseApp param store - consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(grpcRouter, msgRouter)), authtypes.NewModuleAddress("gov").String()) + consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(baseapp.NewGRPCQueryRouter(), msgRouter)), sdk.AccAddress(addresstypes.Module("gov")).String()) bApp.SetParamStore(consensusParamsKeeper.ParamsStore) consensusparamtypes.RegisterQueryServer(grpcRouter, consensusParamsKeeper) @@ -108,7 +112,22 @@ func NewIntegrationApp( panic(fmt.Errorf("failed to load application version from store: %w", err)) } - if _, err := bApp.InitChain(&cmtabcitypes.RequestInitChain{ChainId: appName, ConsensusParams: simtestutil.DefaultConsensusParams}); err != nil { + if _, err := bApp.InitChain(&cmtabcitypes.RequestInitChain{ChainId: appName, ConsensusParams: &cmtproto.ConsensusParams{ + Block: &cmtproto.BlockParams{ + MaxBytes: 200000, + MaxGas: 100_000_000, + }, + Evidence: &cmtproto.EvidenceParams{ + MaxAgeNumBlocks: 302400, + MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration + MaxBytes: 10000, + }, + Validator: &cmtproto.ValidatorParams{ + PubKeyTypes: []string{ + cmttypes.ABCIPubKeyTypeEd25519, + }, + }, + }}); err != nil { panic(fmt.Errorf("failed to initialize application: %w", err)) } } else { diff --git a/testutil/network/network.go b/testutil/network/network.go index 30e151518037..ffe833deaeed 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -26,14 +26,6 @@ import ( sdkmath "cosmossdk.io/math" "cosmossdk.io/math/unsafe" pruningtypes "cosmossdk.io/store/pruning/types" - _ "cosmossdk.io/x/accounts" - _ "cosmossdk.io/x/auth" // import auth as a blank - _ "cosmossdk.io/x/auth/tx/config" // import auth tx config as a blank - authtypes "cosmossdk.io/x/auth/types" - _ "cosmossdk.io/x/bank" // import bank as a blank - banktypes "cosmossdk.io/x/bank/types" - _ "cosmossdk.io/x/staking" // import staking as a blank - stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -51,11 +43,9 @@ import ( srvconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/testutil" - "github.com/cosmos/cosmos-sdk/testutil/configurator" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank "github.com/cosmos/cosmos-sdk/x/genutil" ) @@ -145,7 +135,7 @@ func DefaultConfig(factory TestFixtureFactory) Config { TxConfig: fixture.EncodingConfig.TxConfig, LegacyAmino: fixture.EncodingConfig.Amino, InterfaceRegistry: fixture.EncodingConfig.InterfaceRegistry, - AccountRetriever: authtypes.AccountRetriever{}, + AccountRetriever: genutil.GenAccRetriver(), AppConstructor: fixture.AppConstructor, GenesisState: fixture.GenesisState, TimeoutCommit: 2 * time.Second, @@ -169,15 +159,7 @@ func DefaultConfig(factory TestFixtureFactory) Config { // MinimumAppConfig defines the minimum of modules required for a call to New to succeed func MinimumAppConfig() depinject.Config { - return configurator.NewAppConfig( - configurator.AccountsModule(), - configurator.AuthModule(), - configurator.BankModule(), - configurator.GenutilModule(), - configurator.StakingModule(), - configurator.ConsensusModule(), - configurator.TxModule(), - ) + return genutil.MinimumAppConfig() } func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { @@ -324,9 +306,8 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { valPubKeys := make([]cryptotypes.PubKey, cfg.NumValidators) var ( - genAccounts []authtypes.GenesisAccount - genBalances []banktypes.Balance - genFiles []string + genAccs []sdk.AccAddress + genFiles []string ) buf := bufio.NewReader(os.Stdin) @@ -460,6 +441,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { if err != nil { return nil, err } + genAccs = append(genAccs, addr) // if PrintMnemonic is set to true, we print the first validator node's secret to the network's logger // for debugging and manual testing @@ -479,26 +461,19 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { return nil, err } - balances := sdk.NewCoins( - sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), cfg.AccountTokens), - sdk.NewCoin(cfg.BondDenom, cfg.StakingTokens), - ) - genFiles = append(genFiles, cmtCfg.GenesisFile()) - genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: balances.Sort()}) - genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) commission, err := sdkmath.LegacyNewDecFromStr("0.5") if err != nil { return nil, err } - createValMsg, err := stakingtypes.NewMsgCreateValidator( + createValMsg, err := genutil.GenNewMsgCreateValidator( sdk.ValAddress(addr).String(), valPubKeys[i], sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), - stakingtypes.NewDescription(nodeDirName, "", "", "", ""), - stakingtypes.NewCommissionRates(commission, sdkmath.LegacyOneDec(), sdkmath.LegacyOneDec()), + nodeDirName, + commission, sdkmath.OneInt(), ) if err != nil { @@ -580,7 +555,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { } } - err := initGenFiles(cfg, genAccounts, genBalances, genFiles) + err := initGenFiles(cfg, genAccs, genFiles) if err != nil { return nil, err } diff --git a/testutil/network/util.go b/testutil/network/util.go index a121e341ab56..76cd677c0708 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -19,14 +19,12 @@ import ( "golang.org/x/sync/errgroup" "cosmossdk.io/log" - authtypes "cosmossdk.io/x/auth/types" - banktypes "cosmossdk.io/x/bank/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" servercmtlog "github.com/cosmos/cosmos-sdk/server/log" - "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -149,8 +147,8 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { return err } - appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig, - cmtCfg, initCfg, appGenesis, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator, + appState, err := genutil.GenAppStateFromConfigWithEmptyBalIterator(cfg.Codec, cfg.TxConfig, + cmtCfg, initCfg, appGenesis, genutiltypes.DefaultMessageValidator, cfg.ValidatorAddressCodec, cfg.AddressCodec) if err != nil { return err @@ -165,27 +163,9 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { return nil } -func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string) error { - // set the accounts in the genesis state - var authGenState authtypes.GenesisState - cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[testutil.AuthModuleName], &authGenState) - - accounts, err := authtypes.PackAccounts(genAccounts) - if err != nil { - return err - } - - authGenState.Accounts = append(authGenState.Accounts, accounts...) - cfg.GenesisState[testutil.AuthModuleName] = cfg.Codec.MustMarshalJSON(&authGenState) - - // set the balances in the genesis state - var bankGenState banktypes.GenesisState - cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[testutil.BankModuleName], &bankGenState) - - bankGenState.Balances = append(bankGenState.Balances, genBalances...) - cfg.GenesisState[testutil.BankModuleName] = cfg.Codec.MustMarshalJSON(&bankGenState) - - appGenStateJSON, err := json.MarshalIndent(cfg.GenesisState, "", " ") +func initGenFiles(cfg Config, genAccs []sdk.AccAddress, genFiles []string) error { + genState, err := genutil.InitGenFileFromAddrs(genAccs, cfg.GenesisState, cfg.Codec, cfg.ChainID, cfg.BondDenom, cfg.StakingTokens, cfg.AccountTokens) + appGenStateJSON, err := json.MarshalIndent(genState, "", " ") if err != nil { return err } diff --git a/tools/hubl/internal/compat.go b/tools/hubl/internal/compat.go index 856dd9b8005c..a18627d994cf 100644 --- a/tools/hubl/internal/compat.go +++ b/tools/hubl/internal/compat.go @@ -42,7 +42,7 @@ func loadFileDescriptorsGRPCReflection(ctx context.Context, client *grpc.ClientC } fdMap := map[string]*descriptorpb.FileDescriptorProto{} - waitListServiceRes := make(chan *grpc_reflection_v1alpha.ListServiceResponse) //nolint:staticcheck // we want to use the deprecated field + waitListServiceRes := make(chan *grpc_reflection_v1alpha.ListServiceResponse) waitc := make(chan struct{}) go func() { for { @@ -60,14 +60,14 @@ func loadFileDescriptorsGRPCReflection(ctx context.Context, client *grpc.ClientC case *grpc_reflection_v1alpha.ServerReflectionResponse_ErrorResponse: panic(err) case *grpc_reflection_v1alpha.ServerReflectionResponse_ListServicesResponse: - waitListServiceRes <- res.ListServicesResponse //nolint:staticcheck // we want to use the deprecated field + waitListServiceRes <- res.ListServicesResponse case *grpc_reflection_v1alpha.ServerReflectionResponse_FileDescriptorResponse: _ = processFileDescriptorsResponse(res, fdMap) } } }() - if err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ //nolint:staticcheck // we want to use the deprecated field + if err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ MessageRequest: &grpc_reflection_v1alpha.ServerReflectionRequest_ListServices{}, }); err != nil { return nil, err @@ -75,10 +75,10 @@ func loadFileDescriptorsGRPCReflection(ctx context.Context, client *grpc.ClientC listServiceRes := <-waitListServiceRes - for _, response := range listServiceRes.Service { //nolint:staticcheck // we want to use the deprecated field - err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ //nolint:staticcheck // we want to use the deprecated field + for _, response := range listServiceRes.Service { + err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ MessageRequest: &grpc_reflection_v1alpha.ServerReflectionRequest_FileContainingSymbol{ - FileContainingSymbol: response.Name, //nolint:staticcheck // we want to use the deprecated field + FileContainingSymbol: response.Name, }, }) if err != nil { @@ -87,7 +87,7 @@ func loadFileDescriptorsGRPCReflection(ctx context.Context, client *grpc.ClientC } for _, msgName := range interfaceImplNames { - err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ //nolint:staticcheck // we want to use the deprecated field + err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ MessageRequest: &grpc_reflection_v1alpha.ServerReflectionRequest_FileContainingSymbol{ FileContainingSymbol: msgName, }, @@ -137,7 +137,7 @@ func loadFileDescriptorsGRPCReflection(ctx context.Context, client *grpc.ClientC } func processFileDescriptorsResponse(res *grpc_reflection_v1alpha.ServerReflectionResponse_FileDescriptorResponse, fdMap map[string]*descriptorpb.FileDescriptorProto) error { - for _, bz := range res.FileDescriptorResponse.FileDescriptorProto { //nolint:staticcheck // we want to use the deprecated field + for _, bz := range res.FileDescriptorResponse.FileDescriptorProto { fd := &descriptorpb.FileDescriptorProto{} err := proto.Unmarshal(bz, fd) if err != nil { @@ -188,7 +188,7 @@ func addMissingFileDescriptors(ctx context.Context, client *grpc.ClientConn, fdM }() for _, file := range missingFiles { - err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ //nolint:staticcheck // we want to use the deprecated field + err = reflectClient.Send(&grpc_reflection_v1alpha.ServerReflectionRequest{ MessageRequest: &grpc_reflection_v1alpha.ServerReflectionRequest_FileByFilename{ FileByFilename: file, }, diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index ce2f76f50875..5a4c7978cce1 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -32,13 +32,13 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/testdata" _ "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/types/tx/signing" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + simtestutil "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // TestAccount represents an account used in the tests in x/auth/ante. diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 9e25d14aa6ea..d755907cd187 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -13,11 +13,11 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // authz message types @@ -136,12 +136,12 @@ func SimulateMsgGrant( if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txCfg, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{granterAcc.GetAccountNumber()}, []uint64{granterAcc.GetSequence()}, @@ -224,12 +224,12 @@ func SimulateMsgRevoke( } msg := authz.NewMsgRevoke(granterStrAddr, granteeStrAddr, a.MsgTypeURL()) account := ak.GetAccount(ctx, granterAddr) - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txCfg, []sdk.Msg{&msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -332,12 +332,12 @@ func SimulateMsgExec( } granteeAcc := ak.GetAccount(ctx, granteeAddr) - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txCfg, []sdk.Msg{&msgExec}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{granteeAcc.GetAccountNumber()}, []uint64{granteeAcc.GetSequence()}, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index b3933b6d01e1..b3f67959bb7d 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -10,10 +10,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // Simulation operation weights constants @@ -171,12 +171,12 @@ func sendMsgSend( return err } } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -406,12 +406,12 @@ func sendMsgMultiSend( return err } } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, accountNumbers, sequenceNumbers, diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index a958a47544e9..5824b29647f6 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -7,9 +7,7 @@ import ( "io" "os" "testing" - "time" - abci_server "github.com/cometbft/cometbft/abci/server" "github.com/spf13/viper" "github.com/stretchr/testify/require" @@ -22,10 +20,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/server" - servercmtlog "github.com/cosmos/cosmos-sdk/server/log" - "github.com/cosmos/cosmos-sdk/server/mock" "github.com/cosmos/cosmos-sdk/testutil" - "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -202,37 +197,6 @@ func TestEmptyState(t *testing.T) { require.Contains(t, out, "app_state") } -func TestStartStandAlone(t *testing.T) { - home := t.TempDir() - logger := log.NewNopLogger() - interfaceRegistry := types.NewInterfaceRegistry() - marshaler := codec.NewProtoCodec(interfaceRegistry) - err := genutiltest.ExecInitCmd(testMbm, home, marshaler) - require.NoError(t, err) - - app, err := mock.NewApp(home, logger) - require.NoError(t, err) - - svrAddr, _, closeFn, err := network.FreeTCPAddr() - require.NoError(t, err) - require.NoError(t, closeFn()) - - cmtApp := server.NewCometABCIWrapper(app) - svr, err := abci_server.NewServer(svrAddr, "socket", cmtApp) - require.NoError(t, err, "error creating listener") - - svr.SetLogger(servercmtlog.CometLoggerWrapper{Logger: logger.With("module", "abci-server")}) - err = svr.Start() - require.NoError(t, err) - - timer := time.NewTimer(time.Duration(2) * time.Second) - for range timer.C { - err = svr.Stop() - require.NoError(t, err) - break - } -} - func TestInitNodeValidatorFiles(t *testing.T) { home := t.TempDir() cfg, err := genutiltest.CreateDefaultCometConfig(home) diff --git a/x/genutil/collect.go b/x/genutil/collect.go index 9881ade81f57..345027c26f87 100644 --- a/x/genutil/collect.go +++ b/x/genutil/collect.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/core/address" bankexported "cosmossdk.io/x/bank/exported" + banktypes "cosmossdk.io/x/bank/types" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" @@ -22,6 +23,14 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil/types" ) +// GenAppStateFromConfig gets the genesis app state from the config +func GenAppStateFromConfigWithEmptyBalIterator(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, + config *cfg.Config, initCfg types.InitConfig, genesis *types.AppGenesis, + validator types.MessageValidator, valAddrCodec address.ValidatorAddressCodec, addressCodec address.Codec, +) (appState json.RawMessage, err error) { + return GenAppStateFromConfig(cdc, txEncodingConfig, config, initCfg, genesis, banktypes.GenesisBalancesIterator{}, validator, valAddrCodec, addressCodec) +} + // GenAppStateFromConfig gets the genesis app state from the config func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, config *cfg.Config, initCfg types.InitConfig, genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator, diff --git a/x/genutil/genaccounts.go b/x/genutil/genaccounts.go index d55fdd3ef903..5c1d4fd5cfb4 100644 --- a/x/genutil/genaccounts.go +++ b/x/genutil/genaccounts.go @@ -10,6 +10,7 @@ import ( authvesting "cosmossdk.io/x/auth/vesting/types" banktypes "cosmossdk.io/x/bank/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -151,3 +152,7 @@ func AddGenesisAccount( appGenesis.AppState = appStateJSON return ExportGenesisFile(appGenesis, genesisFileURL) } + +func GenAccRetriver() client.AccountRetriever { + return authtypes.AccountRetriever{} +} diff --git a/x/genutil/utils.go b/x/genutil/utils.go index 880aa7bdc1c0..39a9cc7041f1 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -14,8 +14,23 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/go-bip39" + "cosmossdk.io/depinject" + "cosmossdk.io/math" + authtypes "cosmossdk.io/x/auth/types" + banktypes "cosmossdk.io/x/bank/types" + stakingtypes "cosmossdk.io/x/staking/types" + + _ "cosmossdk.io/x/accounts" + _ "cosmossdk.io/x/auth" // import auth as a blank + _ "cosmossdk.io/x/auth/tx/config" // import auth tx config as a blank + _ "cosmossdk.io/x/bank" // import bank as a blank + _ "cosmossdk.io/x/staking" // import staking as a blank + "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/testutil/configurator" + sdk "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -92,3 +107,68 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic strin return nodeID, valPubKey, nil } + +func InitGenFileFromAddrs(addrs []sdk.AccAddress, genState map[string]json.RawMessage, codec codec.Codec, chainId, bondDenom string, stakeAmount, accAmount math.Int) (map[string]json.RawMessage, error) { + var ( + genAccounts []authtypes.GenesisAccount + genBalances []banktypes.Balance + authGenState authtypes.GenesisState + bankGenState banktypes.GenesisState + ) + + for i := 0; i < len(addrs); i++ { + + balances := sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", fmt.Sprintf("node%d", i)), accAmount), + sdk.NewCoin(bondDenom, stakeAmount), + ) + + genBalances = append(genBalances, banktypes.Balance{Address: addrs[i].String(), Coins: balances.Sort()}) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addrs[i], nil, 0, 0)) + } + + codec.MustUnmarshalJSON(genState[authtypes.ModuleName], &authGenState) + + accounts, err := authtypes.PackAccounts(genAccounts) + if err != nil { + return nil, err + } + + authGenState.Accounts = append(authGenState.Accounts, accounts...) + genState[authtypes.ModuleName] = codec.MustMarshalJSON(&authGenState) + + // set the balances in the genesis state + codec.MustUnmarshalJSON(genState[banktypes.ModuleName], &bankGenState) + + bankGenState.Balances = append(bankGenState.Balances, genBalances...) + genState[banktypes.ModuleName] = codec.MustMarshalJSON(&bankGenState) + + return genState, nil +} + +func GenNewMsgCreateValidator( + valAddr string, pubKey cryptotypes.PubKey, + selfDelegation sdk.Coin, moniker string, commission math.LegacyDec, minSelfDelegation math.Int, +) (*stakingtypes.MsgCreateValidator, error) { + return stakingtypes.NewMsgCreateValidator( + valAddr, + pubKey, + selfDelegation, + stakingtypes.NewDescription(moniker, "", "", "", ""), + stakingtypes.NewCommissionRates(commission, math.LegacyOneDec(), math.LegacyOneDec()), + minSelfDelegation, + ) +} + +// MinimumAppConfig defines the minimum of modules required for a call to New to succeed +func MinimumAppConfig() depinject.Config { + return configurator.NewAppConfig( + configurator.AccountsModule(), + configurator.AuthModule(), + configurator.BankModule(), + configurator.GenutilModule(), + configurator.StakingModule(), + configurator.ConsensusModule(), + configurator.TxModule(), + ) +} diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 6941bcc87d38..5828729829b0 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -12,10 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var initialProposalID = uint64(100000000000000) @@ -266,12 +266,12 @@ func simulateMsgSubmitProposal( } account := ak.GetAccount(ctx, simAccount.Address) - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index df64641858cd..aff6e0cd29d5 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -15,10 +15,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) var initialGroupID = uint64(100000000000000) @@ -246,12 +246,12 @@ func SimulateMsgCreateGroup( } msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)} - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -316,12 +316,12 @@ func SimulateMsgCreateGroupWithPolicy( return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "unable to set decision policy"), nil, err } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -386,12 +386,12 @@ func SimulateMsgCreateGroupPolicy( return simtypes.NoOpMsg(group.ModuleName, TypeMsgCreateGroupPolicy, err.Error()), nil, err } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -473,12 +473,12 @@ func SimulateMsgSubmitProposal( Summary: "Summary of the proposal", } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -546,12 +546,12 @@ func SimulateMsgUpdateGroupAdmin( NewAdmin: newAdminAddr, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -606,12 +606,12 @@ func SimulateMsgUpdateGroupMetadata( Metadata: simtypes.RandStringOfLength(r, 10), } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -696,12 +696,12 @@ func SimulateMsgUpdateGroupMembers( MemberUpdates: members, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -769,12 +769,12 @@ func SimulateMsgUpdateGroupPolicyAdmin( NewAdmin: newAdminAddr, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -843,12 +843,12 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy( return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, err.Error()), nil, err } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -902,12 +902,12 @@ func SimulateMsgUpdateGroupPolicyMetadata( Metadata: simtypes.RandStringOfLength(r, 10), } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -1014,12 +1014,12 @@ func SimulateMsgWithdrawProposal( Address: proposerAddr, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{proposerAcc.GetAccountNumber()}, []uint64{proposerAcc.GetSequence()}, @@ -1126,12 +1126,12 @@ func SimulateMsgVote( Option: group.VOTE_OPTION_YES, Metadata: simtypes.RandStringOfLength(r, 10), } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -1210,12 +1210,12 @@ func SimulateMsgExec( ProposalId: uint64(proposalID), Executor: accAddr, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, @@ -1281,12 +1281,12 @@ func SimulateMsgLeaveGroup( GroupId: groupInfo.Id, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + 10000000, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 5128d8147749..f3523283ab8f 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -10,10 +10,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) const ( @@ -104,12 +104,12 @@ func SimulateMsgSend( Receiver: receiverStr, } - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txCfg, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, diff --git a/testutil/sims/app_helpers.go b/x/simulation/helper/app_helpers.go similarity index 99% rename from testutil/sims/app_helpers.go rename to x/simulation/helper/app_helpers.go index d7c118a4ee99..9b67e52f38d5 100644 --- a/testutil/sims/app_helpers.go +++ b/x/simulation/helper/app_helpers.go @@ -1,4 +1,4 @@ -package sims +package helper import ( "encoding/json" diff --git a/testutil/sims/simulation_helpers.go b/x/simulation/helper/simulation_helpers.go similarity index 99% rename from testutil/sims/simulation_helpers.go rename to x/simulation/helper/simulation_helpers.go index c06ab9e3e64e..33ffec006d2c 100644 --- a/testutil/sims/simulation_helpers.go +++ b/x/simulation/helper/simulation_helpers.go @@ -1,4 +1,4 @@ -package sims +package helper import ( "bytes" @@ -49,6 +49,7 @@ func SetupSimulation(config simtypes.Config, dirPrefix, dbName string, verbose, return db, dir, logger, false, nil } +// Can move to simapp // SimulationOperations retrieves the simulation params from the provided file path // and returns all the modules weighted operations func SimulationOperations(app runtime.AppSimI, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation { diff --git a/testutil/sims/simulation_helpers_test.go b/x/simulation/helper/simulation_helpers_test.go similarity index 92% rename from testutil/sims/simulation_helpers_test.go rename to x/simulation/helper/simulation_helpers_test.go index b22c86e40c92..94a02f6eda5a 100644 --- a/testutil/sims/simulation_helpers_test.go +++ b/x/simulation/helper/simulation_helpers_test.go @@ -1,4 +1,4 @@ -package sims +package helper_test import ( "fmt" @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) const ( @@ -53,7 +54,7 @@ func TestGetSimulationLog(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.store, func(t *testing.T) { - require.Equal(t, tt.expectedLog, GetSimulationLog(tt.store, decoders, tt.kvPairs, tt.kvPairs), tt.store) + require.Equal(t, tt.expectedLog, helper.GetSimulationLog(tt.store, decoders, tt.kvPairs, tt.kvPairs), tt.store) }) } } @@ -103,7 +104,7 @@ func TestDiffKVStores(t *testing.T) { func checkDiffResults(t *testing.T, store1, store2 storetypes.KVStore, noDiff bool, skipPrefixes [][]byte) { t.Helper() - kvAs1, kvBs1 := DiffKVStores(store1, store2, skipPrefixes) + kvAs1, kvBs1 := helper.DiffKVStores(store1, store2, skipPrefixes) if noDiff { assert.Assert(t, len(kvAs1) == 0) diff --git a/testutil/sims/state_helpers.go b/x/simulation/helper/state_helpers.go similarity index 99% rename from testutil/sims/state_helpers.go rename to x/simulation/helper/state_helpers.go index 68885c52568d..9b8ad2b076f9 100644 --- a/testutil/sims/state_helpers.go +++ b/x/simulation/helper/state_helpers.go @@ -1,4 +1,4 @@ -package sims +package helper import ( "bufio" diff --git a/testutil/sims/tx_helpers.go b/x/simulation/helper/tx_helpers.go similarity index 99% rename from testutil/sims/tx_helpers.go rename to x/simulation/helper/tx_helpers.go index 24e0ad0365d2..1f161ad6caea 100644 --- a/testutil/sims/tx_helpers.go +++ b/x/simulation/helper/tx_helpers.go @@ -1,4 +1,4 @@ -package sims +package helper import ( "context" diff --git a/x/simulation/params.go b/x/simulation/params.go index b5c298d92371..d81716def5e0 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -151,14 +151,14 @@ func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFn { // WeightedProposalContent defines a common struct for proposal content defined by external modules (i.e outside gov) // -//nolint:staticcheck // used for legacy testing + type WeightedProposalContent struct { appParamsKey string // key used to retrieve the value of the weight from the simulation application params defaultWeight int // default weight contentSimulatorFn simulation.ContentSimulatorFn // content simulator function } -func NewWeightedProposalContent(appParamsKey string, defaultWeight int, contentSimulatorFn simulation.ContentSimulatorFn) simulation.WeightedProposalContent { //nolint:staticcheck // used for legacy testing +func NewWeightedProposalContent(appParamsKey string, defaultWeight int, contentSimulatorFn simulation.ContentSimulatorFn) simulation.WeightedProposalContent { return &WeightedProposalContent{appParamsKey: appParamsKey, defaultWeight: defaultWeight, contentSimulatorFn: contentSimulatorFn} } @@ -170,7 +170,7 @@ func (w WeightedProposalContent) DefaultWeight() int { return w.defaultWeight } -func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulatorFn { //nolint:staticcheck // used for legacy testing +func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulatorFn { return w.contentSimulatorFn } diff --git a/x/simulation/params_test.go b/x/simulation/params_test.go index e4d6f380d101..fac3844d537e 100644 --- a/x/simulation/params_test.go +++ b/x/simulation/params_test.go @@ -29,7 +29,7 @@ func TestNewWeightedProposalContent(t *testing.T) { key := "theKey" weight := 1 content := &testContent{} - f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { //nolint:staticcheck // used for legacy testing + f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { return content } diff --git a/x/simulation/util.go b/x/simulation/util.go index 5fba0973f850..d04e87b58e60 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -9,9 +9,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B) { @@ -100,12 +100,12 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [ // GenAndDeliverTx generates a transactions and delivers it. func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( txCtx.R, txCtx.TxGen, []sdk.Msg{txCtx.Msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, txCtx.Context.ChainID(), []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 7dce1d345157..8d6e1b0bc264 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -12,10 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation/helper" ) // Simulation operation weights constants @@ -117,12 +117,12 @@ func SimulateMsgUnjail( msg := types.NewMsgUnjail(validator.GetOperator()) - tx, err := simtestutil.GenSignedMockTx( + tx, err := helper.GenSignedMockTx( r, txGen, []sdk.Msg{msg}, fees, - simtestutil.DefaultGenTxGas, + helper.DefaultGenTxGas, chainID, []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()},