cosmos-sdk/store/v2/root/factory_test.go
Alexander Peters 9a92843c21
store/v2: remove auto migration and fix restore cmd (#23568)
Co-authored-by: mmsqe <mavis@crypto.com>
Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2025-01-31 17:34:44 +00:00

46 lines
1009 B
Go

package root
import (
"testing"
gogotypes "github.com/cosmos/gogoproto/types"
"github.com/stretchr/testify/require"
corestore "cosmossdk.io/core/store"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/store/v2/db"
)
func TestFactory(t *testing.T) {
fop := FactoryOptions{
Logger: coretesting.NewNopLogger(),
RootDir: t.TempDir(),
Options: DefaultStoreOptions(),
StoreKeys: storeKeys,
SCRawDB: db.NewMemDB(),
}
f, err := CreateRootStore(&fop)
require.NoError(t, err)
require.NotNil(t, f)
fop.Options.SCType = SCTypeIavlV2
f, err = CreateRootStore(&fop)
require.NoError(t, err)
require.NotNil(t, f)
require.NoError(t, setLatestVersion(fop.SCRawDB, 1))
fop.Options.SCType = SCTypeIavl
f, err = CreateRootStore(&fop)
require.NoError(t, err)
require.NotNil(t, f)
}
func setLatestVersion(db corestore.KVStoreWithBatch, version int64) error {
bz, err := gogotypes.StdInt64Marshal(version)
if err != nil {
panic(err)
}
return db.Set([]byte("s/latest"), bz)
}