@@ -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 ) => {
2519assert . strictEqual ( 0 , client . writeQueueSize ) ;
2620console . log ( 'got connection' ) ;
@@ -34,7 +28,7 @@ server.onconnection = (err, client) =>{
3428
3529client . readStart ( ) ;
3630client . pendingWrites = [ ] ;
37- client . onread = ( err , buffer ) => {
31+ client . onread = common . mustCall ( ( err , buffer ) => {
3832if ( buffer ) {
3933assert . ok ( buffer . length > 0 ) ;
4034
@@ -51,7 +45,7 @@ server.onconnection = (err, client) =>{
5145assert . strictEqual ( 0 , client . writeQueueSize ) ;
5246
5347if ( req . async )
54- req . oncomplete = done ;
48+ req . oncomplete = common . mustCall ( done ) ;
5549else
5650process . nextTick ( done . bind ( null , 0 , client , req ) ) ;
5751
@@ -66,20 +60,16 @@ server.onconnection = (err, client) =>{
6660console . log ( 'client.writeQueueSize: ' + client . writeQueueSize ) ;
6761assert . strictEqual ( 0 , client . writeQueueSize ) ;
6862
69- writeCount ++ ;
70- console . log ( 'write ' + writeCount ) ;
7163maybeCloseClient ( ) ;
7264}
7365
74- sliceCount ++ ;
7566} else {
7667console . log ( 'eof' ) ;
7768client . gotEOF = true ;
7869server . close ( ) ;
79- eofCount ++ ;
8070maybeCloseClient ( ) ;
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 ) => {
9383assert . strictEqual ( 'hello world' , d ) ;
94- recvCount ++ ;
95- } ) ;
84+ } ) ) ;
9685
9786c . on ( 'close' , ( ) => {
9887console . 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