Skip to content

Commit

Permalink
test: use countdown utility
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshithaKP committed Mar 12, 2020
1 parent e458747 commit c6bc304
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/parallel/test-https-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

'use strict';
const common = require('../common');
const Countdown = require('../common/countdown');

if (!common.hasCrypto)
common.skip('missing crypto');
Expand All @@ -40,11 +41,14 @@ const server = https.Server(options, function(req, res) {
res.end('hello world\n');
});


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

const cd = new Countdown(N * M, () => {
server.close();
});


server.listen(0, function() {
for (let i = 0; i < N; i++) {
Expand All @@ -57,7 +61,8 @@ server.listen(0, function() {
}, function(res) {
res.resume();
assert.strictEqual(res.statusCode, 200);
if (++responses === N * M) server.close();
++responses;
cd.dec();
}).on('error', function(e) {
throw e;
});
Expand Down

0 comments on commit c6bc304

Please sign in to comment.