Skip to content

Commit

Permalink
fixed libp2pendpoint flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumemichel committed Jul 6, 2023
1 parent c0b9440 commit 7fe4528
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 101 deletions.
9 changes: 7 additions & 2 deletions network/endpoint/libp2pendpoint/libp2pendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (e *Libp2pEndpoint) SendRequestHandleResponse(ctx context.Context,
resp message.MinKadMessage, timeout time.Duration,
responseHandlerFn endpoint.ResponseHandlerFn) error {

_, span := util.StartSpan(context.Background(),
_, span := util.StartSpan(ctx,
"Libp2pEndpoint.SendRequestHandleResponse", trace.WithAttributes(
attribute.String("PeerID", n.String()),
))
Expand All @@ -176,13 +176,18 @@ func (e *Libp2pEndpoint) SendRequestHandleResponse(ctx context.Context,
return ErrRequirePeerID
}

if len(e.host.Peerstore().Addrs(p.ID)) == 0 {
span.RecordError(endpoint.ErrUnknownPeer)
return endpoint.ErrUnknownPeer
}

if responseHandlerFn == nil {
span.RecordError(endpoint.ErrNilResponseHandler)
return endpoint.ErrNilResponseHandler
}

go func() {
ctx, span := util.StartSpan(context.Background(),
ctx, span := util.StartSpan(e.ctx,
"Libp2pEndpoint.SendRequestHandleResponse libp2p go routine",
trace.WithAttributes(
attribute.String("PeerID", n.String()),
Expand Down
Loading

0 comments on commit 7fe4528

Please sign in to comment.