mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
86a9d4c6a4
* Configurable testutil's BeaconState * fix shared and fuzz tests * return state copy * use mainnet config values for default state * handle error in block fuzz * goimports Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
34 lines
836 B
Go
34 lines
836 B
Go
package testutil
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
"testing"
|
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestNewBeaconState(t *testing.T) {
|
|
st, err := NewBeaconState()
|
|
require.NoError(t, err)
|
|
b, err := st.InnerStateUnsafe().MarshalSSZ()
|
|
require.NoError(t, err)
|
|
got := &pb.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)
|
|
}
|