Skip to content

Commit

Permalink
chore: Add log messages for InitGenesis (cosmos#9675)
Browse files Browse the repository at this point in the history
* Add log messages for InitGenesis

* Update types/module/module.go

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* Update types/module/module.go

* Apply suggestions from code review

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* Try fixing sdk.Context{} initialization

* Fix import

Co-authored-by: Aleksandr Bezobchuk <[email protected]>
  • Loading branch information
ValarDragon and alexanderbez authored Aug 12, 2021
1 parent c04ab50 commit 260c572
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,12 @@ func (m *Manager) RegisterServices(cfg Configurator) {
// InitGenesis performs init genesis functionality for modules
func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage) abci.ResponseInitChain {
var validatorUpdates []abci.ValidatorUpdate
ctx.Logger().Info("initializing blockchain state from genesis.json")
for _, moduleName := range m.OrderInitGenesis {
if genesisData[moduleName] == nil {
continue
}
ctx.Logger().Debug("running initialization for module", "module", moduleName)

moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, genesisData[moduleName])

Expand Down
4 changes: 3 additions & 1 deletion types/module/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
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/codec"
Expand Down Expand Up @@ -200,7 +202,7 @@ func TestManager_InitGenesis(t *testing.T) {
require.NotNil(t, mm)
require.Equal(t, 2, len(mm.Modules))

ctx := sdk.Context{}
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
interfaceRegistry := types.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)}
Expand Down

0 comments on commit 260c572

Please sign in to comment.