From cadebdfc196071c3ec3f75377496b8fef83dbaec Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 13 Aug 2020 18:53:41 +0300 Subject: [PATCH] core: add tests for (*Blockchain).verifyHashAgainstScript --- pkg/core/blockchain_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index bee28a2b2..f7ff28ace 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -335,6 +335,24 @@ func TestVerifyHashAgainstScript(t *testing.T) { require.True(t, errors.Is(err, ErrVerificationFailed)) }) }) + t.Run("NotEnoughGas", func(t *testing.T) { + verif := []byte{byte(opcode.PUSH1)} + w := &transaction.Witness{ + InvocationScript: []byte{byte(opcode.NOP)}, + VerificationScript: verif, + } + err := bc.verifyHashAgainstScript(hash.Hash160(verif), w, ic, false, 1) + require.True(t, errors.Is(err, ErrVerificationFailed)) + }) + t.Run("NoResult", func(t *testing.T) { + verif := []byte{byte(opcode.DROP)} + w := &transaction.Witness{ + InvocationScript: []byte{byte(opcode.PUSH1)}, + VerificationScript: verif, + } + err := bc.verifyHashAgainstScript(hash.Hash160(verif), w, ic, false, gas) + require.True(t, errors.Is(err, ErrVerificationFailed)) + }) } func TestHasBlock(t *testing.T) {