Skip empty criteria for public key instead of fail (#3130)

This commit is contained in:
terence tsao 2019-08-03 10:23:10 -07:00 committed by GitHub
parent 7e819990f6
commit d59800210a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -222,6 +222,11 @@ func (bs *BeaconChainServer) ListValidatorBalances(
}
for _, pubKey := range req.PublicKeys {
// Skip empty public key
if len(pubKey) == 0 {
continue
}
index, err := bs.beaconDB.ValidatorIndex(pubKey)
if err != nil {
return nil, status.Errorf(codes.Internal, "could not retrieve validator index: %v", err)

View File

@ -326,6 +326,11 @@ func TestBeaconChainServer_ListValidatorBalances(t *testing.T) {
{Index: 3, PublicKey: []byte{3}, Balance: 3},
{Index: 4, PublicKey: []byte{4}, Balance: 4}},
}},
{req: &ethpb.GetValidatorBalancesRequest{PublicKeys: [][]byte{{}}, Indices: []uint64{3, 4}}, // Public key has a blank value
res: &ethpb.ValidatorBalances{Balances: []*ethpb.ValidatorBalances_Balance{
{Index: 3, PublicKey: []byte{3}, Balance: 3},
{Index: 4, PublicKey: []byte{4}, Balance: 4}},
}},
}
for _, test := range tests {