From 88859c7d4dd23ccd8a3537ff055c9b496f6c1121 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 18 Dec 2024 09:47:12 +0100 Subject: [PATCH] refactor: limit breaking changes for next version (#22972) (cherry picked from commit ca559989da43557315d7520b107ce630aeee767e) --- client/grpc_query_test.go | 3 +-- .../distribution/migration_v4_test.go | 3 +-- testutil/integration/helpers.go | 19 +++---------------- .../module/testutil/{codec.go => helpers.go} | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 20 deletions(-) rename types/module/testutil/{codec.go => helpers.go} (81%) diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index d0d43a6d3023..8e32d8221d25 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -15,7 +15,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/runtime" - "github.com/cosmos/cosmos-sdk/testutil/integration" "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/cosmos/cosmos-sdk/testutil/x/counter" counterkeeper "github.com/cosmos/cosmos-sdk/testutil/x/counter/keeper" @@ -38,7 +37,7 @@ func (s *IntegrationTestSuite) SetupSuite() { logger := log.NewNopLogger() keys := storetypes.NewKVStoreKeys(countertypes.StoreKey) - cms := integration.CreateMultiStore(keys, logger) + cms := moduletestutil.CreateMultiStore(keys, logger) s.ctx = sdk.NewContext(cms, true, logger) cfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, counter.AppModule{}) s.cdc = cfg.Codec diff --git a/tests/integration/distribution/migration_v4_test.go b/tests/integration/distribution/migration_v4_test.go index 7be836386982..9d4c5bd49b29 100644 --- a/tests/integration/distribution/migration_v4_test.go +++ b/tests/integration/distribution/migration_v4_test.go @@ -26,7 +26,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" - "github.com/cosmos/cosmos-sdk/testutil/integration" sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth" @@ -75,7 +74,7 @@ func TestFundsMigration(t *testing.T) { authtypes.StoreKey, banktypes.StoreKey, disttypes.StoreKey, ) logger := log.NewTestLogger(t) - cms := integration.CreateMultiStore(keys, logger) + cms := moduletestutil.CreateMultiStore(keys, logger) encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, auth.AppModule{}, bank.AppModule{}, distribution.AppModule{}) ctx := sdk.NewContext(cms, true, logger) addressCodec := addresscodec.NewBech32Codec(sdk.Bech32MainPrefix) diff --git a/testutil/integration/helpers.go b/testutil/integration/helpers.go index ea844c17411b..94bbdca35c58 100644 --- a/testutil/integration/helpers.go +++ b/testutil/integration/helpers.go @@ -1,22 +1,9 @@ package integration import ( - coretesting "cosmossdk.io/core/testing" - "cosmossdk.io/log" - "cosmossdk.io/store" - "cosmossdk.io/store/metrics" - storetypes "cosmossdk.io/store/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) // CreateMultiStore is a helper for setting up multiple stores for provided modules. -func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger) storetypes.CommitMultiStore { - db := coretesting.NewMemDB() - cms := store.NewCommitMultiStore(db, logger, metrics.NewNoOpMetrics()) - - for key := range keys { - cms.MountStoreWithDB(keys[key], storetypes.StoreTypeIAVL, db) - } - - _ = cms.LoadLatestVersion() - return cms -} +// Deprecated: use github.com/cosmos/cosmos-sdk/types/module/testutil.CreateMultiStore instead. +var CreateMultiStore = moduletestutil.CreateMultiStore diff --git a/types/module/testutil/codec.go b/types/module/testutil/helpers.go similarity index 81% rename from types/module/testutil/codec.go rename to types/module/testutil/helpers.go index 2250b1208555..3a0d3033579f 100644 --- a/types/module/testutil/codec.go +++ b/types/module/testutil/helpers.go @@ -1,6 +1,12 @@ package testutil import ( + coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/testutil" @@ -78,3 +84,16 @@ type TestTxBuilder struct { func (b *TestTxBuilder) SetExtensionOptions(extOpts ...*types.Any) { b.ExtOptions = extOpts } + +// CreateMultiStore is a helper for setting up multiple stores for provided modules. +func CreateMultiStore(keys map[string]*storetypes.KVStoreKey, logger log.Logger) storetypes.CommitMultiStore { + db := coretesting.NewMemDB() + cms := store.NewCommitMultiStore(db, logger, metrics.NewNoOpMetrics()) + + for key := range keys { + cms.MountStoreWithDB(keys[key], storetypes.StoreTypeIAVL, db) + } + + _ = cms.LoadLatestVersion() + return cms +}