11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst net = require('net');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding');
81cb0ef41Sopenharmony_ciconst { UV_EOF } = internalBinding('uv');
91cb0ef41Sopenharmony_ciconst { streamBaseState, kReadBytesOrError } = internalBinding('stream_wrap');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst s = new net.Socket({
121cb0ef41Sopenharmony_ci  handle: {
131cb0ef41Sopenharmony_ci    readStart: function() {
141cb0ef41Sopenharmony_ci      setImmediate(() => {
151cb0ef41Sopenharmony_ci        streamBaseState[kReadBytesOrError] = UV_EOF;
161cb0ef41Sopenharmony_ci        this.onread();
171cb0ef41Sopenharmony_ci      });
181cb0ef41Sopenharmony_ci    },
191cb0ef41Sopenharmony_ci    close: (cb) => setImmediate(cb)
201cb0ef41Sopenharmony_ci  },
211cb0ef41Sopenharmony_ci  writable: false
221cb0ef41Sopenharmony_ci});
231cb0ef41Sopenharmony_ciassert.strictEqual(s, s.resume());
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconst events = [];
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cis.on('end', () => {
281cb0ef41Sopenharmony_ci  events.push('end');
291cb0ef41Sopenharmony_ci});
301cb0ef41Sopenharmony_cis.on('close', () => {
311cb0ef41Sopenharmony_ci  events.push('close');
321cb0ef41Sopenharmony_ci});
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciprocess.on('exit', () => {
351cb0ef41Sopenharmony_ci  assert.deepStrictEqual(events, [ 'end', 'close' ]);
361cb0ef41Sopenharmony_ci});
37