2021-01-07 21:00:21 +00:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-07-21 21:34:07 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-01-07 21:00:21 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHydrateAttestation(t *testing.T) {
|
|
|
|
a := HydrateAttestation(ðpb.Attestation{})
|
|
|
|
_, err := a.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepEqual(t, a.Signature, make([]byte, params.BeaconConfig().BLSSignatureLength))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHydrateAttestationData(t *testing.T) {
|
|
|
|
d := HydrateAttestationData(ðpb.AttestationData{})
|
|
|
|
_, err := d.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, 32))
|
|
|
|
require.DeepEqual(t, d.Target.Root, make([]byte, 32))
|
|
|
|
require.DeepEqual(t, d.Source.Root, make([]byte, 32))
|
|
|
|
}
|
2021-01-13 22:05:57 +00:00
|
|
|
|
|
|
|
func TestHydrateIndexedAttestation(t *testing.T) {
|
|
|
|
a := ðpb.IndexedAttestation{}
|
|
|
|
a = HydrateIndexedAttestation(a)
|
|
|
|
_, err := a.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
_, err = a.Data.HashTreeRoot()
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
2021-01-14 18:22:53 +00:00
|
|
|
|
|
|
|
func TestGenerateAttestations_EpochBoundary(t *testing.T) {
|
|
|
|
gs, pk := DeterministicGenesisState(t, 32)
|
|
|
|
_, err := GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|