Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
adding back assert.strictEqual to track both requests are completed b…
…efore server is closed. Adding common.mustCall to checkCertReq.
  • Loading branch information
weewey committed May 2, 2017
commit 047045ceee683456a2ad2ae5865d14ca4bb54fb2
21 changes: 18 additions & 3 deletions test/parallel/test-https-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ const options = {
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};

const tests = 2;
let successful = 0;

const testSucceeded = function() {
successful = successful + 1;
if (successful === tests) {
server.close();
}
};

const body = 'hello world\n';

const serverCallback = common.mustCall(function(req, res) {
Expand Down Expand Up @@ -67,6 +77,7 @@ server.listen(0, common.mustCall(() => {

res.on('end', common.mustCall(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The enclosing https.request() and server.listen() callbacks need to have common.mustCall() too, or there is no guarantee that this will execute.

assert.strictEqual(responseBody, body);
testSucceeded();
}));
}));
req.end();
Expand Down Expand Up @@ -94,8 +105,12 @@ server.listen(0, common.mustCall(() => {
});
checkCertReq.end();

checkCertReq.on('error', function(e) {
checkCertReq.on('error', common.mustCall((e) => {
assert.strictEqual(e.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
server.close();
});
testSucceeded();
}));
}));

process.on('exit', function() {
assert.strictEqual(successful, tests);
});