forked from libsv/go-bc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerkletreeparent_test.go
33 lines (22 loc) · 981 Bytes
/
merkletreeparent_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package bc_test
import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/require"
"github.com/libsv/go-bc"
)
func TestGetMerkleTreeParentStr(t *testing.T) {
leftNode := "d6c79a6ef05572f0cb8e9a450c561fc40b0a8a7d48faad95e20d93ddeb08c231"
rightNode := "b1ed931b79056438b990d8981ba46fae97e5574b142445a74a44b978af284f98"
expected := "b0d537b3ee52e472507f453df3d69561720346118a5a8c4d85ca0de73bc792be"
parent, err := bc.MerkleTreeParentStr(leftNode, rightNode)
require.NoError(t, err)
require.Equal(t, expected, parent)
}
func TestGetMerkleTreeParent(t *testing.T) {
leftNode, _ := hex.DecodeString("d6c79a6ef05572f0cb8e9a450c561fc40b0a8a7d48faad95e20d93ddeb08c231")
rightNode, _ := hex.DecodeString("b1ed931b79056438b990d8981ba46fae97e5574b142445a74a44b978af284f98")
expected, _ := hex.DecodeString("b0d537b3ee52e472507f453df3d69561720346118a5a8c4d85ca0de73bc792be")
parent := bc.MerkleTreeParent(leftNode, rightNode)
require.Equal(t, expected, parent)
}