Skip to content

Commit 9490a94

Browse files
committed
fix test
1 parent e0b60eb commit 9490a94

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

x/genutil/client/cli/validate_genesis.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command {
4848
}
4949

5050
var genState map[string]json.RawMessage
51-
if err = json.Unmarshal(appGenesis.AppState, &genState); err != nil {
51+
if err := json.Unmarshal(appGenesis.AppState, &genState); err != nil {
5252
if strings.Contains(err.Error(), "unexpected end of JSON input") {
5353
return fmt.Errorf("app_state is missing in the genesis file: %s", err.Error())
5454
}
55-
56-
return fmt.Errorf("error unmarshalling genesis doc %s: %s", genesis, err.Error())
55+
return fmt.Errorf("error unmarshalling genesis doc %s: %w", genesis, err)
5756
}
5857

5958
if err = mbm.ValidateGenesis(cdc, clientCtx.TxConfig, genState); err != nil {

x/genutil/client/cli/validate_genesis_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cli_test
22

33
import (
44
"encoding/json"
5+
"fmt"
6+
"io"
57
"os"
68
"testing"
79

@@ -92,18 +94,20 @@ func TestValidateGenesis(t *testing.T) {
9294
}
9395
}
9496

97+
var _ module.HasGenesisBasics = mockModule{}
98+
9599
type mockModule struct {
96100
module.AppModuleBasic
97101
}
98102

99-
func (mockModule) Name() string {
103+
func (m mockModule) Name() string {
100104
return "mock"
101105
}
102106

103-
func (mockModule) DefaultGenesis(codec.JSONCodec) json.RawMessage {
107+
func (m mockModule) DefaultGenesis(codec.JSONCodec) json.RawMessage {
104108
return json.RawMessage(`{"foo": "bar"}`)
105109
}
106110

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

0 commit comments

Comments
 (0)