mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
b38b0186b8
* Use bls sig length from fieldparams * fmt * fix tests * fix tests * fix tests * Update tags_test.go * fix tests * Update BUILD.bazel
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-bitfield"
|
|
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations"
|
|
lruwrpr "github.com/prysmaticlabs/prysm/cache/lru"
|
|
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
|
)
|
|
|
|
func TestBeaconAggregateProofSubscriber_CanSaveAggregatedAttestation(t *testing.T) {
|
|
r := &Service{
|
|
cfg: &config{
|
|
attPool: attestations.NewPool(),
|
|
attestationNotifier: (&mock.ChainService{}).OperationNotifier(),
|
|
},
|
|
seenUnAggregatedAttestationCache: lruwrpr.New(10),
|
|
}
|
|
|
|
a := ðpb.SignedAggregateAttestationAndProof{
|
|
Message: ðpb.AggregateAttestationAndProof{
|
|
Aggregate: util.HydrateAttestation(ðpb.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 := ðpb.SignedAggregateAttestationAndProof{
|
|
Message: ðpb.AggregateAttestationAndProof{
|
|
Aggregate: util.HydrateAttestation(ðpb.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")
|
|
}
|