node/test/parallel/test-tls-connect-hints-option.js
Luigi Pinca ff8539e9e7 tls: support the hints option
Make `tls.connect()` support the `hints` option for feature parity with
`net.connect()`.

PR-URL: https://github.com/nodejs/node/pull/27816
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-25 08:50:02 +02:00

27 lines
633 B
JavaScript

'use strict';
const common = require('../common');
// This test verifies that `tls.connect()` honors the `hints` option.
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const dns = require('dns');
const tls = require('tls');
const hints = 512;
assert.notStrictEqual(hints, dns.ADDRCONFIG);
assert.notStrictEqual(hints, dns.V4MAPPED);
assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.V4MAPPED);
tls.connect({
lookup: common.mustCall((host, options) => {
assert.strictEqual(host, 'localhost');
assert.deepStrictEqual(options, { family: undefined, hints });
}),
hints
});