github.com/palcoin-project/palcd@v1.0.0/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  	"github.com/palcoin-project/palcutil"
    11  )
    12  
    13  // TestMerkle tests the BuildMerkleTreeStore API.
    14  func TestMerkle(t *testing.T) {
    15  	block := palcutil.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  }