prysm-pulse/shared/hashutil/merkleRoot_test.go
Radosław Kapka dca93ce641
Unnecessary Slice-to-Slice Conversion analyzer (#7321)
* analyzer with tests
* fix bazel file
* modify analyzer to fix build issues
* add analyzer to tool chain
* remove arrays from inspections
* fix redundant [:] operator
* Merge branch 'master' into use-slice-directly
* Merge branch 'master' into use-slice-directly
* fix another inspection
* add package-level comment
2020-09-23 16:14:34 +00:00

28 lines
611 B
Go

package hashutil_test
import (
"testing"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
func TestMerkleRoot(t *testing.T) {
valueSet := [][]byte{
{'a'},
{'b'},
{'c'},
{'d'},
}
hashedV1 := []byte{'a'}
hashedV2 := []byte{'b'}
hashedV3 := []byte{'c'}
hashedV4 := []byte{'d'}
leftNode := hashutil.Hash(append(hashedV1, hashedV2...))
rightNode := hashutil.Hash(append(hashedV3, hashedV4...))
expectedRoot := hashutil.Hash(append(leftNode[:], rightNode[:]...))
assert.DeepEqual(t, expectedRoot[:], hashutil.MerkleRoot(valueSet))
}