11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst {
41cb0ef41Sopenharmony_ci  hasCrypto,
51cb0ef41Sopenharmony_ci  mustCall,
61cb0ef41Sopenharmony_ci  skip
71cb0ef41Sopenharmony_ci} = require('../common');
81cb0ef41Sopenharmony_ciif (!hasCrypto)
91cb0ef41Sopenharmony_ci  skip('missing crypto');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst {
121cb0ef41Sopenharmony_ci  strictEqual
131cb0ef41Sopenharmony_ci} = require('assert');
141cb0ef41Sopenharmony_ciconst {
151cb0ef41Sopenharmony_ci  createServer,
161cb0ef41Sopenharmony_ci  connect
171cb0ef41Sopenharmony_ci} = require('http2');
181cb0ef41Sopenharmony_ciconst {
191cb0ef41Sopenharmony_ci  spawnSync
201cb0ef41Sopenharmony_ci} = require('child_process');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci// Validate that there is no unexpected output when
231cb0ef41Sopenharmony_ci// using http2
241cb0ef41Sopenharmony_ciif (process.argv[2] !== 'child') {
251cb0ef41Sopenharmony_ci  const {
261cb0ef41Sopenharmony_ci    stdout, stderr, status
271cb0ef41Sopenharmony_ci  } = spawnSync(process.execPath, [__filename, 'child'], { encoding: 'utf8' });
281cb0ef41Sopenharmony_ci  strictEqual(stderr, '');
291cb0ef41Sopenharmony_ci  strictEqual(stdout, '');
301cb0ef41Sopenharmony_ci  strictEqual(status, 0);
311cb0ef41Sopenharmony_ci} else {
321cb0ef41Sopenharmony_ci  const server = createServer();
331cb0ef41Sopenharmony_ci  server.listen(0, mustCall(() => {
341cb0ef41Sopenharmony_ci    const client = connect(`http://localhost:${server.address().port}`);
351cb0ef41Sopenharmony_ci    client.on('connect', mustCall(() => {
361cb0ef41Sopenharmony_ci      client.close();
371cb0ef41Sopenharmony_ci      server.close();
381cb0ef41Sopenharmony_ci    }));
391cb0ef41Sopenharmony_ci  }));
401cb0ef41Sopenharmony_ci}
41