prysm-pulse/beacon-chain/sync/subscriber_beacon_aggregate_proof_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

64 lines
2.2 KiB
Go

package sync
import (
"context"
"testing"
"github.com/prysmaticlabs/go-bitfield"
mock "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/attestations"
lruwrpr "github.com/prysmaticlabs/prysm/v3/cache/lru"
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v3/testing/assert"
"github.com/prysmaticlabs/prysm/v3/testing/require"
"github.com/prysmaticlabs/prysm/v3/testing/util"
)
func TestBeaconAggregateProofSubscriber_CanSaveAggregatedAttestation(t *testing.T) {
r := &Service{
cfg: &config{
attPool: attestations.NewPool(),
attestationNotifier: (&mock.ChainService{}).OperationNotifier(),
},
seenUnAggregatedAttestationCache: lruwrpr.New(10),
}
a := &ethpb.SignedAggregateAttestationAndProof{
Message: &ethpb.AggregateAttestationAndProof{
Aggregate: util.HydrateAttestation(&ethpb.Attestation{
AggregationBits: bitfield.Bitlist{0x07},
}),
AggregatorIndex: 100,
},
Signature: make([]byte, fieldparams.BLSSignatureLength),
}
require.NoError(t, r.beaconAggregateProofSubscriber(context.Background(), a))
assert.DeepSSZEqual(t, []*ethpb.Attestation{a.Message.Aggregate}, r.cfg.attPool.AggregatedAttestations(), "Did not save aggregated attestation")
}
func TestBeaconAggregateProofSubscriber_CanSaveUnaggregatedAttestation(t *testing.T) {
r := &Service{
cfg: &config{
attPool: attestations.NewPool(),
attestationNotifier: (&mock.ChainService{}).OperationNotifier(),
},
seenUnAggregatedAttestationCache: lruwrpr.New(10),
}
a := &ethpb.SignedAggregateAttestationAndProof{
Message: &ethpb.AggregateAttestationAndProof{
Aggregate: util.HydrateAttestation(&ethpb.Attestation{
AggregationBits: bitfield.Bitlist{0x03},
Signature: make([]byte, fieldparams.BLSSignatureLength),
}),
AggregatorIndex: 100,
},
}
require.NoError(t, r.beaconAggregateProofSubscriber(context.Background(), a))
atts, err := r.cfg.attPool.UnaggregatedAttestations()
require.NoError(t, err)
assert.DeepEqual(t, []*ethpb.Attestation{a.Message.Aggregate}, atts, "Did not save unaggregated attestation")
}