Skip to content

Commit f07eaa1

Browse files
committed
fixes
1 parent 4a55e5a commit f07eaa1

3 files changed

Lines changed: 14 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
4545

4646
### Improvements
4747

48-
<<<<<<< HEAD
4948
* (x/bank) [#21460](https://github.com/cosmos/cosmos-sdk/pull/21460) Added `Sender` attribute in `MsgMultiSend` event.
50-
=======
5149
* (genutil) [#21701](https://github.com/cosmos/cosmos-sdk/pull/21701) Improved error messages for genesis validation.
52-
>>>>>>> 9c5cea08c (feat(x/genutil): add better error messages for genesis validation (#21701))
5350

5451
### Bug Fixes
5552

x/genutil/client/cli/validate_genesis.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,19 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command {
4949

5050
var genState map[string]json.RawMessage
5151
if err = json.Unmarshal(appGenesis.AppState, &genState); err != nil {
52-
<<<<<<< HEAD
53-
return fmt.Errorf("error unmarshalling genesis doc %s: %s", genesis, err.Error())
54-
}
55-
56-
if err = mbm.ValidateGenesis(cdc, clientCtx.TxConfig, genState); err != nil {
57-
return fmt.Errorf("error validating genesis file %s: %s", genesis, err.Error())
58-
=======
5952
if strings.Contains(err.Error(), "unexpected end of JSON input") {
6053
return fmt.Errorf("app_state is missing in the genesis file: %s", err.Error())
6154
}
62-
return fmt.Errorf("error unmarshalling genesis doc %s: %w", genesis, err)
55+
56+
return fmt.Errorf("error unmarshalling genesis doc %s: %s", genesis, err.Error())
6357
}
6458

65-
if genMM != nil {
66-
if err = genMM.ValidateGenesis(genState); err != nil {
67-
errStr := fmt.Sprintf("error validating genesis file %s: %s", genesis, err.Error())
68-
if errors.Is(err, io.EOF) {
69-
errStr = fmt.Sprintf("%s: section is missing in the app_state", errStr)
70-
}
71-
return fmt.Errorf("%s", errStr)
59+
if err = mbm.ValidateGenesis(cdc, clientCtx.TxConfig, genState); err != nil {
60+
errStr := fmt.Sprintf("error validating genesis file %s: %s", genesis, err.Error())
61+
if errors.Is(err, io.EOF) {
62+
errStr = fmt.Sprintf("%s: section is missing in the app_state", errStr)
7263
}
73-
>>>>>>> 9c5cea08c (feat(x/genutil): add better error messages for genesis validation (#21701))
64+
return fmt.Errorf("%s", errStr)
7465
}
7566

7667
fmt.Fprintf(cmd.OutOrStdout(), "File at %s is a valid genesis file\n", genesis)

x/genutil/client/cli/validate_genesis_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ import (
66

77
"github.com/stretchr/testify/require"
88

9-
appmodulev2 "cosmossdk.io/core/appmodule/v2"
10-
"cosmossdk.io/x/staking"
11-
129
"github.com/cosmos/cosmos-sdk/client"
13-
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
1410
"github.com/cosmos/cosmos-sdk/testutil"
1511
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
1612
"github.com/cosmos/cosmos-sdk/types/module"
1713
testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
1814
"github.com/cosmos/cosmos-sdk/x/genutil"
1915
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
16+
"github.com/cosmos/cosmos-sdk/x/staking"
2017
)
2118

2219
// An example exported genesis file from a 0.37 chain. Note that evidence
@@ -39,18 +36,18 @@ var v037Exported = `{
3936
}`
4037

4138
func TestValidateGenesis(t *testing.T) {
42-
cdc := testutilmod.MakeTestEncodingConfig(codectestutil.CodecOptions{}, genutil.AppModule{}).Codec
39+
cdc := testutilmod.MakeTestEncodingConfig(genutil.AppModule{}).Codec
4340
testCases := []struct {
4441
name string
4542
genesis string
4643
expErrStr string
47-
genMM *module.Manager
44+
genMM module.BasicManager
4845
}{
4946
{
5047
"invalid json",
5148
`{"app_state": {x,}}`,
5249
"error at offset 16: invalid character",
53-
module.NewManagerFromMap(nil),
50+
module.NewBasicManager(),
5451
},
5552
{
5653
"invalid: missing module config in app_state",
@@ -61,15 +58,13 @@ func TestValidateGenesis(t *testing.T) {
6158
return string(bz)
6259
}(),
6360
"section is missing in the app_state",
64-
module.NewManagerFromMap(map[string]appmodulev2.AppModule{
65-
"custommod": staking.NewAppModule(cdc, nil, nil, nil),
66-
}),
61+
module.NewBasicManager(staking.NewAppModule(cdc, nil, nil, nil, nil)),
6762
},
6863
{
6964
"exported 0.37 genesis file",
7065
v037Exported,
7166
"make sure that you have correctly migrated all CometBFT consensus params",
72-
module.NewManagerFromMap(nil),
67+
module.NewBasicManager(),
7368
},
7469
{
7570
"valid 0.50 genesis file",
@@ -80,7 +75,7 @@ func TestValidateGenesis(t *testing.T) {
8075
return string(bz)
8176
}(),
8277
"",
83-
module.NewManagerFromMap(nil),
78+
module.NewBasicManager(),
8479
},
8580
}
8681

0 commit comments

Comments
 (0)