diff options
author | juggernaut451 <singhjug1994@gmail.com> | 2018-03-18 01:08:36 +0530 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-10 00:41:39 +0200 |
commit | e048b1552363df05d21ef3fa0054d9ab6b801df4 (patch) | |
tree | ca9f72998b7dcd4b0450d1e438c9945582224886 /test | |
parent | 49fd9c63d21c8c42a110996a6a68bf1fdcee12b4 (diff) | |
download | android-node-v8-e048b1552363df05d21ef3fa0054d9ab6b801df4.tar.gz android-node-v8-e048b1552363df05d21ef3fa0054d9ab6b801df4.tar.bz2 android-node-v8-e048b1552363df05d21ef3fa0054d9ab6b801df4.zip |
test: refactor parallel/test-tls-delayed-attach
test: refactor parallel/test-tls-delayed-attach
Added description to the test, replace function with arrow function and
implemented common.mustCall
PR-URL: https://github.com/nodejs/node/pull/19421
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-tls-delayed-attach.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/test/parallel/test-tls-delayed-attach.js b/test/parallel/test-tls-delayed-attach.js index fc5eaaa884..b756db2d67 100644 --- a/test/parallel/test-tls-delayed-attach.js +++ b/test/parallel/test-tls-delayed-attach.js @@ -24,6 +24,12 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +// This test tries to confirm that a TLS Socket will work as expected even if it +// is created after the original socket has received some data. +// +// Ref: https://github.com/nodejs/node-v0.x-archive/issues/6940 +// Ref: https://github.com/nodejs/node-v0.x-archive/pull/6950 + const fixtures = require('../common/fixtures'); const assert = require('assert'); const tls = require('tls'); @@ -37,30 +43,30 @@ const options = { cert: fixtures.readKey('agent1-cert.pem') }; -const server = net.createServer(function(c) { +const server = net.createServer(common.mustCall((c) => { setTimeout(function() { const s = new tls.TLSSocket(c, { isServer: true, secureContext: tls.createSecureContext(options) }); - s.on('data', function(chunk) { + s.on('data', (chunk) => { received += chunk; }); - s.on('end', function() { + s.on('end', common.mustCall(() => { server.close(); s.destroy(); - }); + })); }, 200); -}).listen(0, function() { - const c = tls.connect(this.address().port, { +})).listen(0, common.mustCall(() => { + const c = tls.connect(server.address().port, { rejectUnauthorized: false - }, function() { + }, () => { c.end(sent); }); -}); +})); -process.on('exit', function() { +process.on('exit', () => { assert.strictEqual(received, sent); }); |