mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
quic: add tests confirming error handling for QuicSocket close event
PR-URL: https://github.com/nodejs/node/pull/34247 Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
31
test/parallel/test-quic-socket-close-event-error-async.js
Normal file
31
test/parallel/test-quic-socket-close-event-error-async.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// Flags: --no-warnings
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasQuic)
|
||||
common.skip('missing quic');
|
||||
|
||||
const assert = require('assert');
|
||||
const {
|
||||
key,
|
||||
cert,
|
||||
ca,
|
||||
} = require('../common/quic');
|
||||
|
||||
const { createQuicSocket } = require('net');
|
||||
|
||||
const options = { key, cert, ca, alpn: 'zzz' };
|
||||
|
||||
const server = createQuicSocket({ server: options });
|
||||
|
||||
server.on('error', common.mustNotCall());
|
||||
|
||||
server.on('close', common.mustCall(async () => {
|
||||
throw new Error('boom');
|
||||
}));
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
assert.strictEqual(error.message, 'boom');
|
||||
});
|
||||
|
||||
server.destroy();
|
||||
31
test/parallel/test-quic-socket-close-event-error.js
Normal file
31
test/parallel/test-quic-socket-close-event-error.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// Flags: --no-warnings
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasQuic)
|
||||
common.skip('missing quic');
|
||||
|
||||
const assert = require('assert');
|
||||
const {
|
||||
key,
|
||||
cert,
|
||||
ca,
|
||||
} = require('../common/quic');
|
||||
|
||||
const { createQuicSocket } = require('net');
|
||||
|
||||
const options = { key, cert, ca, alpn: 'zzz' };
|
||||
|
||||
const server = createQuicSocket({ server: options });
|
||||
|
||||
server.on('error', common.mustNotCall());
|
||||
|
||||
server.on('close', common.mustCall(() => {
|
||||
throw new Error('boom');
|
||||
}));
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
assert.strictEqual(error.message, 'boom');
|
||||
});
|
||||
|
||||
server.destroy();
|
||||
Reference in New Issue
Block a user