@@ -343,11 +343,11 @@ describe('HFCConnectionManager', () => {
343343
344344 // Check for the correct interactions with hfc.
345345 sinon . assert . calledOnce ( mockChain . setMemberServicesUrl ) ;
346- sinon . assert . calledWith ( mockChain . setMemberServicesUrl , connectOptions . membershipServicesURL , { pem : '=== such certificate ===' } ) ;
346+ sinon . assert . calledWith ( mockChain . setMemberServicesUrl , connectOptions . membershipServicesURL , { pem : '=== such certificate ===\n ' } ) ;
347347 sinon . assert . calledOnce ( mockChain . addPeer ) ;
348- sinon . assert . calledWith ( mockChain . addPeer , connectOptions . peerURL , { pem : '=== such certificate ===' } ) ;
348+ sinon . assert . calledWith ( mockChain . addPeer , connectOptions . peerURL , { pem : '=== such certificate ===\n ' } ) ;
349349 sinon . assert . calledOnce ( mockChain . eventHubConnect ) ;
350- sinon . assert . calledWith ( mockChain . eventHubConnect , 'grpc://vp1' , { pem : '=== such certificate ===' } ) ;
350+ sinon . assert . calledWith ( mockChain . eventHubConnect , 'grpc://vp1' , { pem : '=== such certificate ===\n ' } ) ;
351351 return true ;
352352
353353 } ) ;
@@ -406,6 +406,24 @@ describe('HFCConnectionManager', () => {
406406 } ;
407407 } ) ;
408408
409+ it ( 'should throw for a connection not created by the connection manager' , ( ) => {
410+ let mockConnection = sinon . createStubInstance ( HFCConnection ) ;
411+ mockConnection . getIdentifier . returns ( 'not a real identifier' ) ;
412+ ( ( ) => {
413+ connectionManager . onDisconnect ( mockConnection ) ;
414+ } ) . should . throw ( / n o t c r e a t e d b y c o n n e c t i o n m a n a g e r / ) ;
415+ } ) ;
416+
417+ it ( 'should throw for a connection already closed by the connection manager' , ( ) => {
418+ let mockConnection = sinon . createStubInstance ( HFCConnection ) ;
419+ let mockChain = sinon . createStubInstance ( hfcChain ) ;
420+ mockConnection . getIdentifier . returns ( 'not a real identifier' ) ;
421+ connectionManager . chainPool [ 'not a real identifier' ] = { count : 0 , chain : mockChain } ;
422+ ( ( ) => {
423+ connectionManager . onDisconnect ( mockConnection ) ;
424+ } ) . should . throw ( / a l r e a d y c l o s e d / ) ;
425+ } ) ;
426+
409427 it ( 'should call onDisconnect when client connection is disconnected' , function ( ) {
410428
411429 // Set up the hfc mock.
0 commit comments