Validator Client Fix (#254)

This commit is contained in:
Nishant Das
2018-09-17 12:13:04 +08:00
committed by Raul Jordan
parent 3c264be1c1
commit 5a6e5f44fd
3 changed files with 42 additions and 0 deletions

View File

@@ -179,9 +179,15 @@ func (s *ShardEthereum) registerAttesterService() error {
return err
}
var rpcService *rpcclient.Service
if err := s.services.FetchService(&rpcService); err != nil {
return err
}
att := attester.NewAttester(context.TODO(), &attester.Config{
Assigner: beaconService,
AssignmentBuf: 100,
Client: rpcService,
})
return s.services.RegisterService(att)
}

View File

@@ -91,3 +91,11 @@ func (s *Service) BeaconServiceClient() pb.BeaconServiceClient {
func (s *Service) ProposerServiceClient() pb.ProposerServiceClient {
return pb.NewProposerServiceClient(s.conn)
}
// AttesterServiceClient initializes a new attester gRPC service using
// an underlying connection object.
// This wrapper is important because the underlying gRPC connection is
// only defined after the service .Start() function is called.
func (s *Service) AttesterServiceClient() pb.AttesterServiceClient {
return pb.NewAttesterServiceClient(s.conn)
}

View File

@@ -52,3 +52,31 @@ func TestBeaconServiceClient(t *testing.T) {
t.Error("Beacon service client function does not implement interface")
}
}
func TestProposerServiceClient(t *testing.T) {
rpcClientService := NewRPCClient(
context.Background(),
&Config{
Endpoint: "merkle tries",
},
)
rpcClientService.conn = nil
client := rpcClientService.ProposerServiceClient()
if _, ok := client.(pb.ProposerServiceClient); !ok {
t.Error("Beacon service client function does not implement interface")
}
}
func TestAttesterServiceClient(t *testing.T) {
rpcClientService := NewRPCClient(
context.Background(),
&Config{
Endpoint: "merkle tries",
},
)
rpcClientService.conn = nil
client := rpcClientService.AttesterServiceClient()
if _, ok := client.(pb.AttesterServiceClient); !ok {
t.Error("Beacon service client function does not implement interface")
}
}