11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst http2 = require('http2');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst server = http2.createServer({ maxSettings: 1 });
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci// TODO(@jasnell): There is still a session event
121cb0ef41Sopenharmony_ci// emitted on the server side but it will be destroyed
131cb0ef41Sopenharmony_ci// immediately after creation and there will be no
141cb0ef41Sopenharmony_ci// stream created.
151cb0ef41Sopenharmony_ciserver.on('session', common.mustCall((session) => {
161cb0ef41Sopenharmony_ci  session.on('stream', common.mustNotCall());
171cb0ef41Sopenharmony_ci  session.on('remoteSettings', common.mustNotCall());
181cb0ef41Sopenharmony_ci}));
191cb0ef41Sopenharmony_ciserver.on('stream', common.mustNotCall());
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => {
221cb0ef41Sopenharmony_ci  // Specify two settings entries when a max of 1 is allowed.
231cb0ef41Sopenharmony_ci  // Connection should error immediately.
241cb0ef41Sopenharmony_ci  const client = http2.connect(
251cb0ef41Sopenharmony_ci    `http://localhost:${server.address().port}`, {
261cb0ef41Sopenharmony_ci      settings: {
271cb0ef41Sopenharmony_ci        // The actual settings values do not matter.
281cb0ef41Sopenharmony_ci        headerTableSize: 1000,
291cb0ef41Sopenharmony_ci        enablePush: false,
301cb0ef41Sopenharmony_ci      },
311cb0ef41Sopenharmony_ci    });
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  client.on('error', common.mustCall(() => {
341cb0ef41Sopenharmony_ci    server.close();
351cb0ef41Sopenharmony_ci  }));
361cb0ef41Sopenharmony_ci}));
37