From 2598257628070202aeb0f4ebeedb5a55182333ed Mon Sep 17 00:00:00 2001 From: Tatiana Nesterenko Date: Fri, 11 Aug 2023 23:14:35 +0100 Subject: [PATCH] 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 --- pkg/core/blockchain.go | 8 ++++---- pkg/core/blockchain_neotest_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index bd28047e4..2eb6a7698 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -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) } diff --git a/pkg/core/blockchain_neotest_test.go b/pkg/core/blockchain_neotest_test.go index d636ce2b5..53480424a 100644 --- a/pkg/core/blockchain_neotest_test.go +++ b/pkg/core/blockchain_neotest_test.go @@ -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()