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