test: fix tls-no-rsa-key flakiness

In some conditions it can happen that the client-side socket is destroyed
before the server-side socket has gracefully closed, thus causing a
'ECONNRESET' error in this socket. To solve this, wait in the client-side
socket for the 'end' event before closing it.

PR-URL: https://github.com/nodejs/node/pull/4043
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Santiago Gimeno 2015-11-26 22:58:51 +01:00 committed by James M Snell
parent 0c924ea39f
commit 61fe86b560

View File

@ -23,9 +23,16 @@ var server = tls.createServer(options, function(conn) {
var c = tls.connect(common.PORT, {
rejectUnauthorized: false
}, function() {
c.on('end', common.mustCall(function() {
c.end();
server.close();
}));
c.on('data', function(data) {
assert.equal(data, 'ok');
});
cert = c.getPeerCertificate();
c.destroy();
server.close();
});
});