prysm-pulse/beacon-chain/sync/subscriber_beacon_aggregate_proof_test.go
Shay Zluf ffa08f5a85
Stream p2p agg attestation (#5809)
* stream aggreagted attestations from p2p network to indexed attestation stream

* remove excessive log

* fix test

* handle nil attestation as well

* Update beacon-chain/sync/subscriber_beacon_aggregate_proof.go

* Update beacon-chain/sync/subscriber_beacon_aggregate_proof.go

* Update beacon-chain/sync/subscriber_beacon_aggregate_proof_test.go

* terence feedback

* sort imports

* sort imports

* Change to received buffer

* preston feedback

* error log

* raul feedback

* more logging changes

* fix duplicate package name

Co-authored-by: terence tsao <terence@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
2020-05-13 12:21:53 -05:00

35 lines
1.1 KiB
Go

package sync
import (
"context"
"reflect"
"testing"
lru "github.com/hashicorp/golang-lru"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
)
func TestBeaconAggregateProofSubscriber_CanSave(t *testing.T) {
c, err := lru.New(10)
if err != nil {
t.Fatal(err)
}
r := &Service{
attPool: attestations.NewPool(),
seenAttestationCache: c,
attestationNotifier: (&mock.ChainService{}).OperationNotifier(),
}
a := &ethpb.SignedAggregateAttestationAndProof{Message: &ethpb.AggregateAttestationAndProof{Aggregate: &ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{}}, AggregationBits: bitfield.Bitlist{0x07}}, AggregatorIndex: 100}}
if err := r.beaconAggregateProofSubscriber(context.Background(), a); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(r.attPool.AggregatedAttestations(), []*ethpb.Attestation{a.Message.Aggregate}) {
t.Error("Did not save aggregated attestation")
}
}