summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvperezma <vperezma89@gmail.com>2017-04-22 11:38:16 -0700
committerRich Trott <rtrott@gmail.com>2017-05-14 21:27:03 -0700
commit72e3dda93c7cae1035521adc67d5b80c735a3ac3 (patch)
treeb00ee81750a25d4409d4f36567c0e02846a60adc
parentb7bc09fd60fa89a572f1de78bf78562bd93adbd3 (diff)
downloadandroid-node-v8-72e3dda93c7cae1035521adc67d5b80c735a3ac3.tar.gz
android-node-v8-72e3dda93c7cae1035521adc67d5b80c735a3ac3.tar.bz2
android-node-v8-72e3dda93c7cae1035521adc67d5b80c735a3ac3.zip
test: use mustCall in tls-connect-given-socket
PR-URL: https://github.com/nodejs/node/pull/12592 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--test/parallel/test-tls-connect-given-socket.js27
1 files changed, 8 insertions, 19 deletions
diff --git a/test/parallel/test-tls-connect-given-socket.js b/test/parallel/test-tls-connect-given-socket.js
index 971593b20b..0855391619 100644
--- a/test/parallel/test-tls-connect-given-socket.js
+++ b/test/parallel/test-tls-connect-given-socket.js
@@ -32,26 +32,20 @@ const tls = require('tls');
const net = require('net');
const fs = require('fs');
const path = require('path');
-
-let serverConnected = 0;
-let clientConnected = 0;
-
const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-const server = tls.createServer(options, (socket) => {
- serverConnected++;
+const server = tls.createServer(options, common.mustCall((socket) => {
socket.end('Hello');
-}).listen(0, () => {
+}, 2)).listen(0, common.mustCall(() => {
let waiting = 2;
- function establish(socket) {
+ function establish(socket, calls) {
const client = tls.connect({
rejectUnauthorized: false,
socket: socket
- }, () => {
- clientConnected++;
+ }, common.mustCall(() => {
let data = '';
client.on('data', common.mustCall((chunk) => {
data += chunk.toString();
@@ -61,7 +55,7 @@ const server = tls.createServer(options, (socket) => {
if (--waiting === 0)
server.close();
}));
- });
+ }, calls));
assert(client.readable);
assert(client.writable);
@@ -72,14 +66,14 @@ const server = tls.createServer(options, (socket) => {
// Immediate death socket
const immediateDeath = net.connect(port);
- establish(immediateDeath).destroy();
+ establish(immediateDeath, 0).destroy();
// Outliving
const outlivingTCP = net.connect(port, common.mustCall(() => {
outlivingTLS.destroy();
next();
}));
- const outlivingTLS = establish(outlivingTCP);
+ const outlivingTLS = establish(outlivingTCP, 0);
function next() {
// Already connected socket
@@ -91,9 +85,4 @@ const server = tls.createServer(options, (socket) => {
const connecting = net.connect(port);
establish(connecting);
}
-});
-
-process.on('exit', () => {
- assert.strictEqual(serverConnected, 2);
- assert.strictEqual(clientConnected, 2);
-});
+}));