Introduce CodeNoSignatures
This commit is contained in:
parent
1ebe1844d2
commit
11585a4abd
@ -45,6 +45,8 @@ FEATURES
|
||||
* SDK
|
||||
* \#2996 Update the `AccountKeeper` to contain params used in the context of
|
||||
the ante handler.
|
||||
* [\#3179](https://github.com/cosmos/cosmos-sdk/pull/3179) New CodeNoSignatures error code.
|
||||
|
||||
|
||||
* Tendermint
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ const (
|
||||
CodeInsufficientFee CodeType = 14
|
||||
CodeTooManySignatures CodeType = 15
|
||||
CodeGasOverflow CodeType = 16
|
||||
CodeNoSignatures CodeType = 17
|
||||
|
||||
// CodespaceRoot is a codespace for error codes in this file only.
|
||||
// Notice that 0 is an "unset" codespace, which can be overridden with
|
||||
@ -90,6 +91,8 @@ func CodeToDefaultMsg(code CodeType) string {
|
||||
return "insufficient fee"
|
||||
case CodeTooManySignatures:
|
||||
return "maximum numer of signatures exceeded"
|
||||
case CodeNoSignatures:
|
||||
return "no signatures supplied"
|
||||
default:
|
||||
return unknownCodeMsg(code)
|
||||
}
|
||||
@ -145,6 +148,9 @@ func ErrInsufficientFee(msg string) Error {
|
||||
func ErrTooManySignatures(msg string) Error {
|
||||
return newErrorWithRootCodespace(CodeTooManySignatures, msg)
|
||||
}
|
||||
func ErrNoSignatures(msg string) Error {
|
||||
return newErrorWithRootCodespace(CodeNoSignatures, msg)
|
||||
}
|
||||
func ErrGasOverflow(msg string) Error {
|
||||
return newErrorWithRootCodespace(CodeGasOverflow, msg)
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func TestAnteHandlerSigErrors(t *testing.T) {
|
||||
require.Equal(t, expectedSigners, stdTx.GetSigners())
|
||||
|
||||
// Check no signatures fails
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized)
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeNoSignatures)
|
||||
|
||||
// test num sigs dont match GetSigners
|
||||
privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
|
||||
|
||||
@ -50,7 +50,7 @@ func (tx StdTx) ValidateBasic() sdk.Error {
|
||||
return sdk.ErrInsufficientFee(fmt.Sprintf("invalid fee %s amount provided", tx.Fee.Amount))
|
||||
}
|
||||
if len(stdSigs) == 0 {
|
||||
return sdk.ErrUnauthorized("no signers")
|
||||
return sdk.ErrNoSignatures("no signers")
|
||||
}
|
||||
if len(stdSigs) != len(tx.GetSigners()) {
|
||||
return sdk.ErrUnauthorized("wrong number of signers")
|
||||
|
||||
@ -91,7 +91,7 @@ func TestTxValidateBasic(t *testing.T) {
|
||||
|
||||
err = tx.ValidateBasic()
|
||||
require.Error(t, err)
|
||||
require.Equal(t, sdk.CodeUnauthorized, err.Result().Code)
|
||||
require.Equal(t, sdk.CodeNoSignatures, err.Result().Code)
|
||||
|
||||
// require to fail validation when signatures do not match expected signers
|
||||
privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0, 1}, []uint64{0, 0}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user