github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/blockchain/merkle_test.go (about)

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