@@ -25,6 +25,7 @@ import FakeConnection from './fake-connection'
25
25
import lolex from 'lolex'
26
26
import { int } from '../../src/integer'
27
27
import { newError , SERVICE_UNAVAILABLE } from '../../lib/error'
28
+ import { PROTOCOL_ERROR } from '../../src/error'
28
29
29
30
const PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound'
30
31
const DATABASE_NOT_FOUND_CODE = 'Neo.ClientError.Database.DatabaseNotFound'
@@ -173,6 +174,37 @@ describe('#unit Rediscovery', () => {
173
174
174
175
expect ( routingTable ) . toEqual ( null )
175
176
} )
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
+ } )
176
208
} )
177
209
178
210
function newMetadata ( {
0 commit comments