1'use strict'; 2 3const { 4 hasCrypto, 5 mustCall, 6 skip 7} = require('../common'); 8if (!hasCrypto) 9 skip('missing crypto'); 10 11const { 12 strictEqual 13} = require('assert'); 14const { 15 createServer, 16 connect 17} = require('http2'); 18const { 19 spawnSync 20} = require('child_process'); 21 22// Validate that there is no unexpected output when 23// using http2 24if (process.argv[2] !== 'child') { 25 const { 26 stdout, stderr, status 27 } = spawnSync(process.execPath, [__filename, 'child'], { encoding: 'utf8' }); 28 strictEqual(stderr, ''); 29 strictEqual(stdout, ''); 30 strictEqual(status, 0); 31} else { 32 const server = createServer(); 33 server.listen(0, mustCall(() => { 34 const client = connect(`http://localhost:${server.address().port}`); 35 client.on('connect', mustCall(() => { 36 client.close(); 37 server.close(); 38 })); 39 })); 40} 41