2015-05-01 08:28:01 +02:00
|
|
|
// Copyright (c) 2013-2014 The btcsuite developers
|
2013-07-18 16:49:28 +02:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-01-30 21:54:30 +01:00
|
|
|
package blockchain_test
|
2013-07-18 16:49:28 +02:00
|
|
|
|
|
|
|
import (
|
2014-07-02 18:04:59 +02:00
|
|
|
"testing"
|
|
|
|
|
2015-01-30 21:54:30 +01:00
|
|
|
"github.com/btcsuite/btcd/blockchain"
|
2015-01-15 17:23:47 +01:00
|
|
|
"github.com/btcsuite/btcutil"
|
2013-07-18 16:49:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestMerkle tests the BuildMerkleTreeStore API.
|
|
|
|
func TestMerkle(t *testing.T) {
|
2013-08-05 22:20:35 +02:00
|
|
|
block := btcutil.NewBlock(&Block100000)
|
2016-10-19 03:24:38 +02:00
|
|
|
merkles := blockchain.BuildMerkleTreeStore(block.Transactions(), false)
|
2013-07-18 16:49:28 +02:00
|
|
|
calculatedMerkleRoot := merkles[len(merkles)-1]
|
|
|
|
wantMerkle := &Block100000.Header.MerkleRoot
|
|
|
|
if !wantMerkle.IsEqual(calculatedMerkleRoot) {
|
|
|
|
t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+
|
|
|
|
"got %v, want %v", calculatedMerkleRoot, wantMerkle)
|
|
|
|
}
|
|
|
|
}
|