diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 200d038f62..42d957346f 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -135,6 +135,19 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o clientCtx = clientCtx.WithInput(inBuf).WithFromAddress(key.GetAddress()) + // The following line comes from a discrepancy between the `gentx` + // and `create-validator` commands: + // - `gentx` expects amount as an arg, + // - `create-validator` expects amount as a required flag. + // ref: https://github.com/cosmos/cosmos-sdk/issues/8251 + // Since gentx doesn't set the amount flag (which `create-validator` + // reads from), we copy the amount arg into the valCfg directly. + // + // Ideally, the `create-validator` command should take a validator + // config file instead of so many flags. + // ref: https://github.com/cosmos/cosmos-sdk/issues/8177 + createValCfg.Amount = amount + // create a 'create-validator' message txBldr, msg, err := cli.BuildCreateValidatorMsg(clientCtx, createValCfg, txFactory, true) if err != nil { diff --git a/x/genutil/client/cli/gentx_test.go b/x/genutil/client/cli/gentx_test.go index bbea1818dd..d15ee88962 100644 --- a/x/genutil/client/cli/gentx_test.go +++ b/x/genutil/client/cli/gentx_test.go @@ -60,12 +60,13 @@ func (s *IntegrationTestSuite) TestGenTxCmd() { ctx := context.Background() ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) + amount := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(12)) genTxFile := filepath.Join(dir, "myTx") cmd.SetArgs([]string{ fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile), val.Moniker, - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), + amount.String(), }) err := cmd.ExecuteContext(ctx) @@ -86,6 +87,7 @@ func (s *IntegrationTestSuite) TestGenTxCmd() { s.Require().Equal(types.TypeMsgCreateValidator, msgs[0].Type()) s.Require().Equal([]sdk.AccAddress{val.Address}, msgs[0].GetSigners()) + s.Require().Equal(amount, msgs[0].(*types.MsgCreateValidator).Value) err = tx.ValidateBasic() s.Require().NoError(err) }