mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-04 13:16:43 +00:00

* [DEV-98] Move script flags from relay rules to consensus * [DEV-98] remove flags from script_tests.json * [DEV-98] fix multisig and remove test that assume no minimal data rule * [DEV-98] rename bip16 bool to isP2sh * [DEV-98] add sighash type to overly long signature in script_tests.json * [DEV-98] add test for NUMEQUAL for non equal numbers script_tests.json * [DEV-98] remove debugging if * [DEV-98] remove ErrCleanStack from EVAL_FALSE * [DEV-98] change isP2sh to isP2SH to comply with Go style * [DEV-98] add ScriptNoFlags to explictly indicate for empty ScriptFlags * [DEV-98] rename ErrPubKeyType -> ErrPubKeyFormat * [DEV-98] rename PUBKEYTYPE -> PUBKEYFORMAT
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// Copyright (c) 2013-2017 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package blockdag
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/daglabs/btcd/txscript"
|
|
)
|
|
|
|
// TestCheckBlockScripts ensures that validating the all of the scripts in a
|
|
// known-good block doesn't return an error.
|
|
func TestCheckBlockScripts(t *testing.T) {
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
testBlockNum := 277647
|
|
blockDataFile := fmt.Sprintf("%d.dat", testBlockNum)
|
|
blocks, err := loadBlocks(blockDataFile)
|
|
if err != nil {
|
|
t.Errorf("Error loading file: %v\n", err)
|
|
return
|
|
}
|
|
if len(blocks) > 1 {
|
|
t.Errorf("The test block file must only have one block in it")
|
|
return
|
|
}
|
|
if len(blocks) == 0 {
|
|
t.Errorf("The test block file may not be empty")
|
|
return
|
|
}
|
|
|
|
storeDataFile := fmt.Sprintf("%d.utxostore", testBlockNum)
|
|
view, err := loadUtxoView(storeDataFile)
|
|
if err != nil {
|
|
t.Errorf("Error loading txstore: %v\n", err)
|
|
return
|
|
}
|
|
|
|
scriptFlags := txscript.ScriptNoFlags
|
|
err = checkBlockScripts(blocks[0], view, scriptFlags, nil)
|
|
if err != nil {
|
|
t.Errorf("Transaction script validation failed: %v\n", err)
|
|
return
|
|
}
|
|
}
|