Fix gentx command setting wrong amount (#8255)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
8fd051b76e
commit
46b697ca23
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue