Align Beacon API with 2.2.0 spec (#10455)

This commit is contained in:
Radosław Kapka 2022-03-30 17:17:19 +02:00 committed by GitHub
parent 588605ceeb
commit be6f3892e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -414,7 +414,7 @@ func (vs *Server) GetAggregateAttestation(ctx context.Context, req *ethpbv1.Aggr
}
if bestMatchingAtt == nil {
return nil, status.Error(codes.InvalidArgument, "No matching attestation found")
return nil, status.Error(codes.NotFound, "No matching attestation found")
}
return &ethpbv1.AggregateAttestationResponse{
Data: migration.V1Alpha1AttestationToV1(bestMatchingAtt),
@ -631,6 +631,9 @@ func (vs *Server) ProduceSyncCommitteeContribution(
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get sync subcommittee messages: %v", err)
}
if msgs == nil {
return nil, status.Errorf(codes.NotFound, "No subcommittee messages found")
}
aggregatedSig, bits, err := vs.V1Alpha1Server.AggregatedSigAndAggregationBits(ctx, msgs, req.Slot, req.SubcommitteeIndex, req.BeaconBlockRoot)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get contribution data: %v", err)

View File

@ -1994,6 +1994,25 @@ func TestProduceSyncCommitteeContribution(t *testing.T) {
aggregationBits := resp.Data.AggregationBits
assert.Equal(t, true, aggregationBits.BitAt(0))
assert.DeepEqual(t, sig, resp.Data.Signature)
syncCommitteePool = synccommittee.NewStore()
v1Server = &v1alpha1validator.Server{
SyncCommitteePool: syncCommitteePool,
HeadFetcher: &mockChain.ChainService{
SyncCommitteeIndices: []types.CommitteeIndex{0},
},
}
server = Server{
V1Alpha1Server: v1Server,
SyncCommitteePool: syncCommitteePool,
}
req = &ethpbv2.ProduceSyncCommitteeContributionRequest{
Slot: 0,
SubcommitteeIndex: 0,
BeaconBlockRoot: root,
}
_, err = server.ProduceSyncCommitteeContribution(ctx, req)
assert.ErrorContains(t, "No subcommittee messages found", err)
}
func TestSubmitContributionAndProofs(t *testing.T) {