mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
PR-URL: https://github.com/nodejs/node/pull/60845 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
// Flags: --expose-internals --experimental-quic --no-warnings
|
|
import { hasQuic, skip } from '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
|
|
if (!hasQuic) {
|
|
skip('QUIC is not enabled');
|
|
}
|
|
|
|
import { default as binding } from 'internal/test/binding';
|
|
const quic = binding.internalBinding('quic');
|
|
|
|
const callbacks = {
|
|
onEndpointClose() {},
|
|
onSessionNew() {},
|
|
onSessionClose() {},
|
|
onSessionDatagram() {},
|
|
onSessionDatagramStatus() {},
|
|
onSessionHandshake() {},
|
|
onSessionPathValidation() {},
|
|
onSessionTicket() {},
|
|
onSessionVersionNegotiation() {},
|
|
onStreamCreated() {},
|
|
onStreamBlocked() {},
|
|
onStreamClose() {},
|
|
onStreamReset() {},
|
|
onStreamHeaders() {},
|
|
onStreamTrailers() {},
|
|
};
|
|
// Fail if any callback is missing
|
|
for (const fn of Object.keys(callbacks)) {
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { [fn]: _, ...rest } = callbacks;
|
|
assert.throws(() => quic.setCallbacks(rest), {
|
|
code: 'ERR_MISSING_ARGS',
|
|
});
|
|
}
|
|
// If all callbacks are present it should work
|
|
quic.setCallbacks(callbacks);
|
|
|
|
// Multiple calls should just be ignored.
|
|
quic.setCallbacks(callbacks);
|