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