fix: deflake multipro echo test

Specifically, wait for the handlers to finish printing before exiting.
This commit is contained in:
Steven Allen 2021-08-03 13:36:29 -07:00
parent 93ad759770
commit 8217b1f094
3 changed files with 3 additions and 1 deletions

View File

@ -86,6 +86,7 @@ func (e *EchoProtocol) onEchoRequest(s network.Stream) {
if ok {
log.Printf("%s: Echo response to %s sent.", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String())
}
e.done <- true
}
// remote echo response handler

View File

@ -57,7 +57,7 @@ func run(h1, h2 *Node, done <-chan bool) {
h2.Echo(h1.Host)
// block until all responses have been processed
for i := 0; i < 4; i++ {
for i := 0; i < 8; i++ {
<-done
}
}

View File

@ -82,6 +82,7 @@ func (p *PingProtocol) onPingRequest(s network.Stream) {
if ok {
log.Printf("%s: Ping response to %s sent.", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String())
}
p.done <- true
}
// remote ping response handler