Skip to content

Commit

Permalink
txscript/reference_test: Convert sighash calc test
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.

Backport of 06f769e
  • Loading branch information
cfromknecht committed Feb 5, 2021
1 parent bcbf950 commit 54fda7d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions txscript/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ func TestCalcSignatureHash(t *testing.T) {
err)
}

const scriptVersion = 0
for i, test := range tests {
if i == 0 {
// Skip first line -- contains comments only.
Expand All @@ -855,15 +856,15 @@ func TestCalcSignatureHash(t *testing.T) {
}

subScript, _ := hex.DecodeString(test[1].(string))
parsedScript, err := parseScript(subScript)
err = checkScriptParses(scriptVersion, subScript)
if err != nil {
t.Errorf("TestCalcSignatureHash failed test #%d: "+
"Failed to parse sub-script: %v", i, err)
continue
}

hashType := SigHashType(testVecF64ToUint32(test[3].(float64)))
hash, err := calcSignatureHash(parsedScript, hashType, &tx,
hash, err := CalcSignatureHash(subScript, hashType, &tx,
int(test[2].(float64)))
if err != nil {
t.Errorf("TestCalcSignatureHash failed test #%d: "+
Expand Down

0 comments on commit 54fda7d

Please sign in to comment.