Skip to content

Commit 8c9d0c1

Browse files
TrottFishrock123
authored andcommitted
test: refactor test-net-connect-options-ipv6
Remove unused variable and refactor checking for event firing. PR-URL: #4395 Reviewed-By: Brian White <[email protected]>
1 parent 8742090 commit 8c9d0c1

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

test/parallel/test-net-connect-options-ipv6.js

+3-18
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const net = require('net');
5-
const dns = require('dns');
65

76
if (!common.hasIPv6) {
87
console.log('1..0 # Skipped: no IPv6 support');
98
return;
109
}
1110

12-
var serverGotEnd = false;
13-
var clientGotEnd = false;
14-
1511
const hosts = common.localIPv6Hosts;
1612
var hostIdx = 0;
1713
var host = hosts[hostIdx];
1814
var localhostTries = 10;
1915

2016
const server = net.createServer({allowHalfOpen: true}, function(socket) {
2117
socket.resume();
22-
socket.on('end', function() {
23-
serverGotEnd = true;
24-
});
18+
socket.on('end', common.mustCall(function() {}));
2519
socket.end();
2620
});
2721

@@ -36,13 +30,12 @@ function tryConnect() {
3630
}, function() {
3731
console.error('client connect cb');
3832
client.resume();
39-
client.on('end', function() {
40-
clientGotEnd = true;
33+
client.on('end', common.mustCall(function() {
4134
setTimeout(function() {
4235
assert(client.writable);
4336
client.end();
4437
}, 10);
45-
});
38+
}));
4639
client.on('close', function() {
4740
server.close();
4841
});
@@ -54,18 +47,10 @@ function tryConnect() {
5447
tryConnect();
5548
else {
5649
console.log('1..0 # Skipped: no IPv6 localhost support');
57-
process.removeListener('exit', onExit);
5850
server.close();
5951
}
6052
return;
6153
}
6254
throw err;
6355
});
6456
}
65-
66-
process.on('exit', onExit);
67-
function onExit() {
68-
console.error('exit', serverGotEnd, clientGotEnd);
69-
assert(serverGotEnd);
70-
assert(clientGotEnd);
71-
}

0 commit comments

Comments
 (0)