From 06f769ef72e6042e7f2b5ff1c512ef1371d615e5 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 13 Mar 2019 01:11:08 -0500 Subject: [PATCH] txscript: Convert sighash calc tests. This converts the tests for calculating signature hashes to use the exported function which handles the raw script versus the now deprecated variant requiring parsed opcodes. --- txscript/reference_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/txscript/reference_test.go b/txscript/reference_test.go index d432172479..dfad701482 100644 --- a/txscript/reference_test.go +++ b/txscript/reference_test.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2017 The btcsuite developers -// Copyright (c) 2015-2018 The Decred developers +// Copyright (c) 2015-2019 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -828,6 +828,7 @@ func TestCalcSignatureHashReference(t *testing.T) { t.Fatalf("TestCalcSignatureHash couldn't Unmarshal: %v\n", err) } + const scriptVersion = 0 for i, test := range tests { // Skip comment lines. if len(test) == 1 { @@ -869,7 +870,7 @@ func TestCalcSignatureHashReference(t *testing.T) { err) continue } - parsedScript, err := parseScript(subScript) + err = checkScriptParses(scriptVersion, subScript) if err != nil { t.Errorf("Test #%d: unable to parse script: %v", i, err) continue @@ -915,7 +916,7 @@ func TestCalcSignatureHashReference(t *testing.T) { } // Calculate the signature hash and verify expected result. - hash, err := calcSignatureHash(parsedScript, hashType, &tx, + hash, err := CalcSignatureHash(subScript, hashType, &tx, int(inputIdxF64), nil) if (err == nil) != (expectedErr == nil) || expectedErr != nil && !IsErrorCode(err, *expectedErr) {