@@ -643,14 +643,14 @@ describe('parsers', function () {
643643 assert . strictEqual ( replyCount , 3 )
644644 parser . execute ( new Buffer ( '\r\n' ) )
645645 assert . strictEqual ( replyCount , 4 )
646- } , 200 )
646+ } , 25 )
647647 // Delay done so the bufferPool is cleared and tested
648648 // If the buffer is not cleared, the coverage is not going to be at 100
649649 setTimeout ( function ( ) {
650650 var totalBuffer = Buffer . concat ( chunks ) . toString ( )
651651 assert . strictEqual ( replies [ 3 ] . toString ( ) , totalBuffer )
652652 done ( )
653- } , ( jsParser ? 1800 : 250 ) )
653+ } , ( jsParser ? 1500 : 50 ) )
654654 } )
655655
656656 it ( 'handle big data' , function ( ) {
@@ -719,20 +719,22 @@ describe('parsers', function () {
719719 assert . strictEqual ( replyCount , 2 )
720720 } )
721721
722- it ( 'handle big data 2 with buffers' , function ( ) {
722+ it ( 'handle big data 2 with buffers' , function ( done ) {
723+ this . timeout ( 4000 )
723724 var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
724725 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' +
725726 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
726727 'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
727728 var bigStringArray = ( new Array ( Math . pow ( 2 , 16 ) / lorem . length ) . join ( lorem + ' ' ) ) . split ( ' ' ) // Math.pow(2, 16) chars long
728- var startBigBuffer = new Buffer ( '$' + ( 4 * 1024 * 1024 ) + '\r\n' )
729- var chunks = new Array ( 64 )
730- for ( var i = 0 ; i < 64 ; i ++ ) {
729+ var startBigBuffer = new Buffer ( '$' + ( 200 * 1024 * 1024 ) + '\r\n' )
730+ var chunks = new Array ( 3200 )
731+ for ( var i = 0 ; i < 3200 ; i ++ ) {
731732 chunks [ i ] = new Buffer ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
732733 }
733734 var replyCount = 0
735+ var replyLen = [ 200 * 1024 * 1024 , 11 , 11 ]
734736 function checkReply ( reply ) {
735- assert . strictEqual ( reply . length , 4 * 1024 * 1024 )
737+ assert . strictEqual ( reply . length , replyLen [ replyCount ] )
736738 replyCount ++
737739 }
738740 var parser = new Parser ( {
@@ -742,15 +744,21 @@ describe('parsers', function () {
742744 returnBuffers : true
743745 } )
744746 parser . execute ( startBigBuffer )
745- for ( i = 0 ; i < 64 ; i ++ ) {
747+ for ( i = 0 ; i < 3200 ; i ++ ) {
746748 if ( Parser . name === 'JavascriptRedisParser' ) {
747749 assert . strictEqual ( parser . bufferCache . length , i + 1 )
748750 }
749751 parser . execute ( chunks [ i ] )
750752 }
751753 assert . strictEqual ( replyCount , 0 )
752- parser . execute ( new Buffer ( '\r\n' ) )
754+ parser . execute ( new Buffer ( '\r\n+hello world ' ) )
753755 assert . strictEqual ( replyCount , 1 )
756+ parser . execute ( new Buffer ( '\r\n$11\r\nhuge' ) )
757+ setTimeout ( function ( ) {
758+ parser . execute ( new Buffer ( ' buffer\r\n' ) )
759+ assert . strictEqual ( replyCount , 3 )
760+ done ( )
761+ } , 600 )
754762 } )
755763 } )
756764 } )
0 commit comments