Skip to content

Commit

Permalink
test: refactor test-tls-interleave
Browse files Browse the repository at this point in the history
var -> let / const
added common.mustCall() to callback
assert.equal() -> assert.strictEqual()

PR-URL: nodejs#10017
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bchirgwin authored and Trott committed Dec 24, 2016
1 parent 0ff69b4 commit 6281a1c
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions test/parallel/test-tls-interleave.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var tls = require('tls');
const assert = require('assert');

var fs = require('fs');
const tls = require('tls');

var dir = common.fixturesDir;
var options = { key: fs.readFileSync(dir + '/test_key.pem'),
cert: fs.readFileSync(dir + '/test_cert.pem'),
ca: [ fs.readFileSync(dir + '/test_ca.pem') ] };
const fs = require('fs');

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',
'and a separate packet',
'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) {
c.write(str);
});
}).listen(0, function() {
}).listen(0, common.mustCall(function() {
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.on('readable', function() {
var data = c.read();
let data = c.read();
if (data === null)
return;

Expand All @@ -47,8 +48,9 @@ var server = tls.createServer(options, function(c) {
}
});
});
});
}));


process.on('exit', function() {
assert.equal(receivedWrites, writes.length);
assert.strictEqual(receivedWrites, writes.length);
});

0 comments on commit 6281a1c

Please sign in to comment.