Skip to content

Commit

Permalink
quic: add tests confirming error handling for QuicSocket close event
Browse files Browse the repository at this point in the history
PR-URL: #34247
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
jasnell committed Jul 9, 2020
1 parent cc89aac commit e381326
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-quic-socket-close-event-error-async.js
@@ -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 changes: 31 additions & 0 deletions test/parallel/test-quic-socket-close-event-error.js
@@ -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();

0 comments on commit e381326

Please sign in to comment.