2
2
const common = require ( '../common' ) ;
3
3
const assert = require ( 'assert' ) ;
4
4
const net = require ( 'net' ) ;
5
- const dns = require ( 'dns' ) ;
6
5
7
6
if ( ! common . hasIPv6 ) {
8
7
console . log ( '1..0 # Skipped: no IPv6 support' ) ;
9
8
return ;
10
9
}
11
10
12
- var serverGotEnd = false ;
13
- var clientGotEnd = false ;
14
-
15
11
const hosts = common . localIPv6Hosts ;
16
12
var hostIdx = 0 ;
17
13
var host = hosts [ hostIdx ] ;
18
14
var localhostTries = 10 ;
19
15
20
16
const server = net . createServer ( { allowHalfOpen : true } , function ( socket ) {
21
17
socket . resume ( ) ;
22
- socket . on ( 'end' , function ( ) {
23
- serverGotEnd = true ;
24
- } ) ;
18
+ socket . on ( 'end' , common . mustCall ( function ( ) { } ) ) ;
25
19
socket . end ( ) ;
26
20
} ) ;
27
21
@@ -36,13 +30,12 @@ function tryConnect() {
36
30
} , function ( ) {
37
31
console . error ( 'client connect cb' ) ;
38
32
client . resume ( ) ;
39
- client . on ( 'end' , function ( ) {
40
- clientGotEnd = true ;
33
+ client . on ( 'end' , common . mustCall ( function ( ) {
41
34
setTimeout ( function ( ) {
42
35
assert ( client . writable ) ;
43
36
client . end ( ) ;
44
37
} , 10 ) ;
45
- } ) ;
38
+ } ) ) ;
46
39
client . on ( 'close' , function ( ) {
47
40
server . close ( ) ;
48
41
} ) ;
@@ -54,18 +47,10 @@ function tryConnect() {
54
47
tryConnect ( ) ;
55
48
else {
56
49
console . log ( '1..0 # Skipped: no IPv6 localhost support' ) ;
57
- process . removeListener ( 'exit' , onExit ) ;
58
50
server . close ( ) ;
59
51
}
60
52
return ;
61
53
}
62
54
throw err ;
63
55
} ) ;
64
56
}
65
-
66
- process . on ( 'exit' , onExit ) ;
67
- function onExit ( ) {
68
- console . error ( 'exit' , serverGotEnd , clientGotEnd ) ;
69
- assert ( serverGotEnd ) ;
70
- assert ( clientGotEnd ) ;
71
- }
0 commit comments