Fix Small Issue in Validator RPC Health Endpoint (#7195)

* amend node connection response
* imports
* fix err
* fix conf
* err
* test fix
* Merge branch 'master' into fix-health-endpoint
This commit is contained in:
Raul Jordan
2020-09-08 17:35:31 -05:00
committed by GitHub
parent 593442a0fa
commit 6d83770534
2 changed files with 10 additions and 17 deletions

View File

@@ -6,25 +6,19 @@ import (
ptypes "github.com/gogo/protobuf/types"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// GetBeaconNodeConnection retrieves the current beacon node connection
// information, as well as its sync status.
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
genesis, err := s.genesisFetcher.GenesisInfo(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not retrieve genesis information: %v", err)
}
syncStatus, err := s.syncChecker.Syncing(ctx)
if err != nil || s.validatorService.Status() != nil {
return &pb.NodeConnectionResponse{
GenesisTime: uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix()),
DepositContractAddress: genesis.DepositContractAddress,
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: false,
Syncing: false,
GenesisTime: 0,
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: false,
Syncing: false,
}, nil
}
return &pb.NodeConnectionResponse{

View File

@@ -25,11 +25,11 @@ type mockGenesisFetcher struct{}
func (m *mockGenesisFetcher) GenesisInfo(ctx context.Context) (*ethpb.Genesis, error) {
genesis, err := ptypes.TimestampProto(time.Unix(0, 0))
if err != nil {
log.Info(err)
return nil, err
}
return &ethpb.Genesis{
GenesisTime: genesis,
DepositContractAddress: []byte("hello"),
GenesisTime: genesis,
}, nil
}
@@ -48,11 +48,10 @@ func TestServer_GetBeaconNodeConnection(t *testing.T) {
got, err := s.GetBeaconNodeConnection(ctx, &ptypes.Empty{})
require.NoError(t, err)
want := &pb.NodeConnectionResponse{
BeaconNodeEndpoint: endpoint,
Connected: false,
Syncing: false,
GenesisTime: uint64(time.Unix(0, 0).Unix()),
DepositContractAddress: []byte("hello"),
BeaconNodeEndpoint: endpoint,
Connected: false,
Syncing: false,
GenesisTime: uint64(time.Unix(0, 0).Unix()),
}
require.DeepEqual(t, want, got)
}