mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
80 lines
2.2 KiB
Go
80 lines
2.2 KiB
Go
package util
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
)
|
|
|
|
func TestNewBeaconState(t *testing.T) {
|
|
st, err := NewBeaconState()
|
|
require.NoError(t, err)
|
|
b, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := ðpb.BeaconState{}
|
|
require.NoError(t, got.UnmarshalSSZ(b))
|
|
assert.DeepEqual(t, st.ToProtoUnsafe(), got)
|
|
}
|
|
|
|
func TestNewBeaconStateAltair(t *testing.T) {
|
|
st, err := NewBeaconStateAltair()
|
|
require.NoError(t, err)
|
|
b, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := ðpb.BeaconStateAltair{}
|
|
require.NoError(t, got.UnmarshalSSZ(b))
|
|
assert.DeepEqual(t, st.ToProtoUnsafe(), got)
|
|
}
|
|
|
|
func TestNewBeaconStateBellatrix(t *testing.T) {
|
|
st, err := NewBeaconStateBellatrix()
|
|
require.NoError(t, err)
|
|
b, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := ðpb.BeaconStateBellatrix{}
|
|
require.NoError(t, got.UnmarshalSSZ(b))
|
|
assert.DeepEqual(t, st.ToProtoUnsafe(), got)
|
|
}
|
|
|
|
func TestNewBeaconStateCapella(t *testing.T) {
|
|
st, err := NewBeaconStateCapella()
|
|
require.NoError(t, err)
|
|
b, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := ðpb.BeaconStateCapella{}
|
|
require.NoError(t, got.UnmarshalSSZ(b))
|
|
assert.DeepEqual(t, st.ToProtoUnsafe(), got)
|
|
}
|
|
|
|
func TestNewBeaconStateDeneb(t *testing.T) {
|
|
st, err := NewBeaconStateDeneb()
|
|
require.NoError(t, err)
|
|
b, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := ðpb.BeaconStateDeneb{}
|
|
require.NoError(t, got.UnmarshalSSZ(b))
|
|
assert.DeepEqual(t, st.ToProtoUnsafe(), got)
|
|
}
|
|
|
|
func TestNewBeaconState_HashTreeRoot(t *testing.T) {
|
|
st, err := NewBeaconState()
|
|
require.NoError(t, err)
|
|
_, err = st.HashTreeRoot(context.Background())
|
|
require.NoError(t, err)
|
|
st, err = NewBeaconStateAltair()
|
|
require.NoError(t, err)
|
|
_, err = st.HashTreeRoot(context.Background())
|
|
require.NoError(t, err)
|
|
st, err = NewBeaconStateBellatrix()
|
|
require.NoError(t, err)
|
|
_, err = st.HashTreeRoot(context.Background())
|
|
require.NoError(t, err)
|
|
st, err = NewBeaconStateCapella()
|
|
require.NoError(t, err)
|
|
_, err = st.HashTreeRoot(context.Background())
|
|
require.NoError(t, err)
|
|
}
|