Files
node/test/parallel/test-heapdump-http2.js
T
Daniel Bevenius a6ab19a96a test: move require of http2 to after crypto check
Currently when configured without-ssl test-heapdump-http2.js will fail
with a missing crypto message.
This commit moves the require of http2 to after the crypto check.

PR-URL: https://github.com/nodejs/node/pull/22148
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-08-15 20:23:17 +10:00

83 lines
1.9 KiB
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const { recordState } = require('../common/heap');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
{
const state = recordState();
state.validateSnapshotNodes('Http2Session', []);
state.validateSnapshotNodes('Http2Stream', []);
}
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respondWithFile(__filename);
});
server.listen(0, () => {
const client = http2.connect(`http://localhost:${server.address().port}`);
const req = client.request();
req.on('response', common.mustCall(() => {
const state = recordState();
// `Node / Http2Stream` (C++) -> Http2Stream (JS)
state.validateSnapshotNodes('Http2Stream', [
{
children: [
{ name: 'Http2Stream' }
]
},
], { loose: true });
// `Node / FileHandle` (C++) -> FileHandle (JS)
state.validateSnapshotNodes('FileHandle', [
{
children: [
{ name: 'FileHandle' }
]
}
]);
state.validateSnapshotNodes('TCPSocketWrap', [
{
children: [
{ name: 'TCP' }
]
}
], { loose: true });
state.validateSnapshotNodes('TCPServerWrap', [
{
children: [
{ name: 'TCP' }
]
}
], { loose: true });
// `Node / StreamPipe` (C++) -> StreamPipe (JS)
state.validateSnapshotNodes('StreamPipe', [
{
children: [
{ name: 'StreamPipe' }
]
}
]);
// `Node / Http2Session` (C++) -> Http2Session (JS)
state.validateSnapshotNodes('Http2Session', [
{
children: [
{ name: 'Http2Session' },
{ name: 'streams' }
]
}
], { loose: true });
}));
req.resume();
req.on('end', common.mustCall(() => {
client.close();
server.close();
}));
req.end();
});