github.com/prysmaticlabs/prysm@v1.4.4/shared/testutil/attestation_test.go (about) 1 package testutil 2 3 import ( 4 "testing" 5 6 ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 7 "github.com/prysmaticlabs/prysm/shared/params" 8 "github.com/prysmaticlabs/prysm/shared/testutil/require" 9 ) 10 11 func TestHydrateAttestation(t *testing.T) { 12 a := HydrateAttestation(ðpb.Attestation{}) 13 _, err := a.HashTreeRoot() 14 require.NoError(t, err) 15 require.DeepEqual(t, a.Signature, make([]byte, params.BeaconConfig().BLSSignatureLength)) 16 } 17 18 func TestHydrateAttestationData(t *testing.T) { 19 d := HydrateAttestationData(ðpb.AttestationData{}) 20 _, err := d.HashTreeRoot() 21 require.NoError(t, err) 22 require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, 32)) 23 require.DeepEqual(t, d.Target.Root, make([]byte, 32)) 24 require.DeepEqual(t, d.Source.Root, make([]byte, 32)) 25 } 26 27 func TestHydrateIndexedAttestation(t *testing.T) { 28 a := ðpb.IndexedAttestation{} 29 a = HydrateIndexedAttestation(a) 30 _, err := a.HashTreeRoot() 31 require.NoError(t, err) 32 _, err = a.Data.HashTreeRoot() 33 require.NoError(t, err) 34 } 35 36 func TestGenerateAttestations_EpochBoundary(t *testing.T) { 37 gs, pk := DeterministicGenesisState(t, 32) 38 _, err := GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false) 39 require.NoError(t, err) 40 }