feat: replace the cosmos-db usecases in the tests with core/testing (#21525)
This commit is contained in:
+5
-5
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
coretesting "cosmossdk.io/core/testing"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/x/accounts"
|
||||
authzmodule "cosmossdk.io/x/authz/module"
|
||||
@@ -44,7 +44,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSimAppExportAndBlockedAddrs(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
db := coretesting.NewMemDB()
|
||||
logger := log.NewTestLogger(t)
|
||||
app := NewSimappWithCustomOptions(t, false, SetupOptions{
|
||||
Logger: logger.With("instance", "first"),
|
||||
@@ -86,7 +86,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunMigrations(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
db := coretesting.NewMemDB()
|
||||
logger := log.NewTestLogger(t)
|
||||
app := NewSimApp(logger.With("instance", "simapp"), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
|
||||
|
||||
@@ -232,7 +232,7 @@ func TestRunMigrations(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitGenesisOnMigration(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
db := coretesting.NewMemDB()
|
||||
app := NewSimApp(log.NewTestLogger(t), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
|
||||
ctx := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
|
||||
|
||||
@@ -271,7 +271,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpgradeStateOnGenesis(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
db := coretesting.NewMemDB()
|
||||
app := NewSimappWithCustomOptions(t, false, SetupOptions{
|
||||
Logger: log.NewTestLogger(t),
|
||||
DB: db,
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ require (
|
||||
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860
|
||||
cosmossdk.io/collections v0.4.0
|
||||
cosmossdk.io/core v1.0.0-alpha.2
|
||||
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/depinject v1.0.0
|
||||
cosmossdk.io/log v1.4.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
@@ -34,7 +34,7 @@ require (
|
||||
cosmossdk.io/x/upgrade v0.0.0-20230613133644-0a778132a60f
|
||||
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
|
||||
github.com/cometbft/cometbft/api v1.0.0-rc.1
|
||||
github.com/cosmos/cosmos-db v1.0.3-0.20240911104526-ddc3f09bfc22
|
||||
github.com/cosmos/cosmos-db v1.0.3-0.20240911104526-ddc3f09bfc22 // indirect
|
||||
// this version is not used as it is always replaced by the latest Cosmos SDK version
|
||||
github.com/cosmos/cosmos-sdk v0.53.0
|
||||
github.com/cosmos/gogoproto v1.7.0
|
||||
|
||||
@@ -846,6 +846,8 @@ go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVf
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -87,7 +86,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
|
||||
}
|
||||
|
||||
if config.Commit {
|
||||
db, ok := db.(dbm.DB)
|
||||
db, ok := db.(simtestutil.DBStatsInterface)
|
||||
if ok {
|
||||
simtestutil.PrintStats(db)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ package cmd
|
||||
import (
|
||||
"os"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
coretesting "cosmossdk.io/core/testing"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/simapp"
|
||||
"cosmossdk.io/simapp/params"
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
func NewRootCmd() *cobra.Command {
|
||||
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
|
||||
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
|
||||
tempApp := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome))
|
||||
tempApp := simapp.NewSimApp(log.NewNopLogger(), coretesting.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome))
|
||||
encodingConfig := params.EncodingConfig{
|
||||
InterfaceRegistry: tempApp.InterfaceRegistry(),
|
||||
Codec: tempApp.AppCodec(),
|
||||
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
cmtjson "github.com/cometbft/cometbft/libs/json"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
corestore "cosmossdk.io/core/store"
|
||||
coretesting "cosmossdk.io/core/testing"
|
||||
"cosmossdk.io/log"
|
||||
sdkmath "cosmossdk.io/math"
|
||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||
@@ -35,12 +36,12 @@ import (
|
||||
// SetupOptions defines arguments that are passed into `Simapp` constructor.
|
||||
type SetupOptions struct {
|
||||
Logger log.Logger
|
||||
DB *dbm.MemDB
|
||||
DB corestore.KVStoreWithBatch
|
||||
AppOpts servertypes.AppOptions
|
||||
}
|
||||
|
||||
func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
|
||||
db := dbm.NewMemDB()
|
||||
db := coretesting.NewMemDB()
|
||||
|
||||
appOptions := make(simtestutil.AppOptionsMap, 0)
|
||||
appOptions[flags.FlagHome] = DefaultNodeHome
|
||||
@@ -234,11 +235,11 @@ func NewTestNetworkFixture() network.TestFixture {
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
app := NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir))
|
||||
app := NewSimApp(log.NewNopLogger(), coretesting.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir))
|
||||
|
||||
appCtr := func(val network.ValidatorI) servertypes.Application {
|
||||
return NewSimApp(
|
||||
val.GetLogger(), dbm.NewMemDB(), nil, true,
|
||||
val.GetLogger(), coretesting.NewMemDB(), nil, true,
|
||||
simtestutil.NewAppOptionsWithFlagHome(client.GetConfigFromViper(val.GetViper()).RootDir),
|
||||
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
|
||||
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
|
||||
|
||||
Reference in New Issue
Block a user