Commit 1e41597e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 17daf48d
...@@ -91,12 +91,12 @@ func _TestHandshake(t *T) { ...@@ -91,12 +91,12 @@ func _TestHandshake(t *T) {
t.Errorf("handshake ver mismatch: p2: unexpected error:\nhave: %v\nwant: %v", err2, err2Want) t.Errorf("handshake ver mismatch: p2: unexpected error:\nhave: %v\nwant: %v", err2, err2Want)
} }
// tx & rx problem // tx & rx problem (client)
p1, p2 = net.Pipe() p1, p2 = net.Pipe()
err1, err2 = nil, nil var err error
wg = xsync.NewWorkGroup(bg) wg = xsync.NewWorkGroup(bg)
gox(wg, func(ctx context.Context) { gox(wg, func(ctx context.Context) {
_, _, err1 = _handshakeClient(ctx, p1, 1, t.enc) _, _, err = _handshakeClient(ctx, p1, 1, t.enc)
}) })
gox(wg, func(_ context.Context) { gox(wg, func(_ context.Context) {
xclose(p2) xclose(p2)
...@@ -104,22 +104,34 @@ func _TestHandshake(t *T) { ...@@ -104,22 +104,34 @@ func _TestHandshake(t *T) {
xwait(wg) xwait(wg)
xclose(p1) xclose(p1)
err11, ok := err1.(*_HandshakeError) err_, ok := err.(*_HandshakeError)
if !ok || !(errors.Is(err_.Err, io.ErrClosedPipe /* on Write */) || errors.Is(err_.Err, io.ErrUnexpectedEOF /* on Read */)) {
if !ok || !(errors.Is(err11.Err, io.ErrClosedPipe /* on Write */) || errors.Is(err11.Err, io.ErrUnexpectedEOF /* on Read */)) { t.Errorf("handshake peer close: unexpected error: %#v", err)
t.Errorf("handshake peer close: unexpected error: %#v", err1)
} }
// XXX same for _handshakeServer // tx & rx problem (server)
p1, p2 = net.Pipe()
wg = xsync.NewWorkGroup(bg)
gox(wg, func(_ context.Context) {
xclose(p1)
})
gox(wg, func(ctx context.Context) {
_, _, err = _handshakeServer(ctx, p2, 1)
})
xwait(wg)
xclose(p2)
err_, ok = err.(*_HandshakeError)
if !ok || !(errors.Is(err_.Err, io.ErrClosedPipe /* on Write */) || errors.Is(err_.Err, io.ErrUnexpectedEOF /* on Read */)) {
t.Errorf("handshake peer close: unexpected error: %#v", err)
}
// ctx cancel // ctx cancel (client)
// XXX same for _handshakeServer
p1, p2 = net.Pipe() p1, p2 = net.Pipe()
ctx, cancel := context.WithCancel(bg) ctx, cancel := context.WithCancel(bg)
wg = xsync.NewWorkGroup(ctx) wg = xsync.NewWorkGroup(ctx)
gox(wg, func(ctx context.Context) { gox(wg, func(ctx context.Context) {
_, _, err1 = _handshakeClient(ctx, p1, 1, t.enc) _, _, err = _handshakeClient(ctx, p1, 1, t.enc)
}) })
tdelay() tdelay()
cancel() cancel()
...@@ -127,9 +139,26 @@ func _TestHandshake(t *T) { ...@@ -127,9 +139,26 @@ func _TestHandshake(t *T) {
xclose(p1) xclose(p1)
xclose(p2) xclose(p2)
err11, ok = err1.(*_HandshakeError) err_, ok = err.(*_HandshakeError)
if !ok || !(err_.Err == context.Canceled) {
t.Errorf("handshake (client): cancel: unexpected error: %#v", err)
}
// ctx cancel (server)
p1, p2 = net.Pipe()
ctx, cancel = context.WithCancel(bg)
wg = xsync.NewWorkGroup(ctx)
gox(wg, func(ctx context.Context) {
_, _, err = _handshakeServer(ctx, p2, 1)
})
tdelay()
cancel()
xwait(wg)
xclose(p1)
xclose(p2)
if !ok || !(err11.Err == context.Canceled) { err_, ok = err.(*_HandshakeError)
t.Errorf("handshake cancel: unexpected error: %#v", err1) if !ok || !(err_.Err == context.Canceled) {
t.Errorf("handshake (server): cancel: unexpected error: %#v", err)
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment