e02fbcf5a1
Putting the test code in the same package makes it easier for forks since they don't have to change the import paths as much and it also gets rid of the need for internal_test.go to bridge. While here, remove the reorganization test since it is much better handled by the full block tests and is no longer needed and do some light cleanup on a few other tests. The full block tests had to remain in the separate test package since it is a circular dependency otherwise. This did require duplicating some of the chain setup code, but given the other benefits this is acceptable.
23 lines
675 B
Go
23 lines
675 B
Go
// Copyright (c) 2013-2017 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package blockchain
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/btcsuite/btcutil"
|
|
)
|
|
|
|
// TestMerkle tests the BuildMerkleTreeStore API.
|
|
func TestMerkle(t *testing.T) {
|
|
block := btcutil.NewBlock(&Block100000)
|
|
merkles := BuildMerkleTreeStore(block.Transactions(), false)
|
|
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)
|
|
}
|
|
}
|