test(systemtests): fix export v2 (#22799)
This commit is contained in:
parent
ecd53f8497
commit
34f407d636
@ -78,9 +78,7 @@ func (s *Server[T]) Config() any {
|
||||
// An empty home directory *is* permitted at this stage, but attempting to build
|
||||
// the store with an empty home directory will fail.
|
||||
func UnmarshalConfig(cfg map[string]any) (*root.Config, error) {
|
||||
config := &root.Config{
|
||||
Options: root.DefaultStoreOptions(),
|
||||
}
|
||||
config := root.DefaultConfig()
|
||||
if err := serverv2.UnmarshalSubConfig(cfg, ServerName, config); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal store config: %w", err)
|
||||
}
|
||||
|
||||
@ -153,13 +153,13 @@ func TestSimAppExportAndBlockedAddrs_WithOneBlockProduced(t *testing.T) {
|
||||
|
||||
MoveNextBlock(t, app, ctx)
|
||||
|
||||
_, err := app.ExportAppStateAndValidators(nil)
|
||||
_, err := app.ExportAppStateAndValidators(false, nil)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSimAppExportAndBlockedAddrs_NoBlocksProduced(t *testing.T) {
|
||||
app, _ := NewTestApp(t)
|
||||
|
||||
_, err := app.ExportAppStateAndValidators(nil)
|
||||
_, err := app.ExportAppStateAndValidators(false, nil)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -13,7 +13,9 @@ import (
|
||||
// file.
|
||||
// This is a demonstation of how to export a genesis file. Export may need extended at
|
||||
// the user discretion for cleaning the genesis state at the end provided with jailAllowedAddrs
|
||||
// Same applies for forZeroHeight preprocessing.
|
||||
func (app *SimApp[T]) ExportAppStateAndValidators(
|
||||
forZeroHeight bool,
|
||||
jailAllowedAddrs []string,
|
||||
) (v2.ExportedApp, error) {
|
||||
ctx := context.Background()
|
||||
@ -44,5 +46,9 @@ func (app *SimApp[T]) ExportAppStateAndValidators(
|
||||
|
||||
exportedApp.AppState = genesis
|
||||
exportedApp.Height = int64(latestHeight)
|
||||
if forZeroHeight {
|
||||
exportedApp.Height = 0
|
||||
}
|
||||
|
||||
return exportedApp, nil
|
||||
}
|
||||
|
||||
@ -3,10 +3,11 @@ package db_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/store/db"
|
||||
"cosmossdk.io/store/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/mock/gomock"
|
||||
|
||||
"cosmossdk.io/store/db"
|
||||
"cosmossdk.io/store/mock"
|
||||
)
|
||||
|
||||
func TestPrefixDB(t *testing.T) {
|
||||
|
||||
@ -55,6 +55,11 @@ func (sb *builder) Build(
|
||||
if config.Home == "" {
|
||||
return nil, fmt.Errorf("home directory is required")
|
||||
}
|
||||
|
||||
if len(config.AppDBBackend) == 0 {
|
||||
return nil, fmt.Errorf("application db backend is required")
|
||||
}
|
||||
|
||||
scRawDb, err := db.NewDB(
|
||||
db.DBType(config.AppDBBackend),
|
||||
"application",
|
||||
|
||||
@ -156,5 +156,4 @@ func (s *fixture) registerMsgRouterService(router *integration.RouterService) {
|
||||
|
||||
func (s *fixture) registerQueryRouterService(router *integration.RouterService) {
|
||||
// register custom router service
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ go 1.23
|
||||
|
||||
require (
|
||||
cosmossdk.io/math v1.4.0
|
||||
cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4
|
||||
cosmossdk.io/systemtests v1.0.0-rc.3
|
||||
github.com/cosmos/cosmos-sdk v0.50.6
|
||||
)
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@ cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
|
||||
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
|
||||
cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk=
|
||||
cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng=
|
||||
cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4 h1:gt0rrxBW4x9KM3+ES8Gy5BZbKIHI3AspYEuvWZO6fgU=
|
||||
cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4/go.mod h1:B3RY1tY/iwLjQ9MUTz+GsiXV9gEdS8mfUvSQtWUwaAo=
|
||||
cosmossdk.io/systemtests v1.0.0-rc.3 h1:W1ZdfHtWxbzRCiBwcMb1nMKkmUNyAcHapJOrfh1lX20=
|
||||
cosmossdk.io/systemtests v1.0.0-rc.3/go.mod h1:B3RY1tY/iwLjQ9MUTz+GsiXV9gEdS8mfUvSQtWUwaAo=
|
||||
cosmossdk.io/x/tx v0.13.3-0.20240419091757-db5906b1e894 h1:kHEvzVqpNv/9pnaEPBsgE/FMc+cVmWjSsInRufkZkpQ=
|
||||
cosmossdk.io/x/tx v0.13.3-0.20240419091757-db5906b1e894/go.mod h1:Tb6/tpONmtL5qFdOMdv1pdvrtJNxcazZBoz04HB71ss=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
|
||||
@ -20,7 +20,7 @@ type genesisMM interface {
|
||||
}
|
||||
|
||||
type ExportableApp interface {
|
||||
ExportAppStateAndValidators([]string) (v2.ExportedApp, error)
|
||||
ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string) (v2.ExportedApp, error)
|
||||
LoadHeight(uint64) error
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
|
||||
const (
|
||||
flagHeight = "height"
|
||||
flagForZeroHeight = "for-zero-height"
|
||||
flagJailAllowedAddrs = "jail-allowed-addrs"
|
||||
)
|
||||
|
||||
@ -56,6 +57,7 @@ func ExportCmd(app ExportableApp) *cobra.Command {
|
||||
}
|
||||
|
||||
height, _ := cmd.Flags().GetInt64(flagHeight)
|
||||
forZeroHeight, _ := cmd.Flags().GetBool(flagForZeroHeight)
|
||||
jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs)
|
||||
outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
|
||||
if height != -1 {
|
||||
@ -63,7 +65,7 @@ func ExportCmd(app ExportableApp) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
}
|
||||
exported, err := app.ExportAppStateAndValidators(jailAllowedAddrs)
|
||||
exported, err := app.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error exporting state: %w", err)
|
||||
}
|
||||
@ -105,6 +107,7 @@ func ExportCmd(app ExportableApp) *cobra.Command {
|
||||
StringSlice(flagJailAllowedAddrs, []string{}, "Comma-separated list of operator addresses of jailed validators to unjail")
|
||||
cmd.Flags().
|
||||
String(flags.FlagOutputDocument, "", "Exported state is written to the given file instead of STDOUT")
|
||||
cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preproccessing)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user