11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciif (!common.hasCrypto)
61cb0ef41Sopenharmony_ci  common.skip('missing crypto');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst { validateSnapshotNodes } = require('../common/heap');
91cb0ef41Sopenharmony_ciconst net = require('net');
101cb0ef41Sopenharmony_ciconst tls = require('tls');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_civalidateSnapshotNodes('Node / TLSWrap', []);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst server = net.createServer(common.mustCall((c) => {
151cb0ef41Sopenharmony_ci  c.end();
161cb0ef41Sopenharmony_ci})).listen(0, common.mustCall(() => {
171cb0ef41Sopenharmony_ci  const c = tls.connect({ port: server.address().port });
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  c.on('error', common.mustCall(() => {
201cb0ef41Sopenharmony_ci    server.close();
211cb0ef41Sopenharmony_ci  }));
221cb0ef41Sopenharmony_ci  c.write('hello');
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  validateSnapshotNodes('Node / TLSWrap', [
251cb0ef41Sopenharmony_ci    {
261cb0ef41Sopenharmony_ci      children: [
271cb0ef41Sopenharmony_ci        { node_name: 'Node / NodeBIO', edge_name: 'enc_out' },
281cb0ef41Sopenharmony_ci        { node_name: 'Node / NodeBIO', edge_name: 'enc_in' },
291cb0ef41Sopenharmony_ci        // `Node / TLSWrap` (C++) -> `TLSWrap` (JS)
301cb0ef41Sopenharmony_ci        { node_name: 'TLSWrap', edge_name: 'native_to_javascript' },
311cb0ef41Sopenharmony_ci        // pending_cleartext_input could be empty
321cb0ef41Sopenharmony_ci      ],
331cb0ef41Sopenharmony_ci    },
341cb0ef41Sopenharmony_ci  ]);
351cb0ef41Sopenharmony_ci}));
36