// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:http2
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.
// Edit the TODO lines below to exercise each API; rerun
// `./run_parity_tests.sh --filter test_parity_http2` to verify.

import * as http2 from "node:http2";


// ── Functions ──
// http2.createServer([options][, onRequestHandler]) — construct + immediate close.
try {
  const s1 = http2.createServer();
  console.log("http2.createServer no-arg typeof:", typeof s1);
  s1.close();
  const s2 = http2.createServer((_req: any, _res: any) => {});
  console.log("http2.createServer w/ listener typeof:", typeof s2);
  s2.close();
} catch (e: any) { console.log("http2.createServer threw:", e && e.message); }

// http2.createSecureServer(options[, onRequestHandler]) — construct + immediate close.
// PERRY-SKIP: needs real TLS key/cert pair; Node accepts empty options but errors later
try {
  const s = http2.createSecureServer({});
  console.log("http2.createSecureServer typeof:", typeof s);
  s.close();
} catch (e: any) { console.log("http2.createSecureServer threw:", e && e.message); }

// http2.connect(authority[, options][, listener]) — destroy immediately, no external dial.
try {
  const client = http2.connect("http://127.0.0.1:1");
  client.on("error", () => {}); // swallow ECONNREFUSED
  console.log("http2.connect typeof:", typeof client);
  client.destroy();
} catch (e: any) { console.log("http2.connect threw:", e && e.message); }

// http2.getDefaultSettings() — probe specific known fields rather than full object.
try {
  const d = http2.getDefaultSettings();
  console.log("getDefaultSettings.headerTableSize:", d.headerTableSize);
  console.log("getDefaultSettings.initialWindowSize:", d.initialWindowSize);
  console.log("getDefaultSettings.maxFrameSize:", d.maxFrameSize);
  console.log("getDefaultSettings.enablePush:", d.enablePush);
  console.log("getDefaultSettings.maxHeaderListSize:", d.maxHeaderListSize);
} catch (e: any) { console.log("getDefaultSettings threw:", e && e.message); }

// http2.getPackedSettings([settings]) — pack a fixed Settings object, probe length.
try {
  const packed = http2.getPackedSettings({headerTableSize: 4096, initialWindowSize: 65535});
  console.log("getPackedSettings typeof:", typeof packed);
  console.log("getPackedSettings.length:", packed.length);
} catch (e: any) { console.log("getPackedSettings threw:", e && e.message); }

// http2.getUnpackedSettings(buf) — round-trip pack→unpack, probe one field.
try {
  const packed = http2.getPackedSettings({headerTableSize: 4096});
  const unpacked = http2.getUnpackedSettings(packed);
  console.log("getUnpackedSettings.headerTableSize:", unpacked.headerTableSize);
} catch (e: any) { console.log("getUnpackedSettings threw:", e && e.message); }

// http2.performServerHandshake(socket[, options]) — type probe only (needs live socket).
// PERRY-SKIP: requires a fully-upgraded net.Socket; not feasible without listener
try {
  console.log("performServerHandshake typeof:", typeof http2.performServerHandshake);
} catch (e: any) { console.log("performServerHandshake threw:", e && e.message); }

// ── Module Properties ──
// http2.constants — probe specific values rather than full object.
try {
  console.log("HTTP2_HEADER_PATH:", http2.constants.HTTP2_HEADER_PATH);
  console.log("HTTP2_HEADER_METHOD:", http2.constants.HTTP2_HEADER_METHOD);
  console.log("HTTP2_HEADER_STATUS:", http2.constants.HTTP2_HEADER_STATUS);
  console.log("HTTP2_HEADER_AUTHORITY:", http2.constants.HTTP2_HEADER_AUTHORITY);
  console.log("HTTP2_HEADER_SCHEME:", http2.constants.HTTP2_HEADER_SCHEME);
  console.log("HTTP_STATUS_OK:", http2.constants.HTTP_STATUS_OK);
  console.log("HTTP_STATUS_NOT_FOUND:", http2.constants.HTTP_STATUS_NOT_FOUND);
  console.log("HTTP_STATUS_INTERNAL_SERVER_ERROR:", http2.constants.HTTP_STATUS_INTERNAL_SERVER_ERROR);
  console.log("NGHTTP2_NO_ERROR:", http2.constants.NGHTTP2_NO_ERROR);
  console.log("NGHTTP2_PROTOCOL_ERROR:", http2.constants.NGHTTP2_PROTOCOL_ERROR);
  console.log("NGHTTP2_INTERNAL_ERROR:", http2.constants.NGHTTP2_INTERNAL_ERROR);
  console.log("NGHTTP2_SESSION_SERVER:", http2.constants.NGHTTP2_SESSION_SERVER);
  console.log("NGHTTP2_SESSION_CLIENT:", http2.constants.NGHTTP2_SESSION_CLIENT);
} catch (e: any) { console.log("http2.constants threw:", e && e.message); }

// http2.sensitiveHeaders (Symbol) — probe typeof + description.
try {
  console.log("sensitiveHeaders typeof:", typeof http2.sensitiveHeaders);
  console.log("sensitiveHeaders description:", (http2.sensitiveHeaders as any).description);
} catch (e: any) { console.log("sensitiveHeaders threw:", e && e.message); }

// ── Classes ──
// class Http2Session — typeof only; instances exercised via http2.connect (destroyed above).
try {
  // Http2Session is not directly exported; probe via connect → session.
  const client = http2.connect("http://127.0.0.1:1");
  client.on("error", () => {});
  console.log("session typeof:", typeof client);
  // session.alpnProtocol — undefined before TLS handshake; probe typeof.
  console.log("session.alpnProtocol typeof:", typeof client.alpnProtocol);
  // session.close([callback]) — typeof only (we destroy below).
  console.log("session.close typeof:", typeof client.close);
  // session.closed / connecting / destroyed / encrypted — boolean state.
  console.log("session.closed typeof:", typeof client.closed);
  console.log("session.connecting typeof:", typeof client.connecting);
  console.log("session.destroyed typeof:", typeof client.destroyed);
  console.log("session.encrypted typeof:", typeof client.encrypted);
  // session.destroy([error][, code]) — typeof.
  console.log("session.destroy typeof:", typeof client.destroy);
  // session.goaway([code[, lastStreamID[, opaqueData]]]) — typeof.
  console.log("session.goaway typeof:", typeof client.goaway);
  // session.localSettings — object.
  console.log("session.localSettings typeof:", typeof client.localSettings);
  // session.originSet — array on TLS, undefined on plaintext.
  console.log("session.originSet typeof:", typeof client.originSet);
  // session.pendingSettingsAck — boolean.
  console.log("session.pendingSettingsAck typeof:", typeof client.pendingSettingsAck);
  // session.ping([payload, ]callback) — typeof.
  console.log("session.ping typeof:", typeof client.ping);
  // session.ref() / unref() — typeof.
  console.log("session.ref typeof:", typeof client.ref);
  console.log("session.unref typeof:", typeof client.unref);
  // session.remoteSettings — object (settings).
  console.log("session.remoteSettings typeof:", typeof client.remoteSettings);
  // session.setLocalWindowSize(windowSize) — typeof.
  console.log("session.setLocalWindowSize typeof:", typeof client.setLocalWindowSize);
  // session.setTimeout(msecs, callback) — typeof.
  console.log("session.setTimeout typeof:", typeof client.setTimeout);
  // session.socket — net.Socket-like.
  console.log("session.socket typeof:", typeof client.socket);
  // session.state — object.
  console.log("session.state typeof:", typeof client.state);
  // session.settings([settings][, callback]) — typeof.
  console.log("session.settings typeof:", typeof client.settings);
  // session.type — int (0=server, 1=client).
  console.log("session.type typeof:", typeof client.type);
  // Scoped destroy.
  client.destroy();
  console.log("session.destroyed after destroy:", client.destroyed);
} catch (e: any) { console.log("Http2Session probe threw:", e && e.message); }

// Coverage: 2 auto-emitted, 28 TODO, 0 skip-listed.
