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:
James M Snell
2020-07-07 13:48:34 -07:00
parent cc89aac5f7
commit e3813261b8
2 changed files with 62 additions and 0 deletions

View 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();

View 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();