summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2017-11-20 17:18:40 +0100
committerAnna Henningsen <anna@addaleax.net>2017-11-28 02:50:54 +0100
commitb44efded8481877c1ec782112b9ae4c4fec37463 (patch)
tree7c967e36bc1d718c513965b619f65e7f4f9da95a /test
parent91d131210c2d7887d8625d34c1008a3d423cf86b (diff)
downloadandroid-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.tar.gz
android-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.tar.bz2
android-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.zip
async_wrap: add provider types for net server
Adds `TCPSERVERWRAP` and `PIPESERVERWRAP` as provider types. This makes it possible to distinguish servers from connections. PR-URL: https://github.com/nodejs/node/pull/17157 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r--test/async-hooks/test-graph.pipeconnect.js10
-rw-r--r--test/async-hooks/test-graph.shutdown.js12
-rw-r--r--test/async-hooks/test-graph.tcp.js10
-rw-r--r--test/async-hooks/test-graph.tls-write.js18
-rw-r--r--test/async-hooks/test-pipeconnectwrap.js44
-rw-r--r--test/async-hooks/test-tcpwrap.js83
-rw-r--r--test/common/index.js4
-rw-r--r--test/parallel/test-handle-wrap-isrefed.js4
-rw-r--r--test/parallel/test-net-connect-options-fd.js4
-rw-r--r--test/parallel/test-net-server-listen-handle.js8
-rw-r--r--test/parallel/test-process-wrap.js4
-rw-r--r--test/parallel/test-tcp-wrap-connect.js4
-rw-r--r--test/parallel/test-tcp-wrap-listen.js4
-rw-r--r--test/parallel/test-tcp-wrap.js4
-rw-r--r--test/sequential/test-async-wrap-getasyncid.js30
15 files changed, 128 insertions, 115 deletions
diff --git a/test/async-hooks/test-graph.pipeconnect.js b/test/async-hooks/test-graph.pipeconnect.js
index a3486521d5..b3ea5c6e42 100644
--- a/test/async-hooks/test-graph.pipeconnect.js
+++ b/test/async-hooks/test-graph.pipeconnect.js
@@ -28,11 +28,11 @@ function onexit() {
hooks.disable();
verifyGraph(
hooks,
- [ { type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null },
- { type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipe:1' },
+ [ { type: 'PIPESERVERWRAP', id: 'pipeserver:1', triggerAsyncId: null },
+ { type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: 'pipeserver:1' },
{ type: 'PIPECONNECTWRAP', id: 'pipeconnect:1',
- triggerAsyncId: 'pipe:2' },
- { type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: 'pipe:1' },
- { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:3' } ]
+ triggerAsyncId: 'pipe:1' },
+ { type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipeserver:1' },
+ { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ]
);
}
diff --git a/test/async-hooks/test-graph.shutdown.js b/test/async-hooks/test-graph.shutdown.js
index 136f018212..f4f077c0dd 100644
--- a/test/async-hooks/test-graph.shutdown.js
+++ b/test/async-hooks/test-graph.shutdown.js
@@ -34,13 +34,13 @@ function onexit() {
hooks.disable();
verifyGraph(
hooks,
- [ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: null },
- { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcp:1' },
+ [ { type: 'TCPSERVERWRAP', id: 'tcpserver:1', triggerAsyncId: null },
+ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: 'tcpserver:1' },
{ type: 'GETADDRINFOREQWRAP',
- id: 'getaddrinforeq:1', triggerAsyncId: 'tcp:2' },
+ id: 'getaddrinforeq:1', triggerAsyncId: 'tcp:1' },
{ type: 'TCPCONNECTWRAP',
- id: 'tcpconnect:1', triggerAsyncId: 'tcp:2' },
- { type: 'TCPWRAP', id: 'tcp:3', triggerAsyncId: 'tcp:1' },
- { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:3' } ]
+ id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
+ { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
+ { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ]
);
}
diff --git a/test/async-hooks/test-graph.tcp.js b/test/async-hooks/test-graph.tcp.js
index 2e0b387cbe..c2458ef1de 100644
--- a/test/async-hooks/test-graph.tcp.js
+++ b/test/async-hooks/test-graph.tcp.js
@@ -38,11 +38,11 @@ function onexit() {
verifyGraph(
hooks,
- [ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: null },
- { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: null },
+ [ { type: 'TCPSERVERWRAP', id: 'tcpserver:1', triggerAsyncId: null },
+ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: null },
{ type: 'TCPCONNECTWRAP',
- id: 'tcpconnect:1', triggerAsyncId: 'tcp:2' },
- { type: 'TCPWRAP', id: 'tcp:3', triggerAsyncId: 'tcp:1' },
- { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:3' } ]
+ id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
+ { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
+ { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ]
);
}
diff --git a/test/async-hooks/test-graph.tls-write.js b/test/async-hooks/test-graph.tls-write.js
index 4ba264c808..0c725d153d 100644
--- a/test/async-hooks/test-graph.tls-write.js
+++ b/test/async-hooks/test-graph.tls-write.js
@@ -55,21 +55,21 @@ function onexit() {
verifyGraph(
hooks,
- [ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: null },
- { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcp:1' },
- { type: 'TLSWRAP', id: 'tls:1', triggerAsyncId: 'tcp:1' },
+ [ { type: 'TCPSERVERWRAP', id: 'tcpserver:1', triggerAsyncId: null },
+ { type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: 'tcpserver:1' },
+ { type: 'TLSWRAP', id: 'tls:1', triggerAsyncId: 'tcpserver:1' },
{ type: 'GETADDRINFOREQWRAP',
id: 'getaddrinforeq:1', triggerAsyncId: 'tls:1' },
{ type: 'TCPCONNECTWRAP',
- id: 'tcpconnect:1', triggerAsyncId: 'tcp:2' },
+ id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'WRITEWRAP', id: 'write:1', triggerAsyncId: 'tcpconnect:1' },
- { type: 'TCPWRAP', id: 'tcp:3', triggerAsyncId: 'tcp:1' },
- { type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcp:1' },
- { type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: 'tcp:1' },
+ { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
+ { type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' },
+ { type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: 'tcpserver:1' },
{ type: 'WRITEWRAP', id: 'write:2', triggerAsyncId: null },
{ type: 'WRITEWRAP', id: 'write:3', triggerAsyncId: null },
{ type: 'WRITEWRAP', id: 'write:4', triggerAsyncId: null },
- { type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' },
- { type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:3' } ]
+ { type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:1' },
+ { type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:2' } ]
);
}
diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js
index bcab601d05..81a5abd42a 100644
--- a/test/async-hooks/test-pipeconnectwrap.js
+++ b/test/async-hooks/test-pipeconnectwrap.js
@@ -12,7 +12,8 @@ common.refreshTmpDir();
const hooks = initHooks();
hooks.enable();
-let pipe1, pipe2, pipe3;
+let pipe1, pipe2;
+let pipeserver;
let pipeconnect;
net.createServer(common.mustCall(function(c) {
@@ -22,27 +23,27 @@ net.createServer(common.mustCall(function(c) {
})).listen(common.PIPE, common.mustCall(onlisten));
function onlisten() {
- let pipes = hooks.activitiesOfTypes('PIPEWRAP');
+ const pipeservers = hooks.activitiesOfTypes('PIPESERVERWRAP');
let pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP');
- assert.strictEqual(pipes.length, 1);
+ assert.strictEqual(pipeservers.length, 1);
assert.strictEqual(pipeconnects.length, 0);
net.connect(common.PIPE,
common.mustCall(maybeOnconnect.bind(null, 'client')));
- pipes = hooks.activitiesOfTypes('PIPEWRAP');
+ const pipes = hooks.activitiesOfTypes('PIPEWRAP');
pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP');
- assert.strictEqual(pipes.length, 2);
+ assert.strictEqual(pipes.length, 1);
assert.strictEqual(pipeconnects.length, 1);
+ pipeserver = pipeservers[0];
pipe1 = pipes[0];
- pipe2 = pipes[1];
pipeconnect = pipeconnects[0];
+ assert.strictEqual(pipeserver.type, 'PIPESERVERWRAP');
assert.strictEqual(pipe1.type, 'PIPEWRAP');
- assert.strictEqual(pipe2.type, 'PIPEWRAP');
assert.strictEqual(pipeconnect.type, 'PIPECONNECTWRAP');
- for (const a of [ pipe1, pipe2, pipeconnect ]) {
+ for (const a of [ pipeserver, pipe1, pipeconnect ]) {
assert.strictEqual(typeof a.uid, 'number');
assert.strictEqual(typeof a.triggerAsyncId, 'number');
checkInvocations(a, { init: 1 }, 'after net.connect');
@@ -60,18 +61,18 @@ function maybeOnconnect(source) {
const pipes = hooks.activitiesOfTypes('PIPEWRAP');
const pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP');
- assert.strictEqual(pipes.length, 3);
+ assert.strictEqual(pipes.length, 2);
assert.strictEqual(pipeconnects.length, 1);
- pipe3 = pipes[2];
- assert.strictEqual(typeof pipe3.uid, 'number');
- assert.strictEqual(typeof pipe3.triggerAsyncId, 'number');
+ pipe2 = pipes[1];
+ assert.strictEqual(typeof pipe2.uid, 'number');
+ assert.strictEqual(typeof pipe2.triggerAsyncId, 'number');
- checkInvocations(pipe1, { init: 1, before: 1, after: 1 },
- 'pipe1, client connected');
- checkInvocations(pipe2, { init: 1 }, 'pipe2, client connected');
+ checkInvocations(pipeserver, { init: 1, before: 1, after: 1 },
+ 'pipeserver, client connected');
+ checkInvocations(pipe1, { init: 1 }, 'pipe1, client connected');
checkInvocations(pipeconnect, { init: 1, before: 1 },
'pipeconnect, client connected');
- checkInvocations(pipe3, { init: 1 }, 'pipe3, client connected');
+ checkInvocations(pipe2, { init: 1 }, 'pipe2, client connected');
tick(5);
}
@@ -80,14 +81,15 @@ process.on('exit', onexit);
function onexit() {
hooks.disable();
hooks.sanityCheck('PIPEWRAP');
+ hooks.sanityCheck('PIPESERVERWRAP');
hooks.sanityCheck('PIPECONNECTWRAP');
// TODO(thlorenz) why have some of those 'before' and 'after' called twice
- checkInvocations(pipe1, { init: 1, before: 1, after: 1, destroy: 1 },
+ checkInvocations(pipeserver, { init: 1, before: 1, after: 1, destroy: 1 },
+ 'pipeserver, process exiting');
+ checkInvocations(pipe1, { init: 1, before: 2, after: 2, destroy: 1 },
'pipe1, process exiting');
- checkInvocations(pipe2, { init: 1, before: 2, after: 2, destroy: 1 },
- 'pipe2, process exiting');
checkInvocations(pipeconnect, { init: 1, before: 1, after: 1, destroy: 1 },
'pipeconnect, process exiting');
- checkInvocations(pipe3, { init: 1, before: 2, after: 2, destroy: 1 },
- 'pipe3, process exiting');
+ checkInvocations(pipe2, { init: 1, before: 2, after: 2, destroy: 1 },
+ 'pipe2, process exiting');
}
diff --git a/test/async-hooks/test-tcpwrap.js b/test/async-hooks/test-tcpwrap.js
index 4693e730bf..e7d879caf7 100644
--- a/test/async-hooks/test-tcpwrap.js
+++ b/test/async-hooks/test-tcpwrap.js
@@ -11,7 +11,8 @@ const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');
const net = require('net');
-let tcp1, tcp2, tcp3;
+let tcp1, tcp2;
+let tcpserver;
let tcpconnect;
const hooks = initHooks();
@@ -24,15 +25,15 @@ const server = net
// Calling server.listen creates a TCPWRAP synchronously
{
server.listen(common.PORT);
- const tcps = hooks.activitiesOfTypes('TCPWRAP');
+ const tcpsservers = hooks.activitiesOfTypes('TCPSERVERWRAP');
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
- assert.strictEqual(tcps.length, 1);
+ assert.strictEqual(tcpsservers.length, 1);
assert.strictEqual(tcpconnects.length, 0);
- tcp1 = tcps[0];
- assert.strictEqual(tcp1.type, 'TCPWRAP');
- assert.strictEqual(typeof tcp1.uid, 'number');
- assert.strictEqual(typeof tcp1.triggerAsyncId, 'number');
- checkInvocations(tcp1, { init: 1 }, 'when calling server.listen');
+ tcpserver = tcpsservers[0];
+ assert.strictEqual(tcpserver.type, 'TCPSERVERWRAP');
+ assert.strictEqual(typeof tcpserver.uid, 'number');
+ assert.strictEqual(typeof tcpserver.triggerAsyncId, 'number');
+ checkInvocations(tcpserver, { init: 1 }, 'when calling server.listen');
}
// Calling net.connect creates another TCPWRAP synchronously
@@ -41,24 +42,25 @@ const server = net
{ port: server.address().port, host: '::1' },
common.mustCall(onconnected));
const tcps = hooks.activitiesOfTypes('TCPWRAP');
- assert.strictEqual(tcps.length, 2);
+ assert.strictEqual(tcps.length, 1);
process.nextTick(() => {
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
assert.strictEqual(tcpconnects.length, 1);
});
- tcp2 = tcps[1];
- assert.strictEqual(tcps.length, 2);
- assert.strictEqual(tcp2.type, 'TCPWRAP');
- assert.strictEqual(typeof tcp2.uid, 'number');
- assert.strictEqual(typeof tcp2.triggerAsyncId, 'number');
+ tcp1 = tcps[0];
+ assert.strictEqual(tcps.length, 1);
+ assert.strictEqual(tcp1.type, 'TCPWRAP');
+ assert.strictEqual(typeof tcp1.uid, 'number');
+ assert.strictEqual(typeof tcp1.triggerAsyncId, 'number');
+ checkInvocations(tcpserver, { init: 1 },
+ 'tcpserver when client is connecting');
checkInvocations(tcp1, { init: 1 }, 'tcp1 when client is connecting');
- checkInvocations(tcp2, { init: 1 }, 'tcp2 when client is connecting');
}
function onlistening() {
- assert.strictEqual(hooks.activitiesOfTypes('TCPWRAP').length, 2);
+ assert.strictEqual(hooks.activitiesOfTypes('TCPWRAP').length, 1);
}
// Depending on timing we see client: onconnected or server: onconnection first
@@ -99,8 +101,8 @@ function onconnected() {
const expected = serverConnected ?
{ init: 1, before: 1, after: 1 } :
{ init: 1 };
- checkInvocations(tcp1, expected, 'tcp1 when client connects');
- checkInvocations(tcp2, { init: 1 }, 'tcp2 when client connects');
+ checkInvocations(tcpserver, expected, 'tcpserver when client connects');
+ checkInvocations(tcp1, { init: 1 }, 'tcp1 when client connects');
}
function onconnection(c) {
@@ -109,34 +111,35 @@ function onconnection(c) {
const tcps = hooks.activitiesOfTypes([ 'TCPWRAP' ]);
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
- assert.strictEqual(tcps.length, 3);
+ assert.strictEqual(tcps.length, 2);
assert.strictEqual(tcpconnects.length, 1);
- tcp3 = tcps[2];
- assert.strictEqual(tcp3.type, 'TCPWRAP');
- assert.strictEqual(typeof tcp3.uid, 'number');
- assert.strictEqual(typeof tcp3.triggerAsyncId, 'number');
+ tcp2 = tcps[1];
+ assert.strictEqual(tcp2.type, 'TCPWRAP');
+ assert.strictEqual(typeof tcp2.uid, 'number');
+ assert.strictEqual(typeof tcp2.triggerAsyncId, 'number');
- checkInvocations(tcp1, { init: 1, before: 1 },
- 'tcp1 when server receives connection');
+ checkInvocations(tcpserver, { init: 1, before: 1 },
+ 'tcpserver when server receives connection');
+ checkInvocations(tcp1, { init: 1 }, 'tcp1 when server receives connection');
checkInvocations(tcp2, { init: 1 }, 'tcp2 when server receives connection');
- checkInvocations(tcp3, { init: 1 }, 'tcp3 when server receives connection');
c.end();
this.close(common.mustCall(onserverClosed));
}
function onserverClosed() {
- checkInvocations(tcp1, { init: 1, before: 1, after: 1, destroy: 1 },
- 'tcp1 when server is closed');
+ checkInvocations(tcpserver, { init: 1, before: 1, after: 1, destroy: 1 },
+ 'tcpserver when server is closed');
setImmediate(() => {
- checkInvocations(tcp2, { init: 1, before: 2, after: 2, destroy: 1 },
- 'tcp2 after server is closed');
+ checkInvocations(tcp1, { init: 1, before: 2, after: 2, destroy: 1 },
+ 'tcp1 after server is closed');
});
- checkInvocations(tcp3, { init: 1, before: 1, after: 1 },
- 'tcp3 synchronously when server is closed');
+ checkInvocations(tcp2, { init: 1, before: 1, after: 1 },
+ 'tcp2 synchronously when server is closed');
+
tick(2, () => {
- checkInvocations(tcp3, { init: 1, before: 2, after: 2, destroy: 1 },
- 'tcp3 when server is closed');
+ checkInvocations(tcp2, { init: 1, before: 2, after: 2, destroy: 1 },
+ 'tcp2 when server is closed');
checkInvocations(tcpconnect, { init: 1, before: 1, after: 1, destroy: 1 },
'tcpconnect when server is closed');
});
@@ -146,17 +149,17 @@ process.on('exit', onexit);
function onexit() {
hooks.disable();
- hooks.sanityCheck([ 'TCPWRAP', 'TCPCONNECTWRAP' ]);
+ hooks.sanityCheck([ 'TCPWRAP', 'TCPSERVERWRAP', 'TCPCONNECTWRAP' ]);
- checkInvocations(tcp1, { init: 1, before: 1, after: 1, destroy: 1 },
- 'tcp1 when process exits');
+ checkInvocations(tcpserver, { init: 1, before: 1, after: 1, destroy: 1 },
+ 'tcpserver when process exits');
+ checkInvocations(
+ tcp1, { init: 1, before: 2, after: 2, destroy: 1 },
+ 'tcp1 when process exits');
checkInvocations(
tcp2, { init: 1, before: 2, after: 2, destroy: 1 },
'tcp2 when process exits');
checkInvocations(
- tcp3, { init: 1, before: 2, after: 2, destroy: 1 },
- 'tcp3 when process exits');
- checkInvocations(
tcpconnect, { init: 1, before: 1, after: 1, destroy: 1 },
'tcpconnect when process exits');
}
diff --git a/test/common/index.js b/test/common/index.js
index 838c7b60da..ee2de37bb7 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -524,8 +524,8 @@ function _mustCallInner(fn, criteria = 1, field) {
}
exports.hasMultiLocalhost = function hasMultiLocalhost() {
- const TCP = process.binding('tcp_wrap').TCP;
- const t = new TCP();
+ const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
+ const t = new TCP(TCPConstants.SOCKET);
const ret = t.bind('127.0.0.2', exports.PORT);
t.close();
return ret === 0;
diff --git a/test/parallel/test-handle-wrap-isrefed.js b/test/parallel/test-handle-wrap-isrefed.js
index b4fccc0529..e1301b57f6 100644
--- a/test/parallel/test-handle-wrap-isrefed.js
+++ b/test/parallel/test-handle-wrap-isrefed.js
@@ -66,8 +66,8 @@ const dgram = require('dgram');
// pipe
{
- const Pipe = process.binding('pipe_wrap').Pipe;
- const handle = new Pipe();
+ const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
+ const handle = new Pipe(PipeConstants.SOCKET);
strictEqual(Object.getPrototypeOf(handle).hasOwnProperty('hasRef'),
true, 'pipe_wrap: hasRef() missing');
strictEqual(handle.hasRef(),
diff --git a/test/parallel/test-net-connect-options-fd.js b/test/parallel/test-net-connect-options-fd.js
index e0872cf7c5..1ffc92257c 100644
--- a/test/parallel/test-net-connect-options-fd.js
+++ b/test/parallel/test-net-connect-options-fd.js
@@ -6,7 +6,7 @@ if (common.isWindows)
const assert = require('assert');
const net = require('net');
const path = require('path');
-const Pipe = process.binding('pipe_wrap').Pipe;
+const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
common.refreshTmpDir();
@@ -71,7 +71,7 @@ const forAllClients = (cb) => common.mustCall(cb, CLIENT_VARIANTS);
})
.listen({ path: serverPath }, common.mustCall(function serverOnListen() {
const getSocketOpt = (index) => {
- const handle = new Pipe();
+ const handle = new Pipe(PipeConstants.SOCKET);
const err = handle.bind(`${prefix}-client-${socketCounter++}`);
assert(err >= 0, String(err));
assert.notStrictEqual(handle.fd, -1);
diff --git a/test/parallel/test-net-server-listen-handle.js b/test/parallel/test-net-server-listen-handle.js
index db8e639f94..de1f1ca375 100644
--- a/test/parallel/test-net-server-listen-handle.js
+++ b/test/parallel/test-net-server-listen-handle.js
@@ -5,8 +5,8 @@ const assert = require('assert');
const net = require('net');
const fs = require('fs');
const uv = process.binding('uv');
-const TCP = process.binding('tcp_wrap').TCP;
-const Pipe = process.binding('pipe_wrap').Pipe;
+const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
+const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
common.refreshTmpDir();
@@ -36,12 +36,12 @@ function randomPipePath() {
function randomHandle(type) {
let handle, errno, handleName;
if (type === 'tcp') {
- handle = new TCP();
+ handle = new TCP(TCPConstants.SOCKET);
errno = handle.bind('0.0.0.0', 0);
handleName = 'arbitrary tcp port';
} else {
const path = randomPipePath();
- handle = new Pipe();
+ handle = new Pipe(PipeConstants.SOCKET);
errno = handle.bind(path);
handleName = `pipe ${path}`;
}
diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js
index 5601328eef..b3cca47c46 100644
--- a/test/parallel/test-process-wrap.js
+++ b/test/parallel/test-process-wrap.js
@@ -23,8 +23,8 @@
require('../common');
const assert = require('assert');
const Process = process.binding('process_wrap').Process;
-const Pipe = process.binding('pipe_wrap').Pipe;
-const pipe = new Pipe();
+const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
+const pipe = new Pipe(PipeConstants.SOCKET);
const p = new Process();
let processExited = false;
diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js
index 77f9814db2..c2746bca64 100644
--- a/test/parallel/test-tcp-wrap-connect.js
+++ b/test/parallel/test-tcp-wrap-connect.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
const assert = require('assert');
-const TCP = process.binding('tcp_wrap').TCP;
+const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
function makeConnection() {
- const client = new TCP();
+ const client = new TCP(TCPConstants.SOCKET);
const req = new TCPConnectWrap();
const err = client.connect(req, '127.0.0.1', this.address().port);
diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js
index 7502969c96..8203a4771b 100644
--- a/test/parallel/test-tcp-wrap-listen.js
+++ b/test/parallel/test-tcp-wrap-listen.js
@@ -2,10 +2,10 @@
const common = require('../common');
const assert = require('assert');
-const TCP = process.binding('tcp_wrap').TCP;
+const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const WriteWrap = process.binding('stream_wrap').WriteWrap;
-const server = new TCP();
+const server = new TCP(TCPConstants.SOCKET);
const r = server.bind('0.0.0.0', 0);
assert.strictEqual(0, r);
diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js
index 96ddd5bfd3..36a45d7606 100644
--- a/test/parallel/test-tcp-wrap.js
+++ b/test/parallel/test-tcp-wrap.js
@@ -23,10 +23,10 @@
require('../common');
const assert = require('assert');
-const TCP = process.binding('tcp_wrap').TCP;
+const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const uv = process.binding('uv');
-const handle = new TCP();
+const handle = new TCP(TCPConstants.SOCKET);
// Should be able to bind to the port
let err = handle.bind('0.0.0.0', 0);
diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js
index d6a7085d89..bd2b3254f0 100644
--- a/test/sequential/test-async-wrap-getasyncid.js
+++ b/test/sequential/test-async-wrap-getasyncid.js
@@ -138,19 +138,27 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
testInitialized(new Gzip()._handle, 'Zlib');
}
-
{
const binding = process.binding('pipe_wrap');
- const handle = new binding.Pipe();
+ const handle = new binding.Pipe(binding.constants.IPC);
testInitialized(handle, 'Pipe');
- const req = new binding.PipeConnectWrap();
- testUninitialized(req, 'PipeConnectWrap');
- req.address = common.PIPE;
- req.oncomplete = common.mustCall(() => handle.close());
- handle.connect(req, req.address, req.oncomplete);
- testInitialized(req, 'PipeConnectWrap');
}
+{
+ const server = net.createServer(common.mustCall((socket) => {
+ server.close();
+ })).listen(common.PIPE, common.mustCall(() => {
+ const binding = process.binding('pipe_wrap');
+ const handle = new binding.Pipe(binding.constants.SOCKET);
+ testInitialized(handle, 'Pipe');
+ const req = new binding.PipeConnectWrap();
+ testUninitialized(req, 'PipeConnectWrap');
+ req.address = common.PIPE;
+ req.oncomplete = common.mustCall(() => handle.close());
+ handle.connect(req, req.address, req.oncomplete);
+ testInitialized(req, 'PipeConnectWrap');
+ }));
+}
{
const Process = process.binding('process_wrap').Process;
@@ -179,7 +187,7 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
});
socket.resume();
})).listen(0, common.localhostIPv4, common.mustCall(() => {
- const handle = new tcp_wrap.TCP();
+ const handle = new tcp_wrap.TCP(tcp_wrap.constants.SOCKET);
const req = new tcp_wrap.TCPConnectWrap();
const sreq = new stream_wrap.ShutdownWrap();
const wreq = new stream_wrap.WriteWrap();
@@ -221,8 +229,8 @@ if (common.hasCrypto) { // eslint-disable-line crypto-check
if (common.hasCrypto) { // eslint-disable-line crypto-check
- const TCP = process.binding('tcp_wrap').TCP;
- const tcp = new TCP();
+ const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
+ const tcp = new TCP(TCPConstants.SOCKET);
const ca = fixtures.readSync('test_ca.pem', 'ascii');
const cert = fixtures.readSync('test_cert.pem', 'ascii');