blob: 670c05fe3f0307e8cd085f4fc3a9fb1d2d2ceaa9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const StreamWrap = require('internal/js_stream_socket');
const { Duplex } = require('stream');
const { ShutdownWrap } = internalBinding('stream_wrap');
function testShutdown(callback) {
const stream = new Duplex({
read: function() {
},
write: function() {
}
});
const wrap = new StreamWrap(stream);
const req = new ShutdownWrap();
req.oncomplete = function(code) {
assert(code < 0);
callback();
};
req.handle = wrap._handle;
// Close the handle to simulate
wrap.destroy();
req.handle.shutdown(req);
}
testShutdown(common.mustCall());
|