prysm-pulse/shared/testutil/attestation_test.go
Raul Jordan 5aac06f04e
Move EthereumAPIs Into Prysm (#8968)
* begin move

* use same import path

* imports

* regen protos

* regen

* no rename

* generate ssz

* gaz

* fmt

* edit build file

* imports

* modify

* remove generated files

* remove protos

* edit imports in prysm

* beacon chain all builds

* edit script

* add generated pbs

* add replace rules

* license for ethereumapis protos

* change visibility

* fmt

* update build files to gaz ignore

* use proper form

* edit imports

* wrap block

* revert scripts

* revert go mod
2021-06-02 18:49:52 -05:00

41 lines
1.2 KiB
Go

package testutil
import (
"testing"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
)
func TestHydrateAttestation(t *testing.T) {
a := HydrateAttestation(&ethpb.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(&ethpb.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))
}
func TestHydrateIndexedAttestation(t *testing.T) {
a := &ethpb.IndexedAttestation{}
a = HydrateIndexedAttestation(a)
_, err := a.HashTreeRoot()
require.NoError(t, err)
_, err = a.Data.HashTreeRoot()
require.NoError(t, err)
}
func TestGenerateAttestations_EpochBoundary(t *testing.T) {
gs, pk := DeterministicGenesisState(t, 32)
_, err := GenerateAttestations(gs, pk, 1, params.BeaconConfig().SlotsPerEpoch, false)
require.NoError(t, err)
}