Fix assignments bug where validators don't retry for assignments on failure (#2000)

This commit is contained in:
Preston Van Loon 2019-03-14 21:39:25 -04:00 committed by GitHub
parent f1d77a816e
commit 5ddf367291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -139,6 +139,7 @@ func (v *validator) UpdateAssignments(ctx context.Context, slot uint64) error {
resp, err := v.validatorClient.CommitteeAssignment(ctx, req)
if err != nil {
v.assignment = nil // Clear assignments so we know to retry the request.
return err
}

View File

@ -283,6 +283,7 @@ func TestUpdateAssignments_ReturnsError(t *testing.T) {
v := validator{
key: validatorKey,
validatorClient: client,
assignment: &pb.CommitteeAssignmentResponse{Shard: 1},
}
expected := errors.New("bad")
@ -295,6 +296,9 @@ func TestUpdateAssignments_ReturnsError(t *testing.T) {
if err := v.UpdateAssignments(context.Background(), params.BeaconConfig().SlotsPerEpoch); err != expected {
t.Errorf("Bad error; want=%v got=%v", expected, err)
}
if v.assignment != nil {
t.Error("Assignments should have been cleared on failure")
}
}
func TestUpdateAssignments_OK(t *testing.T) {