1// Copyright (c) 2013-2017 The btcsuite developers 2// Use of this source code is governed by an ISC 3// license that can be found in the LICENSE file. 4 5package blockchain 6 7import ( 8 "testing" 9 10 "github.com/btcsuite/btcutil" 11) 12 13// TestMerkle tests the BuildMerkleTreeStore API. 14func TestMerkle(t *testing.T) { 15 block := btcutil.NewBlock(&Block100000) 16 merkles := BuildMerkleTreeStore(block.Transactions(), false) 17 calculatedMerkleRoot := merkles[len(merkles)-1] 18 wantMerkle := &Block100000.Header.MerkleRoot 19 if !wantMerkle.IsEqual(calculatedMerkleRoot) { 20 t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+ 21 "got %v, want %v", calculatedMerkleRoot, wantMerkle) 22 } 23} 24