fix(db): Fix pebbleDB integration (#23552)
This commit is contained in:
parent
e2027bf628
commit
576448b821
@ -135,10 +135,11 @@ func SetupTestInstance[T Tx, V SimulationApp[T]](
|
||||
appFactory AppFactory[T, V],
|
||||
appConfigFactory AppConfigFactory,
|
||||
randSource simsxv2.RandSource,
|
||||
dbBackend string,
|
||||
) TestInstance[T] {
|
||||
tb.Helper()
|
||||
vp := viper.New()
|
||||
vp.Set("store.app-db-backend", "memdb")
|
||||
vp.Set("store.app-db-backend", dbBackend)
|
||||
vp.Set("home", tb.TempDir())
|
||||
|
||||
depInjCfg := depinject.Configs(
|
||||
@ -251,7 +252,7 @@ func RunWithRandSource[T Tx, V SimulationApp[T]](
|
||||
require.NotEmpty(tb, initialBlockHeight, "initial block height must not be 0")
|
||||
|
||||
setupFn := func(ctx context.Context, r *rand.Rand) (TestInstance[T], ChainState[T], []simtypes.Account) {
|
||||
testInstance := SetupTestInstance[T, V](tb, appFactory, appConfigFactory, randSource)
|
||||
testInstance := SetupTestInstance[T, V](tb, appFactory, appConfigFactory, randSource, tCfg.DBBackend)
|
||||
accounts, genesisAppState, chainID, genesisTimestamp := prepareInitialGenesisState(
|
||||
testInstance.App,
|
||||
r,
|
||||
|
||||
@ -96,7 +96,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
|
||||
chainID := SimAppChainID + "_2"
|
||||
|
||||
importGenesisChainStateFactory := func(ctx context.Context, r *rand.Rand) (TestInstance[Tx], ChainState[Tx], []simtypes.Account) {
|
||||
testInstance := SetupTestInstance(tb, appFactory, AppConfig, ti.RandSource)
|
||||
testInstance := SetupTestInstance(tb, appFactory, AppConfig, ti.RandSource, cfg.DBBackend)
|
||||
newCs := testInstance.InitializeChain(
|
||||
tb,
|
||||
ctx,
|
||||
@ -136,7 +136,7 @@ func TestAppImportExport(t *testing.T) {
|
||||
chainID := SimAppChainID
|
||||
tb.Log("importing genesis...\n")
|
||||
|
||||
newTestInstance := SetupTestInstance(tb, appFactory, AppConfig, ti.RandSource)
|
||||
newTestInstance := SetupTestInstance(tb, appFactory, AppConfig, ti.RandSource, cfg.DBBackend)
|
||||
newTestInstance.InitializeChain(
|
||||
tb,
|
||||
context.Background(),
|
||||
|
||||
@ -29,6 +29,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
* [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Support memDB for sims
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#23552](https://github.com/cosmos/cosmos-sdk/pull/23552) Fix pebbleDB integration
|
||||
|
||||
## [v2.0.0-beta.2](https://github.com/cosmos/cosmos-sdk/releases/tag/store/v2.0.0-beta.2)
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ func (db *PebbleDB) Get(key []byte) ([]byte, error) {
|
||||
return nil, fmt.Errorf("failed to perform PebbleDB read: %w", err)
|
||||
}
|
||||
|
||||
return bz, closer.Close()
|
||||
return slices.Clone(bz), closer.Close()
|
||||
}
|
||||
|
||||
func (db *PebbleDB) Has(key []byte) (bool, error) {
|
||||
|
||||
@ -46,7 +46,7 @@ func GetSimulatorFlags() {
|
||||
flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block")
|
||||
flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output")
|
||||
flag.BoolVar(&FlagCommitValue, "Commit", true, "have the simulation commit")
|
||||
flag.StringVar(&FlagDBBackendValue, "DBBackend", "goleveldb", "custom db backend type: goleveldb, memdb")
|
||||
flag.StringVar(&FlagDBBackendValue, "DBBackend", "memdb", "custom db backend type: goleveldb, pebbledb, memdb")
|
||||
|
||||
// simulation flags
|
||||
flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user