Ignore empty public keys in gRPC request (#1309)

* Ignore empty public keys in gRPC request

* Remove log
This commit is contained in:
Preston Van Loon 2019-01-12 23:44:28 -05:00 committed by Nishant Das
parent 5b14c8695d
commit ddf454a04d
2 changed files with 16 additions and 0 deletions

View File

@ -447,6 +447,9 @@ func assignmentsForPublicKeys(keys []*pb.PublicKey, beaconState *pbp2p.BeaconSta
assignments := []*pb.Assignment{}
for _, val := range keys {
if len(val.PublicKey) == 0 {
continue
}
// For the corresponding public key and current crystallized state,
// we determine the assigned slot for the validator and whether it
// should act as a proposer or attester.

View File

@ -656,3 +656,16 @@ func TestValidatorAssignments(t *testing.T) {
exitRoutine <- true
testutil.AssertLogsContain(t, hook, "Sending new cycle assignments to validator clients")
}
func TestAssignmentsForPublicKeys_emptyPubKey(t *testing.T) {
pks := []*pb.PublicKey{&pb.PublicKey{}}
a, err := assignmentsForPublicKeys(pks, nil)
if err != nil {
t.Error(err)
}
if len(a) > 0 {
t.Errorf("Expected no assignments, but got %v", a)
}
}