summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-close-callback.js
blob: f822d8a4a92d7816b409c24ef0936e64729769e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

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

const server = http2.createServer();

let session;

const countdown = new Countdown(2, () => {
  server.close(common.mustCall());
  session.destroy();
});

server.listen(0, common.mustCall(() => {
  const client = http2.connect(`http://localhost:${server.address().port}`);
  client.on('connect', common.mustCall(() => countdown.dec()));
}));

server.on('session', common.mustCall((s) => {
  session = s;
  countdown.dec();
}));