11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding'); 71cb0ef41Sopenharmony_ciconst StreamWrap = require('internal/js_stream_socket'); 81cb0ef41Sopenharmony_ciconst { Duplex } = require('stream'); 91cb0ef41Sopenharmony_ciconst { ShutdownWrap } = internalBinding('stream_wrap'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifunction testShutdown(callback) { 121cb0ef41Sopenharmony_ci const stream = new Duplex({ 131cb0ef41Sopenharmony_ci read: function() { 141cb0ef41Sopenharmony_ci }, 151cb0ef41Sopenharmony_ci write: function() { 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci const wrap = new StreamWrap(stream); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci const req = new ShutdownWrap(); 221cb0ef41Sopenharmony_ci req.oncomplete = function(code) { 231cb0ef41Sopenharmony_ci assert(code < 0); 241cb0ef41Sopenharmony_ci callback(); 251cb0ef41Sopenharmony_ci }; 261cb0ef41Sopenharmony_ci req.handle = wrap._handle; 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci // Close the handle to simulate 291cb0ef41Sopenharmony_ci wrap.destroy(); 301cb0ef41Sopenharmony_ci req.handle.shutdown(req); 311cb0ef41Sopenharmony_ci} 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_citestShutdown(common.mustCall()); 34