Browse Source

test: refactor test-tls-interleave

var -> let / const
added common.mustCall() to callback
assert.equal() -> assert.strictEqual()

PR-URL: https://github.com/nodejs/node/pull/10017
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6.x
Brian Chirgwin 8 years ago
committed by Michaël Zasso
parent
commit
21a60912a8
  1. 34
      test/parallel/test-tls-interleave.js

34
test/parallel/test-tls-interleave.js

@ -1,37 +1,38 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) { if (!common.hasCrypto) {
common.skip('missing crypto'); common.skip('missing crypto');
return; return;
} }
var tls = require('tls'); const assert = require('assert');
var fs = require('fs'); const tls = require('tls');
var dir = common.fixturesDir; const fs = require('fs');
var options = { key: fs.readFileSync(dir + '/test_key.pem'),
cert: fs.readFileSync(dir + '/test_cert.pem'),
ca: [ fs.readFileSync(dir + '/test_ca.pem') ] };
var writes = [ const dir = common.fixturesDir;
const options = { key: fs.readFileSync(dir + '/test_key.pem'),
cert: fs.readFileSync(dir + '/test_cert.pem'),
ca: [ fs.readFileSync(dir + '/test_ca.pem') ] };
const writes = [
'some server data', 'some server data',
'and a separate packet', 'and a separate packet',
'and one more', 'and one more',
]; ];
var receivedWrites = 0; let receivedWrites = 0;
var server = tls.createServer(options, function(c) { const server = tls.createServer(options, function(c) {
writes.forEach(function(str) { writes.forEach(function(str) {
c.write(str); c.write(str);
}); });
}).listen(0, function() { }).listen(0, common.mustCall(function() {
const connectOpts = { rejectUnauthorized: false }; const connectOpts = { rejectUnauthorized: false };
var c = tls.connect(this.address().port, connectOpts, function() { const c = tls.connect(this.address().port, connectOpts, function() {
c.write('some client data'); c.write('some client data');
c.on('readable', function() { c.on('readable', function() {
var data = c.read(); let data = c.read();
if (data === null) if (data === null)
return; return;
@ -47,8 +48,9 @@ var server = tls.createServer(options, function(c) {
} }
}); });
}); });
}); }));
process.on('exit', function() { process.on('exit', function() {
assert.equal(receivedWrites, writes.length); assert.strictEqual(receivedWrites, writes.length);
}); });

Loading…
Cancel
Save