Skip to content

Commit e9f09bd

Browse files
committed
test: add test for http2 session connect callback on already connected socket
1 parent 29036ab commit e9f09bd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/parallel/test-http2-connect.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const { mustCall, hasCrypto, skip, expectsError } = require('../common');
44
if (!hasCrypto)
55
skip('missing crypto');
66
const { createServer, connect } = require('http2');
7+
const { connect: netConnect } = require('net');
8+
9+
// check for session connect callback and event
710
{
811
const server = createServer();
912
server.listen(0, mustCall(() => {
@@ -30,6 +33,28 @@ const { createServer, connect } = require('http2');
3033
}));
3134
}
3235

36+
// check for session connect callback on already connected socket
37+
{
38+
const server = createServer();
39+
server.listen(0, mustCall(() => {
40+
const { port } = server.address();
41+
42+
const onSocketConnect = () => {
43+
const authority = `http://localhost:${port}`;
44+
const createConnection = mustCall(() => socket);
45+
const options = { createConnection };
46+
connect(authority, options, mustCall(onSessionConnect));
47+
};
48+
49+
const onSessionConnect = (session) => {
50+
session.close();
51+
server.close();
52+
};
53+
54+
const socket = netConnect(port, mustCall(onSocketConnect));
55+
}));
56+
}
57+
3358
// check for https as protocol
3459
{
3560
const authority = 'https://localhost';

0 commit comments

Comments
 (0)