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) {
|
2021-11-29 16:30:17 +00:00
|
|
|
_, err := NocachedHasher.arraysRoot([][]byte{}, 1, "testing")
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2021-11-29 16:30:17 +00:00
|
|
|
_, err = NocachedHasher.arraysRoot([][]byte{}, 4, "testing")
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2021-11-29 16:30:17 +00:00
|
|
|
_, err = NocachedHasher.arraysRoot([][]byte{}, 8, "testing")
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.NoError(t, err)
|
2021-11-29 16:30:17 +00:00
|
|
|
_, err = NocachedHasher.arraysRoot([][]byte{}, 10, "testing")
|
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) {
|
2021-11-29 16:30:17 +00:00
|
|
|
_, err := NocachedHasher.arraysRoot([][]byte{}, 0, "testing")
|
2021-11-17 09:04:49 +00:00
|
|
|
assert.ErrorContains(t, "zero leaves provided", err)
|
|
|
|
}
|