prysm-pulse/testing/util/attestation_test.go
Raul Jordan d077483577
Add V3 Suffix to All Prysm Packages (#11083)
* v3 import renamings

* tidy

* fmt

* rev

* Update beacon-chain/core/epoch/precompute/reward_penalty_test.go

* Update beacon-chain/core/helpers/validators_test.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/alias.go

* Update beacon-chain/db/iface/BUILD.bazel

* Update beacon-chain/db/kv/kv.go

* Update beacon-chain/db/kv/state.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go

* Update beacon-chain/sync/initial-sync/service.go

* fix deps

* fix bad replacements

* fix bad replacements

* change back

* gohashtree version

* fix deps

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
2022-08-16 12:20:13 +00:00

59 lines
2.0 KiB
Go

package util
import (
"testing"
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
"github.com/prysmaticlabs/prysm/v3/config/params"
v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1"
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v3/testing/require"
)
func TestHydrateAttestation(t *testing.T) {
a := HydrateAttestation(&ethpb.Attestation{})
_, err := a.HashTreeRoot()
require.NoError(t, err)
require.DeepEqual(t, a.Signature, make([]byte, fieldparams.BLSSignatureLength))
}
func TestHydrateAttestationData(t *testing.T) {
d := HydrateAttestationData(&ethpb.AttestationData{})
_, err := d.HashTreeRoot()
require.NoError(t, err)
require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, fieldparams.RootLength))
require.DeepEqual(t, d.Target.Root, make([]byte, fieldparams.RootLength))
require.DeepEqual(t, d.Source.Root, make([]byte, fieldparams.RootLength))
}
func TestHydrateV1Attestation(t *testing.T) {
a := HydrateV1Attestation(&v1.Attestation{})
_, err := a.HashTreeRoot()
require.NoError(t, err)
require.DeepEqual(t, a.Signature, make([]byte, fieldparams.BLSSignatureLength))
}
func TestHydrateV1AttestationData(t *testing.T) {
d := HydrateV1AttestationData(&v1.AttestationData{})
_, err := d.HashTreeRoot()
require.NoError(t, err)
require.DeepEqual(t, d.BeaconBlockRoot, make([]byte, fieldparams.RootLength))
require.DeepEqual(t, d.Target.Root, make([]byte, fieldparams.RootLength))
require.DeepEqual(t, d.Source.Root, make([]byte, fieldparams.RootLength))
}
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)
}