@@ -4,22 +4,44 @@ const common = require('../common');
44const assert = require ( 'assert' ) ;
55const net = require ( 'net' ) ;
66
7- const server = net . createServer ( common . mustCall ( ( socket ) => {
8- socket . end ( Buffer . alloc ( 1024 ) ) ;
9- } ) ) . listen ( 0 , common . mustCall ( ( ) => {
10- const socket = net . connect ( server . address ( ) . port ) ;
11- assert . strictEqual ( socket . allowHalfOpen , false ) ;
12- socket . resume ( ) ;
13- socket . on ( 'end' , common . mustCall ( ( ) => {
14- process . nextTick ( ( ) => {
15- // Ensure socket is not destroyed straight away
16- // without proper shutdown.
7+ {
8+ const server = net . createServer ( common . mustCall ( ( socket ) => {
9+ socket . end ( Buffer . alloc ( 1024 ) ) ;
10+ } ) ) . listen ( 0 , common . mustCall ( ( ) => {
11+ const socket = net . connect ( server . address ( ) . port ) ;
12+ assert . strictEqual ( socket . allowHalfOpen , false ) ;
13+ socket . resume ( ) ;
14+ socket . on ( 'end' , common . mustCall ( ( ) => {
15+ process . nextTick ( ( ) => {
16+ // Ensure socket is not destroyed straight away
17+ // without proper shutdown.
18+ assert ( ! socket . destroyed ) ;
19+ server . close ( ) ;
20+ } ) ;
21+ } ) ) ;
22+ socket . on ( 'finish' , common . mustCall ( ( ) => {
1723 assert ( ! socket . destroyed ) ;
18- server . close ( ) ;
19- } ) ;
24+ } ) ) ;
25+ socket . on ( 'close' , common . mustCall ( ) ) ;
2026 } ) ) ;
21- socket . on ( 'finish' , common . mustCall ( ( ) => {
22- assert ( ! socket . destroyed ) ;
27+ }
28+
29+ {
30+ const server = net . createServer ( common . mustCall ( ( socket ) => {
31+ socket . end ( Buffer . alloc ( 1024 ) ) ;
32+ } ) ) . listen ( 0 , common . mustCall ( ( ) => {
33+ const socket = net . connect ( server . address ( ) . port ) ;
34+ assert . strictEqual ( socket . allowHalfOpen , false ) ;
35+ socket . resume ( ) ;
36+ socket . on ( 'end' , common . mustCall ( ( ) => {
37+ assert ( ! socket . destroyed ) ;
38+ } ) ) ;
39+ socket . end ( 'asd' ) ;
40+ socket . on ( 'finish' , common . mustCall ( ( ) => {
41+ assert ( ! socket . destroyed ) ;
42+ } ) ) ;
43+ socket . on ( 'close' , common . mustCall ( ( ) => {
44+ server . close ( ) ;
45+ } ) ) ;
2346 } ) ) ;
24- socket . on ( 'close' , common . mustCall ( ) ) ;
25- } ) ) ;
47+ }
0 commit comments