@@ -15,12 +15,6 @@ port = port.port;
1515
1616server . listen ( 128 ) ;
1717
18- let sliceCount = 0 ;
19- let eofCount = 0 ;
20-
21- let writeCount = 0 ;
22- let recvCount = 0 ;
23-
2418server . onconnection = ( err , client ) => {
2519 assert . strictEqual ( 0 , client . writeQueueSize ) ;
2620 console . log ( 'got connection' ) ;
@@ -34,7 +28,7 @@ server.onconnection = (err, client) => {
3428
3529 client . readStart ( ) ;
3630 client . pendingWrites = [ ] ;
37- client . onread = ( err , buffer ) => {
31+ client . onread = common . mustCall ( ( err , buffer ) => {
3832 if ( buffer ) {
3933 assert . ok ( buffer . length > 0 ) ;
4034
@@ -51,7 +45,7 @@ server.onconnection = (err, client) => {
5145 assert . strictEqual ( 0 , client . writeQueueSize ) ;
5246
5347 if ( req . async )
54- req . oncomplete = done ;
48+ req . oncomplete = common . mustCall ( done ) ;
5549 else
5650 process . nextTick ( done . bind ( null , 0 , client , req ) ) ;
5751
@@ -66,20 +60,16 @@ server.onconnection = (err, client) => {
6660 console . log ( 'client.writeQueueSize: ' + client . writeQueueSize ) ;
6761 assert . strictEqual ( 0 , client . writeQueueSize ) ;
6862
69- writeCount ++ ;
70- console . log ( 'write ' + writeCount ) ;
7163 maybeCloseClient ( ) ;
7264 }
7365
74- sliceCount ++ ;
7566 } else {
7667 console . log ( 'eof' ) ;
7768 client . gotEOF = true ;
7869 server . close ( ) ;
79- eofCount ++ ;
8070 maybeCloseClient ( ) ;
8171 }
82- } ;
72+ } , 2 ) ;
8373} ;
8474
8575const net = require ( 'net' ) ;
@@ -89,18 +79,10 @@ const c = net.createConnection(port);
8979c . on ( 'connect' , common . mustCall ( ( ) => { c . end ( 'hello world' ) ; } ) ) ;
9080
9181c . setEncoding ( 'utf8' ) ;
92- c . on ( 'data' , ( d ) => {
82+ c . on ( 'data' , common . mustCall ( ( d ) => {
9383 assert . strictEqual ( 'hello world' , d ) ;
94- recvCount ++ ;
95- } ) ;
84+ } ) ) ;
9685
9786c . on ( 'close' , ( ) => {
9887 console . error ( 'client closed' ) ;
9988} ) ;
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