mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
fixing error (#574)
This commit is contained in:
parent
c37ad4b446
commit
542ddef9e8
@ -66,7 +66,7 @@ type Service struct {
|
||||
grpcServer *grpc.Server
|
||||
canonicalBlockChan chan *types.Block
|
||||
canonicalStateChan chan *types.CrystallizedState
|
||||
incomingAttestation chan *pbp2p.AggregatedAttestation
|
||||
incomingAttestation chan *types.Attestation
|
||||
devMode bool
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ func NewRPCService(ctx context.Context, cfg *Config) *Service {
|
||||
withKey: cfg.KeyFlag,
|
||||
canonicalBlockChan: make(chan *types.Block, cfg.SubscriptionBuf),
|
||||
canonicalStateChan: make(chan *types.CrystallizedState, cfg.SubscriptionBuf),
|
||||
incomingAttestation: make(chan *pbp2p.AggregatedAttestation, cfg.SubscriptionBuf),
|
||||
incomingAttestation: make(chan *types.Attestation, cfg.SubscriptionBuf),
|
||||
devMode: cfg.DevMode,
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ func (s *Service) LatestAttestation(req *empty.Empty, stream pb.BeaconService_La
|
||||
select {
|
||||
case attestation := <-s.incomingAttestation:
|
||||
log.Info("Sending attestation to RPC clients")
|
||||
if err := stream.Send(attestation); err != nil {
|
||||
if err := stream.Send(attestation.Proto()); err != nil {
|
||||
return err
|
||||
}
|
||||
case <-sub.Err():
|
||||
|
@ -327,9 +327,10 @@ func TestLatestAttestation(t *testing.T) {
|
||||
defer ctrl.Finish()
|
||||
|
||||
exitRoutine := make(chan bool)
|
||||
attestation := &types.Attestation{}
|
||||
|
||||
mockStream := internal.NewMockBeaconService_LatestAttestationServer(ctrl)
|
||||
mockStream.EXPECT().Send(&pbp2p.AggregatedAttestation{}).Return(errors.New("something wrong"))
|
||||
mockStream.EXPECT().Send(attestation.Proto()).Return(errors.New("something wrong"))
|
||||
// Tests a faulty stream.
|
||||
go func(tt *testing.T) {
|
||||
if err := rpcService.LatestAttestation(&empty.Empty{}, mockStream); err.Error() != "something wrong" {
|
||||
@ -337,10 +338,11 @@ func TestLatestAttestation(t *testing.T) {
|
||||
}
|
||||
<-exitRoutine
|
||||
}(t)
|
||||
rpcService.incomingAttestation <- &pbp2p.AggregatedAttestation{}
|
||||
|
||||
rpcService.incomingAttestation <- attestation
|
||||
|
||||
mockStream = internal.NewMockBeaconService_LatestAttestationServer(ctrl)
|
||||
mockStream.EXPECT().Send(&pbp2p.AggregatedAttestation{}).Return(nil)
|
||||
mockStream.EXPECT().Send(attestation.Proto()).Return(nil)
|
||||
|
||||
// Tests a good stream.
|
||||
go func(tt *testing.T) {
|
||||
@ -349,7 +351,7 @@ func TestLatestAttestation(t *testing.T) {
|
||||
}
|
||||
<-exitRoutine
|
||||
}(t)
|
||||
rpcService.incomingAttestation <- &pbp2p.AggregatedAttestation{}
|
||||
rpcService.incomingAttestation <- attestation
|
||||
testutil.AssertLogsContain(t, hook, "Sending attestation to RPC clients")
|
||||
rpcService.cancel()
|
||||
exitRoutine <- true
|
||||
|
Loading…
Reference in New Issue
Block a user