mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
c4afb8e2e7
* Use state util to get block root * Merge branch 'master' of github.com:prysmaticlabs/prysm * Merge branch 'master' of github.com:prysmaticlabs/prysm * Also save unaggregated att * Merge refs/heads/master into fix-save-agg * Handle error * Merge branch 'fix-save-agg' of github.com:prysmaticlabs/prysm into fix-save-agg * Test * Merge refs/heads/master into fix-save-agg
56 lines
1.9 KiB
Go
56 lines
1.9 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_CanSaveAggregatedAttestation(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 := ðpb.SignedAggregateAttestationAndProof{Message: ðpb.AggregateAttestationAndProof{Aggregate: ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.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")
|
|
}
|
|
}
|
|
|
|
func TestBeaconAggregateProofSubscriber_CanSaveUnaggregatedAttestation(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 := ðpb.SignedAggregateAttestationAndProof{Message: ðpb.AggregateAttestationAndProof{Aggregate: ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{}}, AggregationBits: bitfield.Bitlist{0x03}}, AggregatorIndex: 100}}
|
|
if err := r.beaconAggregateProofSubscriber(context.Background(), a); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !reflect.DeepEqual(r.attPool.UnaggregatedAttestations(), []*ethpb.Attestation{a.Message.Aggregate}) {
|
|
t.Error("Did not save unaggregated attestation")
|
|
}
|
|
}
|