Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https: made some improvements to test-https-agent.js #8517

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions test/parallel/test-https-agent.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

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

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

var options = {
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};


var server = https.Server(options, function(req, res) {
const server = https.Server(options, function(req, res) {
res.writeHead(200);
res.end('hello world\n');
});


var responses = 0;
var N = 4;
var M = 4;
const N = 4;
const M = 4;


server.listen(0, function() {
for (var i = 0; i < N; i++) {
Expand All @@ -36,11 +37,10 @@ server.listen(0, function() {
rejectUnauthorized: false
}, function(res) {
res.resume();
console.log(res.statusCode);
if (++responses == N * M) server.close();
assert.strictEqual(res.statusCode, 200);
if (++responses === N * M) server.close();
}).on('error', function(e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to on('error', common.fail) or on('error', function(e) { throw e; }); not sure what is the preferred way, looks like both are used in other tests.

console.log(e.message);
process.exit(1);
throw e;
});
}
}, i);
Expand All @@ -49,5 +49,5 @@ server.listen(0, function() {


process.on('exit', function() {
assert.equal(N * M, responses);
assert.strictEqual(N * M, responses);
});