Skip to content

Commit 8c859d5

Browse files
Trottaddaleax
authored andcommitted
test: refactor test-tls-inception
* buffer-to-string comparison replaced with string-to-string comparison * equal -> strictEqual * var -> const * rename identifiers to avoid masking PR-URL: #9536 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 7c9e8cb commit 8c859d5

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

test/parallel/test-tls-inception.js

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
43

54
if (!common.hasCrypto) {
65
common.skip('missing crypto');
76
return;
87
}
9-
var tls = require('tls');
108

11-
var fs = require('fs');
12-
var path = require('path');
13-
var net = require('net');
9+
const assert = require('assert');
10+
const tls = require('tls');
1411

15-
var options, a, b;
12+
const fs = require('fs');
13+
const path = require('path');
14+
const net = require('net');
1615

17-
var body = Buffer.alloc(400000, 'A');
18-
19-
options = {
16+
const options = {
2017
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
2118
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
2219
};
2320

21+
const body = 'A'.repeat(40000);
22+
2423
// the "proxy" server
25-
a = tls.createServer(options, function(socket) {
26-
var options = {
24+
const a = tls.createServer(options, function(socket) {
25+
const myOptions = {
2726
host: '127.0.0.1',
2827
port: b.address().port,
2928
rejectUnauthorized: false
3029
};
31-
var dest = net.connect(options);
30+
const dest = net.connect(myOptions);
3231
dest.pipe(socket);
3332
socket.pipe(dest);
3433

@@ -38,20 +37,19 @@ a = tls.createServer(options, function(socket) {
3837
});
3938

4039
// the "target" server
41-
b = tls.createServer(options, function(socket) {
40+
const b = tls.createServer(options, function(socket) {
4241
socket.end(body);
4342
});
4443

4544
a.listen(0, function() {
4645
b.listen(0, function() {
47-
options = {
46+
const myOptions = {
4847
host: '127.0.0.1',
4948
port: a.address().port,
5049
rejectUnauthorized: false
5150
};
52-
var socket = tls.connect(options);
53-
var ssl;
54-
ssl = tls.connect({
51+
const socket = tls.connect(myOptions);
52+
const ssl = tls.connect({
5553
socket: socket,
5654
rejectUnauthorized: false
5755
});
@@ -61,7 +59,7 @@ a.listen(0, function() {
6159
buf += data;
6260
});
6361
ssl.on('end', common.mustCall(function() {
64-
assert.equal(buf, body);
62+
assert.strictEqual(buf, body);
6563
ssl.end();
6664
a.close();
6765
b.close();

0 commit comments

Comments
 (0)