github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/blockchain/scriptval_test.go (about) 1 // Copyright (c) 2013-2016 The btcsuite developers 2 // Copyright (c) 2016 The Dash developers 3 // Use of this source code is governed by an ISC 4 // license that can be found in the LICENSE file. 5 6 package blockchain_test 7 8 import ( 9 "fmt" 10 "runtime" 11 "testing" 12 13 "github.com/BlockABC/godash/blockchain" 14 "github.com/BlockABC/godash/txscript" 15 ) 16 17 // TestCheckBlockScripts ensures that validating the all of the scripts in a 18 // known-good block doesn't return an error. 19 func TestCheckBlockScripts(t *testing.T) { 20 runtime.GOMAXPROCS(runtime.NumCPU()) 21 22 testBlockNum := 277647 23 blockDataFile := fmt.Sprintf("%d.dat.bz2", testBlockNum) 24 blocks, err := loadBlocks(blockDataFile) 25 if err != nil { 26 t.Errorf("Error loading file: %v\n", err) 27 return 28 } 29 if len(blocks) > 1 { 30 t.Errorf("The test block file must only have one block in it") 31 } 32 33 storeDataFile := fmt.Sprintf("%d.utxostore.bz2", testBlockNum) 34 view, err := loadUtxoView(storeDataFile) 35 if err != nil { 36 t.Errorf("Error loading txstore: %v\n", err) 37 return 38 } 39 40 scriptFlags := txscript.ScriptBip16 41 err = blockchain.TstCheckBlockScripts(blocks[0], view, scriptFlags, 42 nil) 43 if err != nil { 44 t.Errorf("Transaction script validation failed: %v\n", err) 45 return 46 } 47 }