@@ -100,9 +100,14 @@ FakeConnection.prototype.handshake = function(options) {
100100 this . _sendPacket ( this . _handshakeInitializationPacket ) ;
101101} ;
102102
103+ FakeConnection . prototype . ok = function ok ( ) {
104+ this . _sendPacket ( new Packets . OkPacket ( ) ) ;
105+ this . _parser . resetPacketNumber ( ) ;
106+ } ;
107+
103108FakeConnection . prototype . _sendAuthResponse = function _sendAuthResponse ( got , expected ) {
104109 if ( expected . toString ( 'hex' ) === got . toString ( 'hex' ) ) {
105- this . _sendPacket ( new Packets . OkPacket ( ) ) ;
110+ this . ok ( ) ;
106111 } else {
107112 this . deny ( 'expected ' + expected . toString ( 'hex' ) + ' got ' + got . toString ( 'hex' ) ) ;
108113 }
@@ -280,8 +285,7 @@ FakeConnection.prototype._parsePacket = function() {
280285 this . user = ( packet . user || null ) ;
281286
282287 if ( ! this . emit ( 'clientAuthentication' , packet ) ) {
283- this . _sendPacket ( new Packets . OkPacket ( ) ) ;
284- this . _parser . resetPacketNumber ( ) ;
288+ this . ok ( ) ;
285289 }
286290 break ;
287291 case Packets . SSLRequestPacket :
@@ -294,8 +298,7 @@ FakeConnection.prototype._parsePacket = function() {
294298 break ;
295299 case Packets . ComPingPacket :
296300 if ( ! this . emit ( 'ping' , packet ) ) {
297- this . _sendPacket ( new Packets . OkPacket ( ) ) ;
298- this . _parser . resetPacketNumber ( ) ;
301+ this . ok ( ) ;
299302 }
300303 break ;
301304 case Packets . ComChangeUserPacket :
@@ -311,8 +314,7 @@ FakeConnection.prototype._parsePacket = function() {
311314 break ;
312315 }
313316
314- this . _sendPacket ( new Packets . OkPacket ( ) ) ;
315- this . _parser . resetPacketNumber ( ) ;
317+ this . ok ( ) ;
316318 }
317319 break ;
318320 case Packets . ComQuitPacket :
0 commit comments