Fix sequence value in auth sign signature only (#8287)
* fix signature only * add test, changelog * update test * Update CHANGELOG.md * address suggestions Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
4fa9e98095
commit
9d67526dd7
|
@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (x/auth) [\#8287](https://github.com/cosmos/cosmos-sdk/pull/8287) Fix `tx sign --signature-only` to return correct sequence value in signature.
|
||||
|
||||
## [v0.40.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.40.0) - 2021-01-08
|
||||
|
||||
v0.40.0, known as the Stargate release of the Cosmos SDK, is one of the largest releases
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
|
@ -145,11 +144,21 @@ func (s *IntegrationTestSuite) TestCLISign() {
|
|||
valInfo, err := val1.ClientCtx.Keyring.Key(val1.Moniker)
|
||||
require.NoError(err)
|
||||
|
||||
// query account info
|
||||
queryResJSON, err := authtest.QueryAccountExec(val1.ClientCtx, val1.Address)
|
||||
require.NoError(err)
|
||||
var account authtypes.AccountI
|
||||
require.NoError(val1.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
||||
|
||||
/**** test signature-only ****/
|
||||
res, err := authtest.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag,
|
||||
sigOnlyFlag)
|
||||
require.NoError(err)
|
||||
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey())
|
||||
sigs, err := txCfg.UnmarshalSignatureJSON(res.Bytes())
|
||||
require.NoError(err)
|
||||
require.Equal(1, len(sigs))
|
||||
require.Equal(account.GetSequence(), sigs[0].Sequence)
|
||||
|
||||
/**** test full output ****/
|
||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag)
|
||||
|
@ -814,19 +823,17 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() {
|
|||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
address sdk.AccAddress
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
"invalid address",
|
||||
[]string{addr1.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
addr1,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid address",
|
||||
[]string{val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
val.Address,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
@ -834,18 +841,15 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() {
|
|||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
s.Run(tc.name, func() {
|
||||
cmd := authcli.GetAccountCmd()
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
out, err := authtest.QueryAccountExec(clientCtx, tc.address)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().NotEqual("internal", err.Error())
|
||||
} else {
|
||||
var any types.Any
|
||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &any))
|
||||
var acc authtypes.AccountI
|
||||
s.Require().NoError(val.ClientCtx.InterfaceRegistry.UnpackAny(&any, &acc))
|
||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(out.Bytes(), &acc))
|
||||
s.Require().Equal(val.Address, acc.GetAddress())
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,12 +23,10 @@ func TxSignExec(clientCtx client.Context, from fmt.Stringer, filename string, ex
|
|||
filename,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
cmd := cli.GetSignCommand()
|
||||
tmcli.PrepareBaseCmd(cmd, "", "")
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cmd, append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxBroadcastExec(clientCtx client.Context, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
|
@ -36,9 +34,7 @@ func TxBroadcastExec(clientCtx client.Context, filename string, extraArgs ...str
|
|||
filename,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetBroadcastCommand(), args)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetBroadcastCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxEncodeExec(clientCtx client.Context, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
|
@ -47,9 +43,7 @@ func TxEncodeExec(clientCtx client.Context, filename string, extraArgs ...string
|
|||
filename,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetEncodeCommand(), args)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetEncodeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxValidateSignaturesExec(clientCtx client.Context, filename string) (testutil.BufferWriter, error) {
|
||||
|
@ -70,9 +64,7 @@ func TxMultiSignExec(clientCtx client.Context, from string, filename string, ext
|
|||
from,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignCommand(), args)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxSignBatchExec(clientCtx client.Context, from fmt.Stringer, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
|
@ -82,9 +74,7 @@ func TxSignBatchExec(clientCtx client.Context, from fmt.Stringer, filename strin
|
|||
filename,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetSignBatchCommand(), args)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetSignBatchCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxDecodeExec(clientCtx client.Context, encodedTx string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
|
@ -93,9 +83,13 @@ func TxDecodeExec(clientCtx client.Context, encodedTx string, extraArgs ...strin
|
|||
encodedTx,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetDecodeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetDecodeCommand(), args)
|
||||
func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
// DONTCOVER
|
||||
|
|
|
@ -118,6 +118,7 @@ func (g config) MarshalSignatureJSON(sigs []signing.SignatureV2) ([]byte, error)
|
|||
descs[i] = &signing.SignatureDescriptor{
|
||||
PublicKey: any,
|
||||
Data: descData,
|
||||
Sequence: sig.Sequence,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue