Skip to content

Commit

Permalink
test: add test for http2 session connect callback on already connecte…
Browse files Browse the repository at this point in the history
…d socket
  • Loading branch information
pietermees committed Apr 9, 2018
1 parent 29036ab commit e9f09bd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/parallel/test-http2-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const { mustCall, hasCrypto, skip, expectsError } = require('../common');
if (!hasCrypto)
skip('missing crypto');
const { createServer, connect } = require('http2');
const { connect: netConnect } = require('net');

// check for session connect callback and event
{
const server = createServer();
server.listen(0, mustCall(() => {
Expand All @@ -30,6 +33,28 @@ const { createServer, connect } = require('http2');
}));
}

// check for session connect callback on already connected socket
{
const server = createServer();
server.listen(0, mustCall(() => {
const { port } = server.address();

const onSocketConnect = () => {
const authority = `http://localhost:${port}`;
const createConnection = mustCall(() => socket);
const options = { createConnection };
connect(authority, options, mustCall(onSessionConnect));
};

const onSessionConnect = (session) => {
session.close();
server.close();
};

const socket = netConnect(port, mustCall(onSocketConnect));
}));
}

// check for https as protocol
{
const authority = 'https://localhost';
Expand Down

0 comments on commit e9f09bd

Please sign in to comment.