Skip to content

Commit

Permalink
txscript: Convert sighash calc tests.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davecgh committed Mar 26, 2019
1 parent c57dc2d commit 06f769e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions 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.

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 06f769e

Please sign in to comment.