2017-08-20 02:21:36 +02:00
|
|
|
// Copyright (c) 2013-2017 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.
|
|
|
|
|
2017-08-20 02:21:36 +02:00
|
|
|
package blockchain
|
2013-07-18 16:49:28 +02:00
|
|
|
|
|
|
|
import (
|
2014-07-02 18:04:59 +02:00
|
|
|
"testing"
|
2013-07-18 16:49:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestMerkle tests the BuildMerkleTreeStore API.
|
|
|
|
func TestMerkle(t *testing.T) {
|
2021-08-19 20:41:48 +02:00
|
|
|
block := GetBlock100000()
|
2017-08-20 02:21:36 +02:00
|
|
|
merkles := BuildMerkleTreeStore(block.Transactions(), false)
|
2013-07-18 16:49:28 +02:00
|
|
|
calculatedMerkleRoot := merkles[len(merkles)-1]
|
2021-08-19 20:41:48 +02:00
|
|
|
wantMerkle := block.MsgBlock().Header.MerkleRoot
|
2013-07-18 16:49:28 +02:00
|
|
|
if !wantMerkle.IsEqual(calculatedMerkleRoot) {
|
|
|
|
t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+
|
|
|
|
"got %v, want %v", calculatedMerkleRoot, wantMerkle)
|
|
|
|
}
|
|
|
|
}
|