summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-connect-hints-option.js
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2019-05-22 10:27:16 +0200
committerLuigi Pinca <luigipinca@gmail.com>2019-05-25 08:50:02 +0200
commitff8539e9e747db61a2adac6d4498ef4ee5826900 (patch)
tree1ba65777ba00431ca1828d996357b265a307ea17 /test/parallel/test-tls-connect-hints-option.js
parent7d5cf572f30d05b0b8946fa69a64c4db4a2138e0 (diff)
downloadandroid-node-v8-ff8539e9e747db61a2adac6d4498ef4ee5826900.tar.gz
android-node-v8-ff8539e9e747db61a2adac6d4498ef4ee5826900.tar.bz2
android-node-v8-ff8539e9e747db61a2adac6d4498ef4ee5826900.zip
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>
Diffstat (limited to 'test/parallel/test-tls-connect-hints-option.js')
-rw-r--r--test/parallel/test-tls-connect-hints-option.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parallel/test-tls-connect-hints-option.js b/test/parallel/test-tls-connect-hints-option.js
new file mode 100644
index 0000000000..fd155c9659
--- /dev/null
+++ b/test/parallel/test-tls-connect-hints-option.js
@@ -0,0 +1,26 @@
+'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
+});