summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-securepair-leak.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-12-23 05:55:37 +0100
committerAnna Henningsen <anna@addaleax.net>2018-01-14 14:49:41 +0100
commit9301b8a9c69d112b98c7d60e074c845d80342b4e (patch)
treefa9f8d98fc7eca29eb6283fa303f8e71976fbb03 /test/parallel/test-tls-securepair-leak.js
parent02fef8ad5a6c0e5c1ce0d4b46aa3a762935c981c (diff)
downloadnode-new-9301b8a9c69d112b98c7d60e074c845d80342b4e.tar.gz
tls: make deprecated tls.createSecurePair() use public API
Make the deprecated `tls.createSecurePair()` method use other public APIs only (`TLSSocket` in particular). Since `tls.createSecurePair()` has been runtime-deprecated only since Node 8, it probably isn’t quite time to remove it yet, but this patch removes almost all of the code complexity that is retained by it. The API, as it is documented, is retained. However, it is very likely that some users have come to rely on parts of undocumented API of the `SecurePair` class, especially since some of the existing tests checked for those. Therefore, this should definitely be considered a breaking change. PR-URL: https://github.com/nodejs/node/pull/17882 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-securepair-leak.js')
-rw-r--r--test/parallel/test-tls-securepair-leak.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/parallel/test-tls-securepair-leak.js b/test/parallel/test-tls-securepair-leak.js
index cbc7c7dadd..4cd927d64a 100644
--- a/test/parallel/test-tls-securepair-leak.js
+++ b/test/parallel/test-tls-securepair-leak.js
@@ -7,7 +7,7 @@ if (!common.hasCrypto)
const assert = require('assert');
const { createSecureContext } = require('tls');
-const { createSecurePair } = require('_tls_legacy');
+const { createSecurePair } = require('tls');
const before = process.memoryUsage().external;
{
@@ -16,11 +16,13 @@ const before = process.memoryUsage().external;
for (let i = 0; i < 1e4; i += 1)
createSecurePair(context, false, false, false, options).destroy();
}
-global.gc();
-const after = process.memoryUsage().external;
+setImmediate(() => {
+ global.gc();
+ const after = process.memoryUsage().external;
-// It's not an exact science but a SecurePair grows .external by about 45 kB.
-// Unless AdjustAmountOfExternalAllocatedMemory() is called on destruction,
-// 10,000 instances make it grow by well over 400 MB. Allow for some slop
-// because objects like buffers also affect the external limit.
-assert(after - before < 25 << 20);
+ // It's not an exact science but a SecurePair grows .external by about 45 kB.
+ // Unless AdjustAmountOfExternalAllocatedMemory() is called on destruction,
+ // 10,000 instances make it grow by well over 400 MB. Allow for some slop
+ // because objects like buffers also affect the external limit.
+ assert(after - before < 25 << 20);
+});