25 lines
749 B
Go
25 lines
749 B
Go
|
// Copyright (c) 2013 Conformal Systems LLC.
|
||
|
// Use of this source code is governed by an ISC
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package btcchain_test
|
||
|
|
||
|
import (
|
||
|
"github.com/conformal/btcchain"
|
||
|
"github.com/conformal/btcutil"
|
||
|
"github.com/conformal/btcwire"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
// TestMerkle tests the BuildMerkleTreeStore API.
|
||
|
func TestMerkle(t *testing.T) {
|
||
|
block := btcutil.NewBlock(&Block100000, btcwire.ProtocolVersion)
|
||
|
merkles := btcchain.BuildMerkleTreeStore(block)
|
||
|
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)
|
||
|
}
|
||
|
}
|