fix(stf): fixes to make init genesis pass (#21088)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
parent
2e0884564f
commit
b05bb2601e
@ -128,8 +128,10 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
|
||||
home := v.GetString(FlagHome)
|
||||
|
||||
storeOpts := rootstore.DefaultStoreOptions()
|
||||
if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil {
|
||||
return nil, fmt.Errorf("failed to store options: %w", err)
|
||||
if s := v.Sub("store.options"); s != nil {
|
||||
if err := s.Unmarshal(&storeOpts); err != nil {
|
||||
return nil, fmt.Errorf("failed to store options: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
scRawDb, err := db.NewDB(db.DBType(v.GetString("store.app-db-backend")), "application", filepath.Join(home, "data"), nil)
|
||||
|
||||
@ -166,7 +166,7 @@ func (m *MM[T]) InitGenesisJSON(
|
||||
case appmodulev2.HasGenesis:
|
||||
m.logger.Debug("running initialization for module", "module", moduleName)
|
||||
if err := module.InitGenesis(ctx, genesisData[moduleName]); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("init module %s: %w", moduleName, err)
|
||||
}
|
||||
case appmodulev2.HasABCIGenesis:
|
||||
m.logger.Debug("running initialization for module", "module", moduleName)
|
||||
|
||||
@ -15,7 +15,7 @@ type AsyncListenerOptions struct {
|
||||
BufferSize int
|
||||
|
||||
// DoneWaitGroup is an optional wait-group that listener goroutines will notify via Add(1) when they are started
|
||||
// and Done() after they are cancelled and completed.
|
||||
// and Done() after they are canceled and completed.
|
||||
DoneWaitGroup *sync.WaitGroup
|
||||
}
|
||||
|
||||
|
||||
@ -119,6 +119,7 @@ func callCollector(i int, onCall func(string, int, Packet)) Listener {
|
||||
}
|
||||
|
||||
func checkExpectedCallOrder(t *testing.T, actual, expected []string) {
|
||||
t.Helper()
|
||||
if len(actual) != len(expected) {
|
||||
t.Fatalf("expected %d calls, got %d", len(expected), len(actual))
|
||||
}
|
||||
|
||||
@ -297,6 +297,7 @@ func TestModuleSchema_LookupType(t *testing.T) {
|
||||
}
|
||||
|
||||
func exampleSchema(t *testing.T) ModuleSchema {
|
||||
t.Helper()
|
||||
return requireModuleSchema(t, []ObjectType{
|
||||
{
|
||||
Name: "object1",
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package stf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"slices"
|
||||
|
||||
"github.com/cosmos/gogoproto/jsonpb"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
@ -55,14 +57,14 @@ func (em *eventManager) EmitNonConsensus(event gogoproto.Message) error {
|
||||
// TypedEventToEvent takes typed event and converts to Event object
|
||||
func TypedEventToEvent(tev gogoproto.Message) (event.Event, error) {
|
||||
evtType := gogoproto.MessageName(tev)
|
||||
evtJSON, err := gogoproto.Marshal(tev)
|
||||
if err != nil {
|
||||
buf := new(bytes.Buffer)
|
||||
jm := &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: nil}
|
||||
if err := jm.Marshal(buf, tev); err != nil {
|
||||
return event.Event{}, err
|
||||
}
|
||||
|
||||
var attrMap map[string]json.RawMessage
|
||||
err = json.Unmarshal(evtJSON, &attrMap)
|
||||
if err != nil {
|
||||
if err := json.Unmarshal(buf.Bytes(), &attrMap); err != nil {
|
||||
return event.Event{}, err
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger
|
||||
}
|
||||
|
||||
storeOpts := root.DefaultStoreOptions()
|
||||
if v != nil {
|
||||
if v != nil && v.Sub("store.options") != nil {
|
||||
if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to store options: %w", err)
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
)
|
||||
|
||||
// DefaultNodeHome default home directories for the application daemon
|
||||
|
||||
Loading…
Reference in New Issue
Block a user