mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
0544dd1f8e
* cmd tests * deposit util tests * feature config tests * hashutil tests * htr util tests * interop tests * ip util tests
28 lines
623 B
Go
28 lines
623 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))
|
|
}
|