提交 c8ef4cad 作者: Juan Benet

Merge pull request #1647 from ipfs/fix/mock-notif

fix mock notification test
...@@ -111,10 +111,8 @@ func TestNotifications(t *testing.T) { ...@@ -111,10 +111,8 @@ func TestNotifications(t *testing.T) {
} }
} }
streams := make(chan inet.Stream)
for _, s := range nets { for _, s := range nets {
s.SetStreamHandler(func(s inet.Stream) { s.SetStreamHandler(func(s inet.Stream) {
streams <- s
s.Close() s.Close()
}) })
} }
...@@ -123,10 +121,17 @@ func TestNotifications(t *testing.T) { ...@@ -123,10 +121,17 @@ func TestNotifications(t *testing.T) {
// unsure where these are coming from // unsure where these are coming from
for i := range nets { for i := range nets {
n := notifiees[i] n := notifiees[i]
testOCStream(n, nil) for j := 0; j < len(nets)-1; j++ {
testOCStream(n, nil) testOCStream(n, nil)
testOCStream(n, nil) }
testOCStream(n, nil) }
streams := make(chan inet.Stream)
for _, s := range nets {
s.SetStreamHandler(func(s inet.Stream) {
streams <- s
s.Close()
})
} }
// open a streams in each conn // open a streams in each conn
......
...@@ -80,6 +80,8 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { ...@@ -80,6 +80,8 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
if err != nil { if err != nil {
log.Debugf("error opening initial stream for %s", ID) log.Debugf("error opening initial stream for %s", ID)
log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer()) log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer())
c.Close()
return
} else { } else {
bwc := ids.Host.GetBandwidthReporter() bwc := ids.Host.GetBandwidthReporter()
s = mstream.WrapStream(s, ID, bwc) s = mstream.WrapStream(s, ID, bwc)
...@@ -88,6 +90,9 @@ func (ids *IDService) IdentifyConn(c inet.Conn) { ...@@ -88,6 +90,9 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
if err := protocol.WriteHeader(s, ID); err != nil { if err := protocol.WriteHeader(s, ID); err != nil {
log.Debugf("error writing stream header for %s", ID) log.Debugf("error writing stream header for %s", ID)
log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer()) log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer())
s.Close()
c.Close()
return
} }
ids.ResponseHandler(s) ids.ResponseHandler(s)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论