mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
parent
88765b6d3c
commit
615daa98e9
@ -102,6 +102,10 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(aggregationBitfield) == 0 {
|
||||||
|
log.Error("Aggregation bitfield is empty so unable to attest to block head")
|
||||||
|
return
|
||||||
|
}
|
||||||
aggregationBitfield[indexIntoCommittee/8] |= 1 << (indexIntoCommittee % 8)
|
aggregationBitfield[indexIntoCommittee/8] |= 1 << (indexIntoCommittee % 8)
|
||||||
// Note: calling get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
// Note: calling get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
||||||
// should return a list of length equal to 1, containing validator_index.
|
// should return a list of length equal to 1, containing validator_index.
|
||||||
|
@ -280,3 +280,38 @@ func TestAttestToBlockHead_DoesAttestAfterDelay(t *testing.T) {
|
|||||||
delay = 0
|
delay = 0
|
||||||
validator.AttestToBlockHead(context.Background(), 0)
|
validator.AttestToBlockHead(context.Background(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAttestToBlockHead_EmptyAggregationBitfield(t *testing.T) {
|
||||||
|
hook := logTest.NewGlobal()
|
||||||
|
validator, m, finish := setup(t)
|
||||||
|
defer finish()
|
||||||
|
|
||||||
|
validatorIndex := uint64(5)
|
||||||
|
committee := []uint64{}
|
||||||
|
m.validatorClient.EXPECT().ValidatorIndex(
|
||||||
|
gomock.Any(), // ctx
|
||||||
|
gomock.AssignableToTypeOf(&pb.ValidatorIndexRequest{}),
|
||||||
|
).Return(&pb.ValidatorIndexResponse{
|
||||||
|
Index: uint64(validatorIndex),
|
||||||
|
}, nil)
|
||||||
|
m.validatorClient.EXPECT().ValidatorCommitteeAtSlot(
|
||||||
|
gomock.Any(), // ctx
|
||||||
|
gomock.AssignableToTypeOf(&pb.CommitteeRequest{}),
|
||||||
|
).Return(&pb.CommitteeResponse{
|
||||||
|
Shard: 5,
|
||||||
|
Committee: committee,
|
||||||
|
}, nil)
|
||||||
|
m.attesterClient.EXPECT().AttestationDataAtSlot(
|
||||||
|
gomock.Any(), // ctx
|
||||||
|
gomock.AssignableToTypeOf(&pb.AttestationDataRequest{}),
|
||||||
|
).Return(&pb.AttestationDataResponse{
|
||||||
|
BeaconBlockRootHash32: []byte("A"),
|
||||||
|
EpochBoundaryRootHash32: []byte("B"),
|
||||||
|
JustifiedBlockRootHash32: []byte("C"),
|
||||||
|
LatestCrosslink: &pbp2p.Crosslink{CrosslinkDataRootHash32: []byte{'D'}},
|
||||||
|
JustifiedEpoch: 3,
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
validator.AttestToBlockHead(context.Background(), 30)
|
||||||
|
testutil.AssertLogsContain(t, hook, "Aggregation bitfield is empty so unable to attest to block head")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user