forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quic: refactor/improve/document QuicSocket listening event
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/parallel/test-quic-server-listening-event-error-async.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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('session', common.mustNotCall()); | ||
|
||
server.listen(); | ||
|
||
server.on('error', common.mustCall((error) => { | ||
assert.strictEqual(error.message, 'boom'); | ||
})); | ||
|
||
server.on('ready', common.mustCall()); | ||
|
||
server.on('listening', common.mustCall(async () => { | ||
throw new Error('boom'); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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('session', common.mustNotCall()); | ||
|
||
server.listen(); | ||
|
||
server.on('error', common.mustCall((error) => { | ||
assert.strictEqual(error.message, 'boom'); | ||
})); | ||
|
||
server.on('ready', common.mustCall()); | ||
|
||
server.on('listening', common.mustCall(() => { | ||
throw new Error('boom'); | ||
})); |