prysm-pulse/testing/util/state_test.go
Raul Jordan a9a4bb9163
Move Shared/Testutil into Testing (#9659)
* move testutil

* util pkg

* build

* gaz

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-09-23 18:53:46 +00:00

34 lines
812 B
Go

package util
import (
"context"
"reflect"
"testing"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/testing/require"
)
func TestNewBeaconState(t *testing.T) {
st, err := NewBeaconState()
require.NoError(t, err)
b, err := st.MarshalSSZ()
require.NoError(t, err)
got := &ethpb.BeaconState{}
require.NoError(t, got.UnmarshalSSZ(b))
if !reflect.DeepEqual(st.InnerStateUnsafe(), got) {
t.Fatal("State did not match after round trip marshal")
}
}
func TestNewBeaconState_HashTreeRoot(t *testing.T) {
st, err := NewBeaconState()
require.NoError(t, err)
_, err = st.HashTreeRoot(context.Background())
require.NoError(t, err)
st, err = NewBeaconState()
require.NoError(t, err)
_, err = st.HashTreeRoot(context.Background())
require.NoError(t, err)
}