Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
quic: check setSocket natRebinding argument, extend test
  • Loading branch information
jasnell committed Aug 17, 2020
commit ba73567a152708f9049dffd0f801c08b1bb00838
2 changes: 2 additions & 0 deletions lib/internal/quic/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,8 @@ class QuicClientSession extends QuicSession {
throw new ERR_INVALID_STATE('QuicSocket is already destroyed');
if (socket.closing)
throw new ERR_INVALID_STATE('QuicSocket is closing');
if (typeof natRebinding !== 'boolean')
throw new ERR_INVALID_ARG_TYPE('natRebinding', 'boolean', true);

await socket[kMaybeBind]();

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-quic-simple-client-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ const server = createQuicSocket({ server: options });
const s1 = req.socket;
const a1 = req.socket.endpoints[0].address;

await Promise.all([1, {}, 'test', false, null, undefined].map((i) => {
return assert.rejects(req.setSocket(i), {
code: 'ERR_INVALID_ARG_TYPE'
});
}));
await Promise.all([1, {}, 'test', null].map((i) => {
return assert.rejects(req.setSocket(req.socket, i), {
code: 'ERR_INVALID_ARG_TYPE'
});
}));

await req.setSocket(client2);

// Verify that it is using a different network endpoint
Expand Down