Skip to content

Commit c6bc304

Browse files
committed
test: use countdown utility
Refs: nodejs#32082 (comment)
1 parent e458747 commit c6bc304

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/parallel/test-https-agent.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
const Countdown = require('../common/countdown');
2425

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

43-
4444
let responses = 0;
4545
const N = 4;
4646
const M = 4;
4747

48+
const cd = new Countdown(N * M, () => {
49+
server.close();
50+
});
51+
4852

4953
server.listen(0, function() {
5054
for (let i = 0; i < N; i++) {
@@ -57,7 +61,8 @@ server.listen(0, function() {
5761
}, function(res) {
5862
res.resume();
5963
assert.strictEqual(res.statusCode, 200);
60-
if (++responses === N * M) server.close();
64+
++responses;
65+
cd.dec();
6166
}).on('error', function(e) {
6267
throw e;
6368
});

0 commit comments

Comments
 (0)