mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-30 18:56:41 +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
33 lines
1.1 KiB
Go
33 lines
1.1 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 (
|
|
"testing"
|
|
|
|
"github.com/daglabs/btcd/util"
|
|
)
|
|
|
|
// TestMerkle tests the BuildHashMerkleTreeStore API.
|
|
func TestMerkle(t *testing.T) {
|
|
block := util.NewBlock(&Block100000)
|
|
|
|
hashMerkleTree := BuildHashMerkleTreeStore(block.Transactions())
|
|
calculatedHashMerkleRoot := hashMerkleTree.Root()
|
|
wantHashMerkleRoot := &Block100000.Header.HashMerkleRoot
|
|
if !wantHashMerkleRoot.IsEqual(calculatedHashMerkleRoot) {
|
|
t.Errorf("BuildHashMerkleTreeStore: hash merkle root mismatch - "+
|
|
"got %v, want %v", calculatedHashMerkleRoot, wantHashMerkleRoot)
|
|
}
|
|
|
|
idMerkleTree := BuildIDMerkleTreeStore(block.Transactions())
|
|
calculatedIDMerkleRoot := idMerkleTree.Root()
|
|
wantIDMerkleRoot := &Block100000.Header.IDMerkleRoot
|
|
if !wantIDMerkleRoot.IsEqual(calculatedIDMerkleRoot) {
|
|
t.Errorf("BuildIDMerkleTreeStore: ID merkle root mismatch - "+
|
|
"got %v, want %v", calculatedIDMerkleRoot, wantIDMerkleRoot)
|
|
}
|
|
}
|