Skip to content

Commit

Permalink
debug error better
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Nov 19, 2024
1 parent 7ddf1ff commit add307d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions p2p/http/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,20 @@ func ExampleHost_Serve() {
ListenAddrs: []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/50221/http")},
}

go server.Serve()
defer server.Close()
go func() {
err := server.Serve()
if err != nil && err != http.ErrServerClosed {
fmt.Println("Error", err)
}
}()

for _, a := range server.Addrs() {
s := a.String()
addrWithoutSpecificPort := tcpPortRE.ReplaceAllString(s, "/tcp/<runtime-port>")
fmt.Println(addrWithoutSpecificPort)
}

server.Close()
// Output: /ip4/127.0.0.1/tcp/<runtime-port>/http
}

Expand Down

0 comments on commit add307d

Please sign in to comment.