mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 08:00:26 +00:00

test/parallel/test-regress-GH-5727 assumed that one of the servers would be listening on IPv6. This breaks when the machine running the test doesn't have IPv6. This commit builds the connection key that is compared dynamically. Refs: https://github.com/nodejs/node/pull/5732 PR-URL: https://github.com/nodejs/node/pull/6319 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
31 lines
874 B
JavaScript
31 lines
874 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const invalidPort = -1 >>> 0;
|
|
const errorMessage = /"port" argument must be \>= 0 and \< 65536/;
|
|
|
|
net.Server().listen(common.PORT, function() {
|
|
const address = this.address();
|
|
const key = `${address.family.slice(-1)}:${address.address}:${common.PORT}`;
|
|
|
|
assert.equal(this._connectionKey, key);
|
|
this.close();
|
|
});
|
|
|
|
// The first argument is a configuration object
|
|
assert.throws(() => {
|
|
net.Server().listen({ port: invalidPort }, common.fail);
|
|
}, errorMessage);
|
|
|
|
// The first argument is the port, no IP given.
|
|
assert.throws(() => {
|
|
net.Server().listen(invalidPort, common.fail);
|
|
}, errorMessage);
|
|
|
|
// The first argument is the port, the second an IP.
|
|
assert.throws(() => {
|
|
net.Server().listen(invalidPort, '0.0.0.0', common.fail);
|
|
}, errorMessage);
|