2021-11-29 16:30:17 +00:00
|
|
|
package stateutil
|
2021-11-17 09:04:49 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestArraysTreeRoot_OnlyPowerOf2(t *testing.T) {
|
2022-02-22 09:27:51 +00:00
|
|
|
_, err := arraysRoot([][]byte{}, 1)
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2022-02-22 09:27:51 +00:00
|
|
|
_, err = arraysRoot([][]byte{}, 4)
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2022-02-22 09:27:51 +00:00
|
|
|
_, err = arraysRoot([][]byte{}, 8)
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2022-02-22 09:27:51 +00:00
|
|
|
_, err = arraysRoot([][]byte{}, 10)
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.ErrorContains(t, "hash layer is a non power of 2", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestArraysTreeRoot_ZeroLength(t *testing.T) {
|
2022-02-22 09:27:51 +00:00
|
|
|
_, err := arraysRoot([][]byte{}, 0)
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.ErrorContains(t, "zero leaves provided", err)
|
|
|
|
}
|