github.com/lbryio/lbcd@v0.22.119/blockchain/merkle_test.go (about)

     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  
     5  package blockchain
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  // TestMerkle tests the BuildMerkleTreeStore API.
    12  func TestMerkle(t *testing.T) {
    13  	block := GetBlock100000()
    14  	merkles := BuildMerkleTreeStore(block.Transactions(), false)
    15  	calculatedMerkleRoot := merkles[len(merkles)-1]
    16  	wantMerkle := block.MsgBlock().Header.MerkleRoot
    17  	if !wantMerkle.IsEqual(calculatedMerkleRoot) {
    18  		t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+
    19  			"got %v, want %v", calculatedMerkleRoot, wantMerkle)
    20  	}
    21  }