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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Flags: --no-warnings
'use strict';
const common = require('../common');
if (!common.hasQuic)
common.skip('missing quic');
const assert = require('assert');
const { createQuicSocket } = require('net');
const { key, cert, ca } = require('../common/quic');
const { once } = require('events');
const kALPN = 'zzz';
const idleTimeout = common.platformTimeout(1);
const options = { key, cert, ca, alpn: kALPN };
// Test idleTimeout. The test will hang and fail with a timeout
// if the idleTimeout is not working correctly.
(async () => {
const server = createQuicSocket({ server: options });
const client = createQuicSocket({ client: options });
server.on('session', common.mustCall());
await server.listen();
const session = await client.connect({
address: common.localhostIPv4,
port: server.endpoints[0].address.port,
idleTimeout,
});
await once(session, 'close');
assert(session.idleTimeout);
client.close();
server.close();
await Promise.all([
once(client, 'close'),
once(server, 'close')
]);
})().then(common.mustCall());
(async () => {
const server = createQuicSocket({ server: options });
const client = createQuicSocket({ client: options });
server.on('session', common.mustCall(async (session) => {
await once(session, 'close');
assert(session.idleTimeout);
client.close();
server.close();
await Promise.all([
once(client, 'close'),
once(server, 'close')
]);
}));
await server.listen({ idleTimeout });
const session = await client.connect({
address: common.localhostIPv4,
port: server.endpoints[0].address.port,
});
await once(session, 'close');
})().then(common.mustCall());
|