diff options
author | Pieter Mees <pieter.mees@zentrick.com> | 2018-04-09 15:19:59 -0400 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-04-11 08:57:54 +0200 |
commit | 2852521c49da64857fa8f49aca387f1bd6b93c26 (patch) | |
tree | f5ed79e0c8d12f83605013c760e37cf9bfd464c1 /test | |
parent | f64aaba72517c4c6e7270fda3fb288e4823b865e (diff) | |
download | android-node-v8-2852521c49da64857fa8f49aca387f1bd6b93c26.tar.gz android-node-v8-2852521c49da64857fa8f49aca387f1bd6b93c26.tar.bz2 android-node-v8-2852521c49da64857fa8f49aca387f1bd6b93c26.zip |
http2: emit session connect on next tick
PR-URL: https://github.com/nodejs/node/pull/19842
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-http2-connect.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-http2-connect.js b/test/parallel/test-http2-connect.js index 9b628db5ae..252efa1229 100644 --- a/test/parallel/test-http2-connect.js +++ b/test/parallel/test-http2-connect.js @@ -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(() => { @@ -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'; |