Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Sep 13, 2024
1 parent e0b60eb commit 9490a94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions x/genutil/client/cli/validate_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command {
}

var genState map[string]json.RawMessage
if err = json.Unmarshal(appGenesis.AppState, &genState); err != nil {
if err := json.Unmarshal(appGenesis.AppState, &genState); err != nil {
if strings.Contains(err.Error(), "unexpected end of JSON input") {
return fmt.Errorf("app_state is missing in the genesis file: %s", err.Error())
}

return fmt.Errorf("error unmarshalling genesis doc %s: %s", genesis, err.Error())
return fmt.Errorf("error unmarshalling genesis doc %s: %w", genesis, err)
}

if err = mbm.ValidateGenesis(cdc, clientCtx.TxConfig, genState); err != nil {
Expand Down
12 changes: 8 additions & 4 deletions x/genutil/client/cli/validate_genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cli_test

import (
"encoding/json"
"fmt"
"io"
"os"
"testing"

Expand Down Expand Up @@ -92,18 +94,20 @@ func TestValidateGenesis(t *testing.T) {
}
}

var _ module.HasGenesisBasics = mockModule{}

type mockModule struct {
module.AppModuleBasic
}

func (mockModule) Name() string {
func (m mockModule) Name() string {
return "mock"
}

func (mockModule) DefaultGenesis(codec.JSONCodec) json.RawMessage {
func (m mockModule) DefaultGenesis(codec.JSONCodec) json.RawMessage {
return json.RawMessage(`{"foo": "bar"}`)
}

func (mockModule) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error {
return nil
func (m mockModule) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error {
return fmt.Errorf("mock section is missing: %w", io.EOF)
}

0 comments on commit 9490a94

Please sign in to comment.