mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
ba07ccb484
* slasher/beaconclient tests * slasher/db/kv tests * Merge branch 'master' into apply-testutils-assertions-to-slasher * fix build * slasher/detection tests * rest of the tests * misc tests * tools tests * Merge refs/heads/master into apply-testutils-assertions-misc * Merge branch 'master' into apply-testutils-assertions-misc * agg tests * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge branch 'master' into apply-testutils-assertions-misc * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc * updates aggregated_test * beacon-chain/operations/attestations/kv/* tests updated * beacon-chain/operations/attestations tests updated * beacon-chain/operations/slashings tests updated * Merge branch 'master' into apply-testutils-assertions-misc * gazelle * beacon-chain/core tests updated * fixes test * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc * beacon-chain/rpc tests updated * beacon-chain/sync/initial-sync tests * misc tests * optimizes error message parsing in testutils * Merge branch 'assertutils-optimize-processing' into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * endtoend tests * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc * gazelle * Merge refs/heads/master into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * beacon-chain/blockchain tests updated * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc * beacon-chain/state/stategen tests updated * beacon-chain all left-over tests are done * Merge refs/heads/master into apply-testutils-assertions-misc * validator tests updated * slasher tests * Merge branch 'master' into apply-testutils-assertions-misc * gofmt * gazelle * Merge refs/heads/master into apply-testutils-assertions-misc * shared upd * end2end tests deps fixed * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc * Merge refs/heads/master into apply-testutils-assertions-misc * misc * all tests are updated * Merge branch 'apply-testutils-assertions-misc' of github.com:prysmaticlabs/prysm into apply-testutils-assertions-misc
93 lines
2.5 KiB
Go
93 lines
2.5 KiB
Go
package attestations
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/go-bitfield"
|
|
"github.com/prysmaticlabs/prysm/shared/aggregation"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
)
|
|
|
|
func TestAggregateAttestations_MaxCover_NewMaxCover(t *testing.T) {
|
|
type args struct {
|
|
atts []*ethpb.Attestation
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want *aggregation.MaxCoverProblem
|
|
wantedErr string
|
|
}{
|
|
{
|
|
name: "nil attestations",
|
|
args: args{
|
|
atts: nil,
|
|
},
|
|
wantedErr: ErrInvalidAttestationCount.Error(),
|
|
},
|
|
{
|
|
name: "no attestations",
|
|
args: args{
|
|
atts: []*ethpb.Attestation{},
|
|
},
|
|
wantedErr: ErrInvalidAttestationCount.Error(),
|
|
},
|
|
{
|
|
name: "attestations of different bitlist length",
|
|
args: args{
|
|
atts: []*ethpb.Attestation{
|
|
{AggregationBits: bitfield.NewBitlist(64)},
|
|
{AggregationBits: bitfield.NewBitlist(128)},
|
|
},
|
|
},
|
|
wantedErr: aggregation.ErrBitsDifferentLen.Error(),
|
|
},
|
|
{
|
|
name: "single attestation",
|
|
args: args{
|
|
atts: []*ethpb.Attestation{
|
|
{AggregationBits: bitfield.Bitlist{0b00001010, 0b1}},
|
|
},
|
|
},
|
|
want: &aggregation.MaxCoverProblem{
|
|
Candidates: aggregation.MaxCoverCandidates{
|
|
aggregation.NewMaxCoverCandidate(0, &bitfield.Bitlist{0b00001010, 0b1}),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "multiple attestations",
|
|
args: args{
|
|
atts: []*ethpb.Attestation{
|
|
{AggregationBits: bitfield.Bitlist{0b00001010, 0b1}},
|
|
{AggregationBits: bitfield.Bitlist{0b00101010, 0b1}},
|
|
{AggregationBits: bitfield.Bitlist{0b11111010, 0b1}},
|
|
{AggregationBits: bitfield.Bitlist{0b00000010, 0b1}},
|
|
{AggregationBits: bitfield.Bitlist{0b00000001, 0b1}},
|
|
},
|
|
},
|
|
want: &aggregation.MaxCoverProblem{
|
|
Candidates: aggregation.MaxCoverCandidates{
|
|
aggregation.NewMaxCoverCandidate(0, &bitfield.Bitlist{0b00001010, 0b1}),
|
|
aggregation.NewMaxCoverCandidate(1, &bitfield.Bitlist{0b00101010, 0b1}),
|
|
aggregation.NewMaxCoverCandidate(2, &bitfield.Bitlist{0b11111010, 0b1}),
|
|
aggregation.NewMaxCoverCandidate(3, &bitfield.Bitlist{0b00000010, 0b1}),
|
|
aggregation.NewMaxCoverCandidate(4, &bitfield.Bitlist{0b00000001, 0b1}),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := NewMaxCover(tt.args.atts)
|
|
if tt.wantedErr != "" {
|
|
assert.ErrorContains(t, tt.wantedErr, err)
|
|
} else {
|
|
assert.NoError(t, err)
|
|
assert.DeepEqual(t, tt.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|