@@ -25,6 +25,7 @@ import FakeConnection from './fake-connection'
2525import lolex from 'lolex'
2626import { int } from '../../src/integer'
2727import { newError , SERVICE_UNAVAILABLE } from '../../lib/error'
28+ import { PROTOCOL_ERROR } from '../../src/error'
2829
2930const PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound'
3031const DATABASE_NOT_FOUND_CODE = 'Neo.ClientError.Database.DatabaseNotFound'
@@ -173,6 +174,37 @@ describe('#unit Rediscovery', () => {
173174
174175 expect ( routingTable ) . toEqual ( null )
175176 } )
177+
178+ it ( 'should throw PROTOCOL_ERROR if the routing table is invalid' , async ( ) => {
179+ runWithClockAt ( Date . now ( ) , async ( ) => {
180+ try {
181+ const ttl = int ( 123 )
182+ const routers = [ 'bolt://localhost:7687' ]
183+ const writers = [ 'bolt://localhost:7686' ]
184+ const readers = [ ]
185+ const initialAddress = '127.0.0.1'
186+ const routingContext = { context : '1234 ' }
187+ const rawRoutingTable = RawRoutingTable . ofMessageResponse (
188+ newMetadata ( { ttl, routers, readers, writers } )
189+ )
190+
191+ await lookupRoutingTableOnRouter ( {
192+ initialAddress,
193+ routingContext,
194+ rawRoutingTable
195+ } )
196+
197+ fail ( 'should not succeed' )
198+ } catch ( error ) {
199+ expect ( error ) . toEqual (
200+ newError (
201+ 'Received no readers from router localhost:7687' ,
202+ PROTOCOL_ERROR
203+ )
204+ )
205+ }
206+ } )
207+ } )
176208} )
177209
178210function newMetadata ( {
0 commit comments