core: rename ErrInvalidVerification and ErrInvalidInvocation

No functional changes, just a refactoring.
Use more specific and meaningful names to be able to use these errors from external packages.

Signed-off-by: Tatiana Nesterenko <tatiana@nspcc.io>
This commit is contained in:
Tatiana Nesterenko 2023-08-11 23:14:35 +01:00
parent 1e6372e6d9
commit 2598257628
2 changed files with 6 additions and 6 deletions

View file

@ -2769,9 +2769,9 @@ var (
ErrWitnessHashMismatch = errors.New("witness hash mismatch")
ErrNativeContractWitness = errors.New("native contract witness must have empty verification script")
ErrVerificationFailed = errors.New("signature check failed")
ErrInvalidInvocation = errors.New("invalid invocation script")
ErrInvalidInvocationScript = errors.New("invalid invocation script")
ErrInvalidSignature = fmt.Errorf("%w: invalid signature", ErrVerificationFailed)
ErrInvalidVerification = errors.New("invalid verification script")
ErrInvalidVerificationScript = errors.New("invalid verification script")
ErrUnknownVerificationContract = errors.New("unknown verification contract")
ErrInvalidVerificationContract = errors.New("verification contract is missing `verify` method")
)
@ -2787,7 +2787,7 @@ func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uin
}
err := vm.IsScriptCorrect(witness.VerificationScript, nil)
if err != nil {
return fmt.Errorf("%w: %v", ErrInvalidVerification, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
return fmt.Errorf("%w: %v", ErrInvalidVerificationScript, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
}
ic.VM.LoadScriptWithHash(witness.VerificationScript, hash, callflag.ReadOnly)
} else {
@ -2812,7 +2812,7 @@ func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uin
if len(witness.InvocationScript) != 0 {
err := vm.IsScriptCorrect(witness.InvocationScript, nil)
if err != nil {
return fmt.Errorf("%w: %v", ErrInvalidInvocation, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
return fmt.Errorf("%w: %v", ErrInvalidInvocationScript, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors
}
ic.VM.LoadScript(witness.InvocationScript)
}

View file

@ -1293,7 +1293,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
InvocationScript: []byte{},
VerificationScript: verif,
})
checkErr(t, core.ErrInvalidVerification, tx)
checkErr(t, core.ErrInvalidVerificationScript, tx)
})
t.Run("InvalidInvocationScript", func(t *testing.T) {
tx := newTestTx(t, h, testScript)
@ -1308,7 +1308,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
InvocationScript: []byte{byte(opcode.JMP), 3, 0xff},
VerificationScript: verif,
})
checkErr(t, core.ErrInvalidInvocation, tx)
checkErr(t, core.ErrInvalidInvocationScript, tx)
})
t.Run("Conflict", func(t *testing.T) {
balance := bc.GetUtilityTokenBalance(h).Int64()