Skip to content

Commit f2a74f7

Browse files
Peter Wilhelmsson2hdddg
authored andcommitted
Enable support for bolt v4.1 protocol, remove v1 support
1 parent ad5f5a3 commit f2a74f7

File tree

7 files changed

+45
-15
lines changed

7 files changed

+45
-15
lines changed

src/internal/bolt-protocol-v4x1.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2002-2020 "Neo4j,"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
import BoltProtocolV4 from './bolt-protocol-v4x0'
20+
import RequestMessage, { ALL } from './request-message'
21+
import { ResultStreamObserver } from './stream-observers'
22+
import { BOLT_PROTOCOL_V4_1 } from './constants'
23+
24+
export default class BoltProtocol extends BoltProtocolV4 {
25+
get version () {
26+
return BOLT_PROTOCOL_V4_1
27+
}
28+
}

src/internal/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ const BOLT_PROTOCOL_V1 = 1
2424
const BOLT_PROTOCOL_V2 = 2
2525
const BOLT_PROTOCOL_V3 = 3
2626
const BOLT_PROTOCOL_V4_0 = 4.0
27+
const BOLT_PROTOCOL_V4_1 = 4.1
2728

2829
export {
2930
ACCESS_MODE_READ,
3031
ACCESS_MODE_WRITE,
3132
BOLT_PROTOCOL_V1,
3233
BOLT_PROTOCOL_V2,
3334
BOLT_PROTOCOL_V3,
34-
BOLT_PROTOCOL_V4_0
35+
BOLT_PROTOCOL_V4_0,
36+
BOLT_PROTOCOL_V4_1
3537
}

src/internal/protocol-handshaker.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import BoltProtocolV1 from './bolt-protocol-v1'
2323
import BoltProtocolV2 from './bolt-protocol-v2'
2424
import BoltProtocolV3 from './bolt-protocol-v3'
2525
import BoltProtocolV4x0 from './bolt-protocol-v4x0'
26+
import BoltProtocolV4x1 from './bolt-protocol-v4x1'
2627

2728
const BOLT_MAGIC_PREAMBLE = 0x6060b017
2829

@@ -108,6 +109,12 @@ export default class ProtocolHandshaker {
108109
this._chunker,
109110
this._disableLosslessIntegers
110111
)
112+
case 4.1:
113+
return new BoltProtocolV4x1(
114+
this._connection,
115+
this._chunker,
116+
this._disableLosslessIntegers
117+
)
111118
default:
112119
throw newError('Unknown Bolt protocol version: ' + version)
113120
}
@@ -125,10 +132,10 @@ function newHandshakeBuffer () {
125132
handshakeBuffer.writeInt32(BOLT_MAGIC_PREAMBLE)
126133

127134
// proposed versions
135+
handshakeBuffer.writeInt32((1 << 8) | 4)
128136
handshakeBuffer.writeInt32(4)
129137
handshakeBuffer.writeInt32(3)
130138
handshakeBuffer.writeInt32(2)
131-
handshakeBuffer.writeInt32(1)
132139

133140
// reset the reader position
134141
handshakeBuffer.reset()

test/internal/connection-channel.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ describe('#integration ChannelConnection', () => {
123123
connection._negotiateProtocol()
124124

125125
const boltMagicPreamble = '60 60 b0 17'
126-
const protocolVersion4 = '00 00 00 04'
126+
const protocolVersion4x1 = '00 00 01 04'
127+
const protocolVersion4x0 = '00 00 00 04'
127128
const protocolVersion3 = '00 00 00 03'
128129
const protocolVersion2 = '00 00 00 02'
129-
const protocolVersion1 = '00 00 00 01'
130130
expect(channel.toHex()).toBe(
131-
`${boltMagicPreamble} ${protocolVersion4} ${protocolVersion3} ${protocolVersion2} ${protocolVersion1}`
131+
`${boltMagicPreamble} ${protocolVersion4x1} ${protocolVersion4x0} ${protocolVersion3} ${protocolVersion2}`
132132
)
133133
})
134134

test/internal/node/direct.driver.boltkit.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ describe('#stub-direct direct driver with stub server', () => {
430430
await server.exit()
431431
}
432432

433-
it('v1', () => verifySupportsMultiDb('v1', false))
434433
it('v2', () => verifySupportsMultiDb('v2', false))
435434
it('v3', () => verifySupportsMultiDb('v3', false))
436435
it('v4', () => verifySupportsMultiDb('v4', true))
@@ -468,7 +467,6 @@ describe('#stub-direct direct driver with stub server', () => {
468467
await server.exit()
469468
}
470469

471-
it('v1', () => verifySupportsTransactionConfig('v1', false))
472470
it('v2', () => verifySupportsTransactionConfig('v2', false))
473471
it('v3', () => verifySupportsTransactionConfig('v3', true))
474472
it('v4', () => verifySupportsTransactionConfig('v4', true))

test/internal/node/routing.driver.boltkit.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,11 +2375,9 @@ describe('#stub-routing routing driver with stub server', () => {
23752375
await server.exit()
23762376
}
23772377

2378-
it('v1', () => verifySupportsMultiDb('v1', false))
23792378
it('v2', () => verifySupportsMultiDb('v2', false))
23802379
it('v3', () => verifySupportsMultiDb('v3', false))
23812380
it('v4', () => verifySupportsMultiDb('v4', true))
2382-
it('v1 with resolver', () => verifySupportsMultiDbWithResolver('v1', false))
23832381
it('v2 with resolver', () => verifySupportsMultiDbWithResolver('v2', false))
23842382
it('v3 with resolver', () => verifySupportsMultiDbWithResolver('v3', false))
23852383
it('v4 with resolver', () => verifySupportsMultiDbWithResolver('v4', true))
@@ -2446,12 +2444,9 @@ describe('#stub-routing routing driver with stub server', () => {
24462444
await server.exit()
24472445
}
24482446

2449-
it('v1', () => verifySupportsTransactionConfig('v1', false))
24502447
it('v2', () => verifySupportsTransactionConfig('v2', false))
24512448
it('v3', () => verifySupportsTransactionConfig('v3', true))
24522449
it('v4', () => verifySupportsTransactionConfig('v4', true))
2453-
it('v1 with resolver', () =>
2454-
verifySupportsTransactionConfigWithResolver('v1', false))
24552450
it('v2 with resolver', () =>
24562451
verifySupportsTransactionConfigWithResolver('v2', false))
24572452
it('v3 with resolver', () =>

test/internal/protocol-handshaker.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ describe('#unit ProtocolHandshaker', () => {
4242
expect(writtenBuffers.length).toEqual(1)
4343

4444
const boltMagicPreamble = '60 60 b0 17'
45-
const protocolVersion4 = '00 00 00 04'
45+
const protocolVersion4x1 = '00 00 01 04'
46+
const protocolVersion4x0 = '00 00 00 04'
4647
const protocolVersion3 = '00 00 00 03'
4748
const protocolVersion2 = '00 00 00 02'
48-
const protocolVersion1 = '00 00 00 01'
4949

5050
expect(writtenBuffers[0].toHex()).toEqual(
51-
`${boltMagicPreamble} ${protocolVersion4} ${protocolVersion3} ${protocolVersion2} ${protocolVersion1}`
51+
`${boltMagicPreamble} ${protocolVersion4x1} ${protocolVersion4x0} ${protocolVersion3} ${protocolVersion2}`
5252
)
5353
})
5454

0 commit comments

Comments
 (0)