Skip to content

Commit e381326

Browse files
committed
quic: add tests confirming error handling for QuicSocket close event
PR-URL: #34247 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent cc89aac commit e381326

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Flags: --no-warnings
2+
'use strict';
3+
4+
const common = require('../common');
5+
if (!common.hasQuic)
6+
common.skip('missing quic');
7+
8+
const assert = require('assert');
9+
const {
10+
key,
11+
cert,
12+
ca,
13+
} = require('../common/quic');
14+
15+
const { createQuicSocket } = require('net');
16+
17+
const options = { key, cert, ca, alpn: 'zzz' };
18+
19+
const server = createQuicSocket({ server: options });
20+
21+
server.on('error', common.mustNotCall());
22+
23+
server.on('close', common.mustCall(async () => {
24+
throw new Error('boom');
25+
}));
26+
27+
process.on('uncaughtException', (error) => {
28+
assert.strictEqual(error.message, 'boom');
29+
});
30+
31+
server.destroy();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Flags: --no-warnings
2+
'use strict';
3+
4+
const common = require('../common');
5+
if (!common.hasQuic)
6+
common.skip('missing quic');
7+
8+
const assert = require('assert');
9+
const {
10+
key,
11+
cert,
12+
ca,
13+
} = require('../common/quic');
14+
15+
const { createQuicSocket } = require('net');
16+
17+
const options = { key, cert, ca, alpn: 'zzz' };
18+
19+
const server = createQuicSocket({ server: options });
20+
21+
server.on('error', common.mustNotCall());
22+
23+
server.on('close', common.mustCall(() => {
24+
throw new Error('boom');
25+
}));
26+
27+
process.on('uncaughtException', (error) => {
28+
assert.strictEqual(error.message, 'boom');
29+
});
30+
31+
server.destroy();

0 commit comments

Comments
 (0)