From 8dba5e6e649268da2df896497bee6a7d9e314c85 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 9 Feb 2024 17:48:32 +0100 Subject: [PATCH] wip: trying to use GovGenSimApp --- ante/fee_test.go | 2 +- app/app.go | 2 +- app/sim/sim_state.go | 2 +- app/sim/sim_utils.go | 2 +- app/sim_test.go | 2 +- go.mod | 3 +-- go.sum | 2 -- x/gov/abci_test.go | 27 +++++++++++----------- x/gov/client/testutil/helpers.go | 36 +++++++++++++++++++++++++++++ x/gov/client/utils/query_test.go | 2 +- x/gov/genesis_test.go | 17 ++++++++------ x/gov/keeper/common_test.go | 3 +-- x/gov/keeper/deposit_test.go | 3 +-- x/gov/keeper/grpc_query_test.go | 3 +-- x/gov/keeper/hooks_test.go | 7 +++--- x/gov/keeper/keeper_test.go | 3 +-- x/gov/keeper/querier_test.go | 9 ++++---- x/gov/keeper/tally_test.go | 3 +-- x/gov/keeper/vote_test.go | 3 +-- x/gov/module_test.go | 3 +-- x/gov/simulation/decoder_test.go | 3 +-- x/gov/simulation/operations.go | 4 ++-- x/gov/simulation/operations_test.go | 19 +++++++-------- x/gov/simulation/proposals.go | 3 +-- x/gov/simulation/proposals_test.go | 2 +- 25 files changed, 98 insertions(+), 67 deletions(-) diff --git a/ante/fee_test.go b/ante/fee_test.go index bb79d230..4cb80761 100644 --- a/ante/fee_test.go +++ b/ante/fee_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -19,7 +20,6 @@ import ( "github.com/atomone-hub/govgen/v1/ante" govgenapp "github.com/atomone-hub/govgen/v1/app" govgenhelpers "github.com/atomone-hub/govgen/v1/app/helpers" - "github.com/atomone-hub/govgen/v1/simapp" ) type FeeIntegrationTestSuite struct { diff --git a/app/app.go b/app/app.go index dfdcd965..47bdd9ac 100644 --- a/app/app.go +++ b/app/app.go @@ -29,6 +29,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" @@ -45,7 +46,6 @@ import ( "github.com/atomone-hub/govgen/v1/app/keepers" govgenappparams "github.com/atomone-hub/govgen/v1/app/params" "github.com/atomone-hub/govgen/v1/app/upgrades" - "github.com/atomone-hub/govgen/v1/simapp" ) var ( diff --git a/app/sim/sim_state.go b/app/sim/sim_state.go index e9c92f0c..e2d1dcce 100644 --- a/app/sim/sim_state.go +++ b/app/sim/sim_state.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -21,7 +22,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" govgen "github.com/atomone-hub/govgen/v1/app" - simappparams "github.com/atomone-hub/govgen/v1/simapp/params" ) // AppStateFn returns the initial application state using a genesis or the simulation parameters. diff --git a/app/sim/sim_utils.go b/app/sim/sim_utils.go index 316d1acc..2f7a6441 100644 --- a/app/sim/sim_utils.go +++ b/app/sim/sim_utils.go @@ -9,13 +9,13 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" govgen "github.com/atomone-hub/govgen/v1/app" - "github.com/atomone-hub/govgen/v1/simapp/helpers" ) // SetupSimulation creates the config, db (levelDB), temporary directory and logger for diff --git a/app/sim_test.go b/app/sim_test.go index ea572884..35fb6ac1 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -12,6 +12,7 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store" simulation2 "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -20,7 +21,6 @@ import ( "github.com/atomone-hub/govgen/v1/app/helpers" "github.com/atomone-hub/govgen/v1/app/params" "github.com/atomone-hub/govgen/v1/app/sim" - "github.com/atomone-hub/govgen/v1/simapp" ) func init() { diff --git a/go.mod b/go.mod index 9e1e4bff..b8589c02 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/armon/go-metrics v0.4.1 github.com/cosmos/cosmos-sdk v0.45.16 github.com/gogo/protobuf v1.3.3 - github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/google/gofuzz v1.2.0 github.com/gorilla/mux v1.8.1 @@ -16,7 +15,6 @@ require ( github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.34.27 github.com/tendermint/tm-db v0.6.7 @@ -124,6 +122,7 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.10.0 // indirect + github.com/spf13/viper v1.17.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect diff --git a/go.sum b/go.sum index 08207d58..10067657 100644 --- a/go.sum +++ b/go.sum @@ -423,7 +423,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -1403,7 +1402,6 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index cc76ecd1..0feeaa72 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -9,18 +9,19 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" "github.com/atomone-hub/govgen/v1/x/gov" + "github.com/atomone-hub/govgen/v1/x/gov/client/testutil" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking" ) func TestTickExpiredDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 10, valTokens) header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -70,9 +71,9 @@ func TestTickExpiredDepositPeriod(t *testing.T) { } func TestTickMultipleExpiredDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 10, valTokens) header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -147,9 +148,9 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { } func TestTickPassedDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 10, valTokens) header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -204,9 +205,9 @@ func TestTickPassedDepositPeriod(t *testing.T) { } func TestTickPassedVotingPeriod(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 10, valTokens) SortAddresses(addrs) @@ -272,9 +273,9 @@ func TestTickPassedVotingPeriod(t *testing.T) { } func TestProposalPassedEndblocker(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 10, valTokens) SortAddresses(addrs) @@ -323,9 +324,9 @@ func TestProposalPassedEndblocker(t *testing.T) { } func TestEndBlockerProposalHandlerFailed(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 1, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 1, valTokens) SortAddresses(addrs) diff --git a/x/gov/client/testutil/helpers.go b/x/gov/client/testutil/helpers.go index 19ab9c53..5a3ab015 100644 --- a/x/gov/client/testutil/helpers.go +++ b/x/gov/client/testutil/helpers.go @@ -4,14 +4,50 @@ import ( "fmt" govcli "github.com/atomone-hub/govgen/v1/x/gov/client/cli" + "github.com/atomone-hub/govgen/v1/x/gov/keeper" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" sdk "github.com/cosmos/cosmos-sdk/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/params" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/x/upgrade" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) +type GovGenSimApp struct { + *simapp.SimApp + GovKeeper keeper.Keeper +} + +func SimAppSetup(isCheckTx bool) GovGenSimApp { + app := simapp.Setup(isCheckTx) + govRouter := govtypes.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)) + keeper := keeper.NewKeeper( + app.AppCodec(), app.GetKey(govtypes.StoreKey), app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, + app.StakingKeeper, govRouter, + ) + keeper = *keeper.SetHooks( + govtypes.NewMultiGovHooks( + // register the governance hooks + ), + ) + return GovGenSimApp{ + SimApp: app, + GovKeeper: keeper, + } +} + var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 2b21d7e4..965aa06f 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -10,10 +10,10 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" "github.com/atomone-hub/govgen/v1/x/gov/client/utils" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" "github.com/cosmos/cosmos-sdk/x/gov/types" diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 6862f1f8..2bb3c225 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -10,9 +10,10 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/atomone-hub/govgen/v1/simapp" "github.com/atomone-hub/govgen/v1/x/gov" + "github.com/atomone-hub/govgen/v1/x/gov/client/testutil" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -21,9 +22,9 @@ import ( ) func TestImportExportQueues(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 2, valTokens) SortAddresses(addrs) @@ -70,7 +71,9 @@ func TestImportExportQueues(t *testing.T) { } db := dbm.NewMemDB() - app2 := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 0, simapp.MakeTestEncodingConfig(), simapp.EmptyAppOptions{}) + app2 := testutil.GovGenSimApp{ + SimApp: simapp.NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 0, simapp.MakeTestEncodingConfig(), simapp.EmptyAppOptions{}), + } app2.InitChain( abci.RequestInitChain{ @@ -114,7 +117,7 @@ func TestImportExportQueues(t *testing.T) { } func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) require.Panics(t, func() { gov.InitGenesis(ctx, app.AccountKeeper, app.BankKeeper, app.GovKeeper, &types.GenesisState{ @@ -135,9 +138,9 @@ func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { } func TestEqualProposals(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 2, valTokens) SortAddresses(addrs) diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index 2247660c..7b002b13 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -5,8 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking" diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index cf084e15..0c8e3706 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -7,8 +7,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 480e1a57..0e7d6f25 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -5,8 +5,7 @@ import ( "fmt" "strconv" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/gov/types" diff --git a/x/gov/keeper/hooks_test.go b/x/gov/keeper/hooks_test.go index 2f467eda..1d045b58 100644 --- a/x/gov/keeper/hooks_test.go +++ b/x/gov/keeper/hooks_test.go @@ -7,10 +7,11 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" "github.com/atomone-hub/govgen/v1/x/gov" + "github.com/atomone-hub/govgen/v1/x/gov/client/testutil" "github.com/atomone-hub/govgen/v1/x/gov/keeper" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -47,11 +48,11 @@ func (h *MockGovHooksReceiver) AfterProposalVotingPeriodEnded(ctx sdk.Context, p } func TestHooks(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) minDeposit := app.GovKeeper.GetDepositParams(ctx).MinDeposit - addrs := simapp.AddTestAddrs(app, ctx, 1, minDeposit[0].Amount) + addrs := simapp.AddTestAddrs(app.SimApp, ctx, 1, minDeposit[0].Amount) govHooksReceiver := MockGovHooksReceiver{} diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 8c0efa9a..105a9d00 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -7,9 +7,8 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index f8a2ca52..ca13d516 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -10,10 +10,11 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" + "github.com/atomone-hub/govgen/v1/x/gov/client/testutil" "github.com/atomone-hub/govgen/v1/x/gov/keeper" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -146,12 +147,12 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, quer } func TestQueries(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) legacyQuerierCdc := app.LegacyAmino() querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(20000001)) + TestAddrs := simapp.AddTestAddrsIncremental(app.SimApp, ctx, 2, sdk.NewInt(20000001)) oneCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)) consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) @@ -305,7 +306,7 @@ func TestQueries(t *testing.T) { } func TestPaginatedVotesQuery(t *testing.T) { - app := simapp.Setup(false) + app := testutil.SimAppSetup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) legacyQuerierCdc := app.LegacyAmino() diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 48a8cceb..7347cfbe 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -6,8 +6,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking" diff --git a/x/gov/keeper/vote_test.go b/x/gov/keeper/vote_test.go index 6bc66a0b..80df4671 100644 --- a/x/gov/keeper/vote_test.go +++ b/x/gov/keeper/vote_test.go @@ -6,8 +6,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/gov/module_test.go b/x/gov/module_test.go index e96c185f..4e54c0b7 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -7,8 +7,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - + "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 65d16807..92703293 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -8,10 +8,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/atomone-hub/govgen/v1/simapp" "github.com/atomone-hub/govgen/v1/x/gov/simulation" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" "github.com/cosmos/cosmos-sdk/x/gov/types" diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index f47f19f9..3a8b59a1 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -5,12 +5,12 @@ import ( "math/rand" "time" - "github.com/atomone-hub/govgen/v1/simapp/helpers" - simappparams "github.com/atomone-hub/govgen/v1/simapp/params" "github.com/atomone-hub/govgen/v1/x/gov/keeper" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/simapp/helpers" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gov/types" diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index 110df8a6..6da1985f 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -10,10 +10,11 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/atomone-hub/govgen/v1/simapp" - simappparams "github.com/atomone-hub/govgen/v1/simapp/params" + "github.com/atomone-hub/govgen/v1/x/gov/client/testutil" "github.com/atomone-hub/govgen/v1/x/gov/simulation" + "github.com/cosmos/cosmos-sdk/simapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -67,7 +68,7 @@ func TestWeightedOperations(t *testing.T) { // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) - accs := getTestingAccounts(t, r, app, ctx, 3) + accs := getTestingAccounts(t, r, app.SimApp, ctx, 3) expected := []struct { weight int @@ -101,7 +102,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) - accounts := getTestingAccounts(t, r, app, ctx, 3) + accounts := getTestingAccounts(t, r, app.SimApp, ctx, 3) // begin a new block app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}}) @@ -133,7 +134,7 @@ func TestSimulateMsgDeposit(t *testing.T) { // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) - accounts := getTestingAccounts(t, r, app, ctx, 3) + accounts := getTestingAccounts(t, r, app.SimApp, ctx, 3) // setup a proposal content := types.NewTextProposal("Test", "description") @@ -175,7 +176,7 @@ func TestSimulateMsgVote(t *testing.T) { // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) - accounts := getTestingAccounts(t, r, app, ctx, 3) + accounts := getTestingAccounts(t, r, app.SimApp, ctx, 3) // setup a proposal content := types.NewTextProposal("Test", "description") @@ -217,7 +218,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) - accounts := getTestingAccounts(t, r, app, ctx, 3) + accounts := getTestingAccounts(t, r, app.SimApp, ctx, 3) // setup a proposal content := types.NewTextProposal("Test", "description") @@ -250,8 +251,8 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { } // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(isCheckTx bool) (testutil.GovGenSimApp, sdk.Context) { + app := testutil.SimAppSetup(isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) diff --git a/x/gov/simulation/proposals.go b/x/gov/simulation/proposals.go index 702f98a6..322774c9 100644 --- a/x/gov/simulation/proposals.go +++ b/x/gov/simulation/proposals.go @@ -3,8 +3,7 @@ package simulation import ( "math/rand" - simappparams "github.com/atomone-hub/govgen/v1/simapp/params" - + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/gov/types" diff --git a/x/gov/simulation/proposals_test.go b/x/gov/simulation/proposals_test.go index b72671d7..28a21c4d 100644 --- a/x/gov/simulation/proposals_test.go +++ b/x/gov/simulation/proposals_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - simappparams "github.com/atomone-hub/govgen/v1/simapp/params" "github.com/atomone-hub/govgen/v1/x/gov/simulation" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" )