mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-01 11:46:43 +00:00

* [DEV-329] Add TxID * [DEV-329] Change Transaction inputs to reference by tx id instead of tx hash * [DEV-329] Fix tests * [DEV-329] change txhash to txid in mempool * [DEV-334] Make IDMerkleRoot * [DEV-329] Add txid that excludes payload, gas and ScriptSigs (#158) * [DEV-329] Add TxID * [DEV-329] Change Transaction inputs to reference by tx id instead of tx hash * [DEV-329] Fix tests * [DEV-329] change txhash to txid in mempool * [DEV-329] replace thinEncoding bool with txEncoding bitmask * [DEV-329] Change txencoding var names * [DEV-329] change txEncodingexcludeSignatureScript -> txEncodingExcludeSignatureScript * [DEV-334] Add IDMerkleRoot to blocknode and recalculate IDMerkleRoot when extraNonce is changed * [DEV-334] Fix tests * [DEV-334] Fix tests * [DEV-334] fix SubnetworkDAGCoin -> SubnetworkIDNative * [DEV-334] Add ID() function to Coin interface and rename hash to txID in a few places * [DEV-334] Add Root method for merkle root * [DEV-334] add comment to dag.SubnetworkID() * [DEV-334] fix serializeSize comment
55 lines
1.3 KiB
Go
55 lines
1.3 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) {
|
|
t.Skip() // TODO: Reactivate this test once we have blocks from testnet.
|
|
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)
|
|
utxoSet, err := loadUTXOSet(storeDataFile)
|
|
if err != nil {
|
|
t.Errorf("Error loading txstore: %v\n", err)
|
|
return
|
|
}
|
|
|
|
node := &blockNode{
|
|
hash: *blocks[0].Hash(),
|
|
}
|
|
|
|
scriptFlags := txscript.ScriptNoFlags
|
|
err = checkBlockScripts(node, utxoSet, blocks[0].Transactions(), scriptFlags, nil)
|
|
if err != nil {
|
|
t.Errorf("Transaction script validation failed: %v\n", err)
|
|
return
|
|
}
|
|
}
|