2022-02-28 13:56:12 +00:00
|
|
|
package stateutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2022-08-16 12:20:13 +00:00
|
|
|
mathutil "github.com/prysmaticlabs/prysm/v3/math"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
2022-02-28 13:56:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestValidatorConstants(t *testing.T) {
|
|
|
|
v := ðpb.Validator{}
|
|
|
|
refV := reflect.ValueOf(v).Elem()
|
|
|
|
numFields := refV.NumField()
|
|
|
|
numOfValFields := 0
|
|
|
|
|
|
|
|
for i := 0; i < numFields; i++ {
|
|
|
|
if strings.Contains(refV.Type().Field(i).Name, "state") ||
|
|
|
|
strings.Contains(refV.Type().Field(i).Name, "sizeCache") ||
|
|
|
|
strings.Contains(refV.Type().Field(i).Name, "unknownFields") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
numOfValFields++
|
|
|
|
}
|
|
|
|
assert.Equal(t, validatorFieldRoots, numOfValFields)
|
|
|
|
assert.Equal(t, uint64(validatorFieldRoots), mathutil.PowerOf2(validatorTreeDepth))
|
|
|
|
|
|
|
|
_, err := ValidatorRegistryRoot([]*ethpb.Validator{v})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|