@@ -15,11 +15,6 @@ port = port.port;
15
15
16
16
server . listen ( 128 ) ;
17
17
18
- let sliceCount = 0 , eofCount = 0 ;
19
-
20
- let writeCount = 0 ;
21
- let recvCount = 0 ;
22
-
23
18
server . onconnection = ( err , client ) => {
24
19
assert . strictEqual ( 0 , client . writeQueueSize ) ;
25
20
console . log ( 'got connection' ) ;
@@ -33,7 +28,7 @@ server.onconnection = (err, client) => {
33
28
34
29
client . readStart ( ) ;
35
30
client . pendingWrites = [ ] ;
36
- client . onread = ( err , buffer ) => {
31
+ client . onread = common . mustCall ( ( err , buffer ) => {
37
32
if ( buffer ) {
38
33
assert . ok ( buffer . length > 0 ) ;
39
34
@@ -50,7 +45,7 @@ server.onconnection = (err, client) => {
50
45
assert . strictEqual ( 0 , client . writeQueueSize ) ;
51
46
52
47
if ( req . async )
53
- req . oncomplete = done ;
48
+ req . oncomplete = common . mustCall ( done ) ;
54
49
else
55
50
process . nextTick ( done . bind ( null , 0 , client , req ) ) ;
56
51
@@ -65,20 +60,16 @@ server.onconnection = (err, client) => {
65
60
console . log ( 'client.writeQueueSize: ' + client . writeQueueSize ) ;
66
61
assert . strictEqual ( 0 , client . writeQueueSize ) ;
67
62
68
- writeCount ++ ;
69
- console . log ( 'write ' + writeCount ) ;
70
63
maybeCloseClient ( ) ;
71
64
}
72
65
73
- sliceCount ++ ;
74
66
} else {
75
67
console . log ( 'eof' ) ;
76
68
client . gotEOF = true ;
77
69
server . close ( ) ;
78
- eofCount ++ ;
79
70
maybeCloseClient ( ) ;
80
71
}
81
- } ;
72
+ } , 2 ) ;
82
73
} ;
83
74
84
75
const net = require ( 'net' ) ;
@@ -88,18 +79,10 @@ const c = net.createConnection(port);
88
79
c . on ( 'connect' , common . mustCall ( ( ) => { c . end ( 'hello world' ) ; } ) ) ;
89
80
90
81
c . setEncoding ( 'utf8' ) ;
91
- c . on ( 'data' , ( d ) => {
82
+ c . on ( 'data' , common . mustCall ( ( d ) => {
92
83
assert . strictEqual ( 'hello world' , d ) ;
93
- recvCount ++ ;
94
- } ) ;
84
+ } ) ) ;
95
85
96
86
c . on ( 'close' , ( ) => {
97
87
console . error ( 'client closed' ) ;
98
88
} ) ;
99
-
100
- process . on ( 'exit' , ( ) => {
101
- assert . strictEqual ( 1 , sliceCount ) ;
102
- assert . strictEqual ( 1 , eofCount ) ;
103
- assert . strictEqual ( 1 , writeCount ) ;
104
- assert . strictEqual ( 1 , recvCount ) ;
105
- } ) ;
0 commit comments