Browse Source

test: refactor test-tls-timeout-server-2

* Use `common.mustCall` for all callbacks
* Use `const` instead of `var`

PR-URL: https://github.com/nodejs/node/pull/9876
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Devon Rifkin 8 years ago
committed by James M Snell
parent
commit
7a38e49341
  1. 20
      test/parallel/test-tls-timeout-server-2.js

20
test/parallel/test-tls-timeout-server-2.js

@ -1,32 +1,32 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
if (!common.hasCrypto) { if (!common.hasCrypto) {
common.skip('missing crypto'); common.skip('missing crypto');
return; return;
} }
var tls = require('tls'); const tls = require('tls');
var fs = require('fs'); const fs = require('fs');
var options = { const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}; };
var server = tls.createServer(options, function(cleartext) { const server = tls.createServer(options, common.mustCall(function(cleartext) {
var s = cleartext.setTimeout(50, function() { const s = cleartext.setTimeout(50, function() {
cleartext.destroy(); cleartext.destroy();
server.close(); server.close();
}); });
assert.ok(s instanceof tls.TLSSocket); assert.ok(s instanceof tls.TLSSocket);
}); }));
server.listen(0, function() { server.listen(0, common.mustCall(function() {
tls.connect({ tls.connect({
host: '127.0.0.1', host: '127.0.0.1',
port: this.address().port, port: this.address().port,
rejectUnauthorized: false rejectUnauthorized: false
}); });
}); }));

Loading…
Cancel
Save