chore: Add log messages for InitGenesis (#9675)
* Add log messages for InitGenesis * Update types/module/module.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update types/module/module.go * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Try fixing sdk.Context{} initialization * Fix import Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
parent
c04ab50fd0
commit
260c5728ab
|
@ -298,10 +298,12 @@ func (m *Manager) RegisterServices(cfg Configurator) {
|
||||||
// InitGenesis performs init genesis functionality for modules
|
// InitGenesis performs init genesis functionality for modules
|
||||||
func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage) abci.ResponseInitChain {
|
func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage) abci.ResponseInitChain {
|
||||||
var validatorUpdates []abci.ValidatorUpdate
|
var validatorUpdates []abci.ValidatorUpdate
|
||||||
|
ctx.Logger().Info("initializing blockchain state from genesis.json")
|
||||||
for _, moduleName := range m.OrderInitGenesis {
|
for _, moduleName := range m.OrderInitGenesis {
|
||||||
if genesisData[moduleName] == nil {
|
if genesisData[moduleName] == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
ctx.Logger().Debug("running initialization for module", "module", moduleName)
|
||||||
|
|
||||||
moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName])
|
moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName])
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
@ -200,7 +202,7 @@ func TestManager_InitGenesis(t *testing.T) {
|
||||||
require.NotNil(t, mm)
|
require.NotNil(t, mm)
|
||||||
require.Equal(t, 2, len(mm.Modules))
|
require.Equal(t, 2, len(mm.Modules))
|
||||||
|
|
||||||
ctx := sdk.Context{}
|
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
|
||||||
interfaceRegistry := types.NewInterfaceRegistry()
|
interfaceRegistry := types.NewInterfaceRegistry()
|
||||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||||
genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)}
|
genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)}
|
||||||
|
|
Loading…
Reference in New Issue