diff --git a/packages/bolt-connection/src/bolt/bolt-protocol-v1.js b/packages/bolt-connection/src/bolt/bolt-protocol-v1.js index d04b33b4e..41db11658 100644 --- a/packages/bolt-connection/src/bolt/bolt-protocol-v1.js +++ b/packages/bolt-connection/src/bolt/bolt-protocol-v1.js @@ -100,7 +100,7 @@ export default class BoltProtocol { } /** - * Returns the numerical version identifier for this protocol + * Returns the stringified version identifier for this protocol */ get version () { return BOLT_PROTOCOL_V1 diff --git a/packages/bolt-connection/src/bolt/create.js b/packages/bolt-connection/src/bolt/create.js index 18891e197..5974e2a29 100644 --- a/packages/bolt-connection/src/bolt/create.js +++ b/packages/bolt-connection/src/bolt/create.js @@ -15,7 +15,7 @@ * limitations under the License. */ -import { newError } from 'neo4j-driver-core' +import { newError, ProtocolVersion } from 'neo4j-driver-core' import BoltProtocolV1 from './bolt-protocol-v1' import BoltProtocolV2 from './bolt-protocol-v2' import BoltProtocolV3 from './bolt-protocol-v3' @@ -112,8 +112,11 @@ function createProtocol ( onProtocolError, log ) { - switch (version) { - case 1: + if (!(version instanceof ProtocolVersion) || version === undefined || version === null) { + throw newError('Unknown Bolt protocol version: ' + version) + } + switch (version.toString()) { + case '1.0': return new BoltProtocolV1( server, chunker, @@ -122,7 +125,7 @@ function createProtocol ( log, onProtocolError ) - case 2: + case '2.0': return new BoltProtocolV2( server, chunker, @@ -131,7 +134,7 @@ function createProtocol ( log, onProtocolError ) - case 3: + case '3.0': return new BoltProtocolV3( server, chunker, @@ -140,7 +143,7 @@ function createProtocol ( log, onProtocolError ) - case 4.0: + case '4.0': return new BoltProtocolV4x0( server, chunker, @@ -149,7 +152,7 @@ function createProtocol ( log, onProtocolError ) - case 4.1: + case '4.1': return new BoltProtocolV4x1( server, chunker, @@ -159,7 +162,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.2: + case '4.2': return new BoltProtocolV4x2( server, chunker, @@ -169,7 +172,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.3: + case '4.3': return new BoltProtocolV4x3( server, chunker, @@ -179,7 +182,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.4: + case '4.4': return new BoltProtocolV4x4( server, chunker, @@ -189,7 +192,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.0: + case '5.0': return new BoltProtocolV5x0( server, chunker, @@ -199,7 +202,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.1: + case '5.1': return new BoltProtocolV5x1( server, chunker, @@ -209,7 +212,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.2: + case '5.2': return new BoltProtocolV5x2( server, chunker, @@ -219,7 +222,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.3: + case '5.3': return new BoltProtocolV5x3(server, chunker, packingConfig, @@ -227,7 +230,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.4: + case '5.4': return new BoltProtocolV5x4(server, chunker, packingConfig, @@ -235,7 +238,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.5: + case '5.5': return new BoltProtocolV5x5(server, chunker, packingConfig, @@ -243,7 +246,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.6: + case '5.6': return new BoltProtocolV5x6(server, chunker, packingConfig, @@ -251,7 +254,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.7: + case '5.7': return new BoltProtocolV5x7(server, chunker, packingConfig, @@ -259,7 +262,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.8: + case '5.8': return new BoltProtocolV5x8(server, chunker, packingConfig, @@ -267,7 +270,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 6.0: + case '6.0': return new BoltProtocolV6x0(server, chunker, packingConfig, diff --git a/packages/bolt-connection/src/bolt/handshake.js b/packages/bolt-connection/src/bolt/handshake.js index 4354654cf..27e3c4b51 100644 --- a/packages/bolt-connection/src/bolt/handshake.js +++ b/packages/bolt-connection/src/bolt/handshake.js @@ -16,7 +16,7 @@ */ import { alloc } from '../channel' -import { newError } from 'neo4j-driver-core' +import { newError, ProtocolVersion } from 'neo4j-driver-core' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference @@ -69,7 +69,7 @@ function parseNegotiatedResponse (buffer, log) { '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' ) } - return Number(h[3] + '.' + h[2]) + return new ProtocolVersion(h[3], h[2]) } function handshakeNegotiationV2 (channel, buffer, log) { @@ -112,7 +112,7 @@ function handshakeNegotiationV2 (channel, buffer, log) { selectionBuffer.writeVarInt(capabilites) channel.write(selectionBuffer) resolve({ - protocolVersion: Number(major + '.' + minor), + protocolVersion: new ProtocolVersion(major, minor), capabilites, consumeRemainingBuffer: consumer => { if (buffer.hasRemaining()) { @@ -146,7 +146,7 @@ function newHandshakeBuffer () { */ /** * @typedef HandshakeResult - * @property {number} protocolVersion The protocol version negotiated in the handshake + * @property {ProtocolVersion} protocolVersion The protocol version negotiated in the handshake * @property {number} capabilites A bitmask representing the capabilities negotiated in the handshake * @property {function(BufferConsumerCallback)} consumeRemainingBuffer A function to consume the remaining buffer if it exists */ @@ -160,7 +160,7 @@ function newHandshakeBuffer () { */ export default function handshake (channel, log) { return initialHandshake(channel, log).then((result) => { - if (result.protocolVersion === 255.1) { + if (result.protocolVersion.equalTo(new ProtocolVersion(255, 1))) { return handshakeNegotiationV2(channel, result.buffer, log) } else { return result diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js index 565955a2e..d322450a5 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js index e69ce764b..9ff7fd82f 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } @@ -611,7 +611,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider const connectionProvider = new SingleConnectionProvider(delegateConnection) const protocolVersion = connection.protocol().version - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return [new Session({ mode: WRITE, bookmarks: Bookmarks.empty(), diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js index 26742391a..ad82fce1b 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js @@ -32,7 +32,8 @@ import { UnboundRelationship, Node, newError, - Vector + Vector, + ProtocolVersion } from 'neo4j-driver-core' import utils from '../test-utils' import { LoginObserver } from '../../src/bolt/stream-observers' @@ -224,7 +225,7 @@ describe('#unit BoltProtocolV1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV1(null, null, false) - expect(protocol.version).toBe(1) + expect(protocol.version).toEqual(new ProtocolVersion(1, 0)) }) describe('Bolt V3', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js index f5f415cb6..301fccaca 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js @@ -31,7 +31,8 @@ import { Relationship, Time, UnboundRelationship, - Node + Node, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -69,7 +70,7 @@ describe('#unit BoltProtocolV2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV2(null, null, false) - expect(protocol.version).toBe(2) + expect(protocol.version).toEqual(new ProtocolVersion(2, 0)) }) describe('unpacker configuration', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js index 2dbfd57e5..12a5a8407 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js @@ -36,7 +36,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -202,7 +203,7 @@ describe('#unit BoltProtocolV3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV3(null, null, false) - expect(protocol.version).toBe(3) + expect(protocol.version).toEqual(new ProtocolVersion(3, 0)) }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js index a3390252e..34590dddc 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js @@ -36,7 +36,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -149,7 +150,7 @@ describe('#unit BoltProtocolV4x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x0(null, null, false) - expect(protocol.version).toBe(4) + expect(protocol.version).toEqual(new ProtocolVersion(4, 0)) }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js index 9770453e0..5844ff6f8 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js @@ -32,7 +32,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -169,7 +170,7 @@ describe('#unit BoltProtocolV4x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x3(null, null, false) - expect(protocol.version).toBe(4.3) + expect(protocol.version).toEqual(new ProtocolVersion(4, 3)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js index 8351774d7..49869979f 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js @@ -32,7 +32,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV4x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x4(null, null, false) - expect(protocol.version).toBe(4.4) + expect(protocol.version).toEqual(new ProtocolVersion(4, 4)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js index a9849e7d6..04126daa7 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x0(null, null, false) - expect(protocol.version).toBe(5.0) + expect(protocol.version).toEqual(new ProtocolVersion(5, 0)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js index 3d6663852..801b2d189 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x1(null, null, false) - expect(protocol.version).toBe(5.1) + expect(protocol.version).toEqual(new ProtocolVersion(5, 1)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js index ab1a210c5..d24adc5ad 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x2(null, null, false) - expect(protocol.version).toBe(5.2) + expect(protocol.version).toEqual(new ProtocolVersion(5, 2)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js index bd27bb2f7..c0ca5182c 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x3(null, null, false) - expect(protocol.version).toBe(5.3) + expect(protocol.version).toEqual(new ProtocolVersion(5, 3)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js index 1ccbc0cd9..7005950b7 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x4(null, null, false) - expect(protocol.version).toBe(5.4) + expect(protocol.version).toEqual(new ProtocolVersion(5, 4)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js index 8e3cea85c..598817bcb 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x5', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x5(null, null, false) - expect(protocol.version).toBe(5.5) + expect(protocol.version).toEqual(new ProtocolVersion(5, 5)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js index 5fb60fa71..9403ae467 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x6', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x6(null, null, false) - expect(protocol.version).toBe(5.6) + expect(protocol.version).toEqual(new ProtocolVersion(5, 6)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js index a1c3cbb49..717668744 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -254,7 +255,7 @@ describe('#unit BoltProtocolV5x7', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x7(null, null, false) - expect(protocol.version).toBe(5.7) + expect(protocol.version).toEqual(new ProtocolVersion(5, 7)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js index cd96faddf..ceb551b06 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -254,7 +255,7 @@ describe('#unit BoltProtocolV5x8', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x8(null, null, false) - expect(protocol.version).toBe(5.8) + expect(protocol.version).toEqual(new ProtocolVersion(5, 8)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js index a0440d01b..7abaad9ab 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js @@ -36,7 +36,8 @@ import { Node, internal, vector, - json + json, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -256,7 +257,7 @@ describe('#unit BoltProtocolV6x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV6x0(null, null, false) - expect(protocol.version).toBe(6.0) + expect(protocol.version).toEqual(new ProtocolVersion(6, 0)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/index.test.js b/packages/bolt-connection/test/bolt/index.test.js index 6fb17e146..1c721ab25 100644 --- a/packages/bolt-connection/test/bolt/index.test.js +++ b/packages/bolt-connection/test/bolt/index.test.js @@ -17,7 +17,7 @@ import Bolt from '../../src/bolt' import DummyChannel from '../dummy-channel' import { alloc } from '../../src/channel' -import { newError, internal } from 'neo4j-driver-core' +import { newError, internal, ProtocolVersion } from 'neo4j-driver-core' import { Chunker, Dechunker } from '../../src/channel/chunking' import BoltProtocolV1 from '../../src/bolt/bolt-protocol-v1' @@ -35,6 +35,9 @@ import BoltProtocolV5x3 from '../../src/bolt/bolt-protocol-v5x3' import BoltProtocolV5x4 from '../../src/bolt/bolt-protocol-v5x4' import BoltProtocolV5x5 from '../../src/bolt/bolt-protocol-v5x5' import BoltProtocolV5x6 from '../../src/bolt/bolt-protocol-v5x6' +import BoltProtocolV5x7 from '../../src/bolt/bolt-protocol-v5x7' +import BoltProtocolV5x8 from '../../src/bolt/bolt-protocol-v5x8' +import BoltProtocolV6x0 from '../../src/bolt/bolt-protocol-v6x0' const { logger: { Logger } @@ -60,28 +63,28 @@ describe('#unit Bolt', () => { it('should handle a successful handshake without remaining buffer', done => { const { channel, handshakePromise } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' handshakePromise .then(({ protocolVersion, consumeRemainingBuffer }) => { - expect(protocolVersion).toEqual(expectedProtocolVersion) + expect(protocolVersion).toEqual({ major: 4, minor: 3 }) consumeRemainingBuffer(() => done.fail('Should not have remaining buffer') ) done() }) - .catch(e => done.fail(e)) + .catch(e => { throw e }) channel.onmessage(packedHandshakeMessage(expectedProtocolVersion)) }) it('should handle a successful handshake with remaining buffer', done => { const { channel, handshakePromise } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' const expectedExtraBuffer = createExtraBuffer() handshakePromise .then(({ protocolVersion, consumeRemainingBuffer }) => { - expect(protocolVersion).toEqual(expectedProtocolVersion) + expect(protocolVersion).toEqual({ major: 4, minor: 3 }) let consumeRemainingBufferCalled = false consumeRemainingBuffer(buffer => { consumeRemainingBufferCalled = true @@ -90,7 +93,7 @@ describe('#unit Bolt', () => { expect(consumeRemainingBufferCalled).toBeTruthy() done() }) - .catch(e => done.fail(e)) + .catch(e => { throw e }) channel.onmessage( packedHandshakeMessage(expectedProtocolVersion, expectedExtraBuffer) @@ -129,7 +132,7 @@ describe('#unit Bolt', () => { it('should not log error if the server responds with a valid protocol version', async () => { const { channel, handshakePromise, log } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' const logErrorSpy = jest.spyOn(log, 'error') channel.onmessage(packedHandshakeMessage(expectedProtocolVersion)) @@ -380,21 +383,24 @@ describe('#unit Bolt', () => { } const availableProtocols = [ - v(1, BoltProtocolV1), - v(2, BoltProtocolV2), - v(3, BoltProtocolV3), - v(4.0, BoltProtocolV4x0), - v(4.1, BoltProtocolV4x1), - v(4.2, BoltProtocolV4x2), - v(4.3, BoltProtocolV4x3), - v(4.4, BoltProtocolV4x4), - v(5.0, BoltProtocolV5x0), - v(5.1, BoltProtocolV5x1), - v(5.2, BoltProtocolV5x2), - v(5.3, BoltProtocolV5x3), - v(5.4, BoltProtocolV5x4), - v(5.5, BoltProtocolV5x5), - v(5.6, BoltProtocolV5x6) + v(new ProtocolVersion(1, 0), BoltProtocolV1), + v(new ProtocolVersion(2, 0), BoltProtocolV2), + v(new ProtocolVersion(3, 0), BoltProtocolV3), + v(new ProtocolVersion(4, 0), BoltProtocolV4x0), + v(new ProtocolVersion(4, 1), BoltProtocolV4x1), + v(new ProtocolVersion(4, 2), BoltProtocolV4x2), + v(new ProtocolVersion(4, 3), BoltProtocolV4x3), + v(new ProtocolVersion(4, 4), BoltProtocolV4x4), + v(new ProtocolVersion(5, 0), BoltProtocolV5x0), + v(new ProtocolVersion(5, 1), BoltProtocolV5x1), + v(new ProtocolVersion(5, 2), BoltProtocolV5x2), + v(new ProtocolVersion(5, 3), BoltProtocolV5x3), + v(new ProtocolVersion(5, 4), BoltProtocolV5x4), + v(new ProtocolVersion(5, 5), BoltProtocolV5x5), + v(new ProtocolVersion(5, 6), BoltProtocolV5x6), + v(new ProtocolVersion(5, 7), BoltProtocolV5x7), + v(new ProtocolVersion(5, 8), BoltProtocolV5x8), + v(new ProtocolVersion(6, 0), BoltProtocolV6x0) ] availableProtocols.forEach(lambda) diff --git a/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js b/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js index 2ac4c4dc3..3cfecf72a 100644 --- a/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js +++ b/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js @@ -719,7 +719,7 @@ describe('.verifyConnectivityAndGetServerInfo()', () => { }) function setup ({ releaseMock } = {}) { - const protocolVersion = 4.4 + const protocolVersion = '4.4' const resetAndFlush = jest.fn(() => Promise.resolve()) const server = { address: 'localhost:123', version: 'neo4j/1234' } const seenConnections = [] diff --git a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js index 84bda4bc0..8894b379d 100644 --- a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js +++ b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js @@ -24,7 +24,8 @@ import { internal, ServerInfo, staticAuthTokenManager, - authTokenManagers + authTokenManagers, + ProtocolVersion } from 'neo4j-driver-core' import { RoutingTable } from '../../src/rediscovery/' import SimpleHostNameResolver from '../../src/channel/browser/browser-host-name-resolver' @@ -45,14 +46,10 @@ const READ = 'READ' const WRITE = 'WRITE' describe.each([ - 3, - 4.0, - 4.1, - 4.2, - 4.3, - 4.4, - 5.0, - 5.1 + new ProtocolVersion(4, 4), + new ProtocolVersion(5, 0), + new ProtocolVersion(5, 8), + new ProtocolVersion(6, 0) ])('#unit RoutingConnectionProvider (PROTOCOL_VERSION=%d)', (PROTOCOL_VERSION) => { const server0 = ServerAddress.fromUrl('server0') const server1 = ServerAddress.fromUrl('server1') @@ -3043,7 +3040,7 @@ describe.each([ [server3, server4], [server5, server6] ) - const protocolVersion = 4.4 + const protocolVersion = new ProtocolVersion(4, 4) const server = { address: 'localhost:123', version: 'neo4j/1234' } const seenConnectionsPerAddress = new Map() @@ -3120,7 +3117,7 @@ describe.each([ const pool = newPool({ create: (address, release) => { if (i++ % 2 === 0) { - return new FakeConnection(address, release, 'version', 4.4, {}) + return new FakeConnection(address, release, 'version', new ProtocolVersion(4, 4), {}) } throw error } @@ -3134,7 +3131,7 @@ describe.each([ ) const serverInfo = await connectionProvider.verifyConnectivityAndGetServerInfo({ database, accessMode }) - expect(serverInfo).toEqual(new ServerInfo({}, 4.4)) + expect(serverInfo).toEqual(new ServerInfo({}, new ProtocolVersion(4, 4))) }) }) diff --git a/packages/core/src/connection-provider.ts b/packages/core/src/connection-provider.ts index f9e1fe53a..a393026ef 100644 --- a/packages/core/src/connection-provider.ts +++ b/packages/core/src/connection-provider.ts @@ -18,6 +18,7 @@ import Connection from './connection' import { bookmarks } from './internal' +import { ProtocolVersion } from './internal/protocol-version' import { ServerInfo } from './result-summary' import { AuthToken } from './types' @@ -155,7 +156,7 @@ class ConnectionProvider { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { throw Error('Not Implemented') } diff --git a/packages/core/src/connection.ts b/packages/core/src/connection.ts index f24d035dd..188d24be1 100644 --- a/packages/core/src/connection.ts +++ b/packages/core/src/connection.ts @@ -19,6 +19,7 @@ import { Bookmarks } from './internal/bookmarks' import { AccessMode, TelemetryApis } from './internal/constants' import { ResultStreamObserver } from './internal/observers' +import { ProtocolVersion } from './internal/protocol-version' import { TxConfig } from './internal/tx-config' import NotificationFilter from './notification-filter' @@ -131,7 +132,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): number { + getProtocolVersion (): ProtocolVersion { throw new Error('Not implemented') } diff --git a/packages/core/src/driver.ts b/packages/core/src/driver.ts index 2f6fed974..144f42bca 100644 --- a/packages/core/src/driver.ts +++ b/packages/core/src/driver.ts @@ -48,6 +48,7 @@ import { newError } from './error' import NotificationFilter from './notification-filter' import HomeDatabaseCache from './internal/homedb-cache' import { cacheKey } from './internal/auth-util' +import { ProtocolVersion } from './internal/protocol-version' const DEFAULT_MAX_CONNECTION_LIFETIME: number = 60 * 60 * 1000 // 1 hour @@ -739,7 +740,7 @@ class Driver { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { const connectionProvider = this._getOrCreateConnectionProvider() return connectionProvider.getNegotiatedProtocolVersion() } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 83fc1400b..f0db6abba 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -103,6 +103,7 @@ import resultTransformers, { ResultTransformer } from './result-transformers' import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate' import * as internal from './internal' // todo: removed afterwards import Vector, { VectorType, vector } from './vector' +import { ProtocolVersion } from './internal/protocol-version' /** * Object containing string constants representing predefined {@link Neo4jError} codes. @@ -189,7 +190,8 @@ const forExport = { notificationFilterDisabledClassification, notificationFilterMinimumSeverityLevel, clientCertificateProviders, - resolveCertificateProvider + resolveCertificateProvider, + ProtocolVersion } export { @@ -269,7 +271,8 @@ export { clientCertificateProviders, resolveCertificateProvider, Vector, - vector + vector, + ProtocolVersion } export type { diff --git a/packages/core/src/internal/constants.ts b/packages/core/src/internal/constants.ts index 7403677c3..032e81a6e 100644 --- a/packages/core/src/internal/constants.ts +++ b/packages/core/src/internal/constants.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import { ProtocolVersion } from './protocol-version' + const FETCH_ALL = -1 const DEFAULT_POOL_ACQUISITION_TIMEOUT = 60 * 1000 // 60 seconds const DEFAULT_POOL_MAX_SIZE = 100 @@ -23,24 +25,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: number = 1 -const BOLT_PROTOCOL_V2: number = 2 -const BOLT_PROTOCOL_V3: number = 3 -const BOLT_PROTOCOL_V4_0: number = 4.0 -const BOLT_PROTOCOL_V4_1: number = 4.1 -const BOLT_PROTOCOL_V4_2: number = 4.2 -const BOLT_PROTOCOL_V4_3: number = 4.3 -const BOLT_PROTOCOL_V4_4: number = 4.4 -const BOLT_PROTOCOL_V5_0: number = 5.0 -const BOLT_PROTOCOL_V5_1: number = 5.1 -const BOLT_PROTOCOL_V5_2: number = 5.2 -const BOLT_PROTOCOL_V5_3: number = 5.3 -const BOLT_PROTOCOL_V5_4: number = 5.4 -const BOLT_PROTOCOL_V5_5: number = 5.5 -const BOLT_PROTOCOL_V5_6: number = 5.6 -const BOLT_PROTOCOL_V5_7: number = 5.7 -const BOLT_PROTOCOL_V5_8: number = 5.8 -const BOLT_PROTOCOL_V6_0: number = 6.0 +const BOLT_PROTOCOL_V1: ProtocolVersion = new ProtocolVersion(1, 0) +const BOLT_PROTOCOL_V2: ProtocolVersion = new ProtocolVersion(2, 0) +const BOLT_PROTOCOL_V3: ProtocolVersion = new ProtocolVersion(3, 0) +const BOLT_PROTOCOL_V4_0: ProtocolVersion = new ProtocolVersion(4, 0) +const BOLT_PROTOCOL_V4_1: ProtocolVersion = new ProtocolVersion(4, 1) +const BOLT_PROTOCOL_V4_2: ProtocolVersion = new ProtocolVersion(4, 2) +const BOLT_PROTOCOL_V4_3: ProtocolVersion = new ProtocolVersion(4, 3) +const BOLT_PROTOCOL_V4_4: ProtocolVersion = new ProtocolVersion(4, 4) +const BOLT_PROTOCOL_V5_0: ProtocolVersion = new ProtocolVersion(5, 0) +const BOLT_PROTOCOL_V5_1: ProtocolVersion = new ProtocolVersion(5, 1) +const BOLT_PROTOCOL_V5_2: ProtocolVersion = new ProtocolVersion(5, 2) +const BOLT_PROTOCOL_V5_3: ProtocolVersion = new ProtocolVersion(5, 3) +const BOLT_PROTOCOL_V5_4: ProtocolVersion = new ProtocolVersion(5, 4) +const BOLT_PROTOCOL_V5_5: ProtocolVersion = new ProtocolVersion(5, 5) +const BOLT_PROTOCOL_V5_6: ProtocolVersion = new ProtocolVersion(5, 6) +const BOLT_PROTOCOL_V5_7: ProtocolVersion = new ProtocolVersion(5, 7) +const BOLT_PROTOCOL_V5_8: ProtocolVersion = new ProtocolVersion(5, 8) +const BOLT_PROTOCOL_V6_0: ProtocolVersion = new ProtocolVersion(6, 0) const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/core/src/internal/protocol-version.ts b/packages/core/src/internal/protocol-version.ts new file mode 100644 index 000000000..4a2fd2b89 --- /dev/null +++ b/packages/core/src/internal/protocol-version.ts @@ -0,0 +1,50 @@ +export class ProtocolVersion { + private readonly major: number + private readonly minor: number + constructor (major: number, minor: number) { + this.major = major + this.minor = minor + } + + getMajor (): number { + return this.major + } + + getMinor (): number { + return this.major + } + + isLessThan (other: ProtocolVersion): boolean { + if (this.major < other.major) { + return true + } else if (this.major === other.major && this.minor < other.minor) { + return true + } + return false + } + + isGreaterThan (other: ProtocolVersion): boolean { + if (this.major > other.major) { + return true + } else if (this.major === other.major && this.minor > other.minor) { + return true + } + return false + } + + isGreaterOrEqualTo (other: ProtocolVersion): boolean { + return !this.isLessThan(other) + } + + isLessOrEqualTo (other: ProtocolVersion): boolean { + return !this.isGreaterThan(other) + } + + equalTo (other: ProtocolVersion): boolean { + return this.major === other.major && this.minor === other.minor + } + + toString (): string { + return this.major.toString() + '.' + this.minor.toString() + } +} diff --git a/packages/core/src/result-summary.ts b/packages/core/src/result-summary.ts index 8ffdc8b45..fbfa21085 100644 --- a/packages/core/src/result-summary.ts +++ b/packages/core/src/result-summary.ts @@ -19,6 +19,7 @@ import Integer from './integer' import { NumberOrInteger } from './graph-types' import { util } from './internal' import GqlStatusObject, { Notification, buildGqlStatusObjectFromMetadata, buildNotificationsFromMetadata } from './notification' +import { ProtocolVersion } from './internal/protocol-version' /** * A ResultSummary instance contains structured metadata for a {@link Result}. @@ -42,13 +43,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {number|undefined} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: number + protocolVersion?: ProtocolVersion ) { /** * The query and parameters this summary is for. @@ -434,7 +435,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: number + protocolVersion?: ProtocolVersion agent?: string /** @@ -442,9 +443,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {number} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: number) { + constructor (serverMeta?: any, protocolVersion?: ProtocolVersion) { if (serverMeta != null) { /** * The server adress @@ -463,7 +464,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {number} + * @type {ProtocolVersion} * @public */ this.protocolVersion = protocolVersion diff --git a/packages/core/test/driver.test.ts b/packages/core/test/driver.test.ts index 2c1b1055d..8b45f1714 100644 --- a/packages/core/test/driver.test.ts +++ b/packages/core/test/driver.test.ts @@ -25,6 +25,7 @@ import { LogLevel } from '../src/types' import resultTransformers from '../src/result-transformers' import Record, { RecordShape } from '../src/record' import { invalidNotificationFilters, validNotificationFilters } from './utils/notification-filters.fixtures' +import { ProtocolVersion } from '../src/internal/protocol-version' describe('Driver', () => { let driver: Driver | null @@ -391,7 +392,7 @@ describe('Driver', () => { const expected: EagerResult = { keys: ['a'], records: [], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) @@ -414,7 +415,7 @@ describe('Driver', () => { const expected: EagerResult = { keys: ['a'], records: [], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) @@ -447,7 +448,7 @@ describe('Driver', () => { records: [ new Record(['name', 'age'], ['A Person', 25]) ], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) diff --git a/packages/core/test/result-summary.test.ts b/packages/core/test/result-summary.test.ts index 69c28595f..051970c58 100644 --- a/packages/core/test/result-summary.test.ts +++ b/packages/core/test/result-summary.test.ts @@ -16,6 +16,7 @@ */ import { int } from '../src' +import { ProtocolVersion } from '../src/internal/protocol-version' import { ServerInfo, ProfiledPlan, @@ -29,10 +30,10 @@ describe('ServerInfo', () => { it.each([ [ { address: '192.168.0.1', version: 'neo4j' }, - 4.3, + new ProtocolVersion(4, 3), { address: '192.168.0.1', - protocolVersion: 4.3, + protocolVersion: new ProtocolVersion(4, 3), agent: 'neo4j' } ], @@ -45,7 +46,7 @@ describe('ServerInfo', () => { agent: 'neo4j' } ], - [undefined, 4.3, { protocolVersion: 4.3 }], + [undefined, new ProtocolVersion(4, 3), { protocolVersion: new ProtocolVersion(4, 3) }], [undefined, undefined, {}] ])( 'new ServerInfo(%o, %i) === %j', diff --git a/packages/core/test/result.test.ts b/packages/core/test/result.test.ts index fcba57ad0..4cbc08950 100644 --- a/packages/core/test/result.test.ts +++ b/packages/core/test/result.test.ts @@ -26,6 +26,7 @@ import ResultStreamObserverMock from './utils/result-stream-observer.mock' import Result from '../src/result' import FakeConnection from './utils/connection.fake' import { Logger } from '../src/internal/logger' +import { ProtocolVersion } from '../src/internal/protocol-version' interface AB { a: number @@ -188,7 +189,7 @@ describe('Result', () => { resultAvailableAfter: 124, extraInfo: 'extra' } - const protocolVersion = 5.0 + const protocolVersion = new ProtocolVersion(5, 0) const expectedSummary = new ResultSummary( expected.query, @@ -462,7 +463,7 @@ describe('Result', () => { expect(releaseConnection).toHaveBeenCalled() }) - it.each([123, undefined])( + it.each([new ProtocolVersion(123, 0), undefined])( 'should enrich summary with the protocol version onCompleted', async version => { const connectionMock = new FakeConnection() @@ -470,7 +471,7 @@ describe('Result', () => { // this test is considering the situation where protocol version // is undefined, which should not happen during normal driver // operation. - connectionMock.protocolVersion = version as unknown as number + connectionMock.protocolVersion = version as unknown as ProtocolVersion connectionHolderMock.getConnection = async (): Promise => { return connectionMock @@ -676,7 +677,7 @@ describe('Result', () => { expect(releaseConnection).toHaveBeenCalled() }) - it.each([123, undefined])( + it.each([new ProtocolVersion(123, 0), undefined])( 'should enrich summary with the protocol version on completed', async version => { const connectionMock = new FakeConnection() @@ -684,7 +685,7 @@ describe('Result', () => { // this test is considering the situation where protocol version // is undefined, which should not happen during normal driver // operation. - connectionMock.protocolVersion = version as unknown as number + connectionMock.protocolVersion = version as unknown as ProtocolVersion connectionHolderMock.getConnection = async (): Promise => { return await Promise.resolve(connectionMock) diff --git a/packages/core/test/utils/connection.fake.ts b/packages/core/test/utils/connection.fake.ts index 6153c3d0c..ef5fb176f 100644 --- a/packages/core/test/utils/connection.fake.ts +++ b/packages/core/test/utils/connection.fake.ts @@ -18,6 +18,7 @@ import { Connection, ResultObserver, ResultSummary } from '../../src' import { BeginTransactionConfig, CommitTransactionConfig, RollbackConnectionConfig, RunQueryConfig } from '../../src/connection' import { ResultStreamObserver } from '../../src/internal/observers' +import { ProtocolVersion } from '../../src/internal/protocol-version' /** * This class is like a mock of {@link Connection} that tracks invocations count. @@ -38,7 +39,7 @@ export default class FakeConnection extends Connection { public seenParameters: any[] public seenProtocolOptions: any[] private readonly _server: any - public protocolVersion: number + public protocolVersion: ProtocolVersion public protocolErrorsHandled: number public seenProtocolErrors: string[] public seenRequestRoutingInformation: any[] @@ -61,7 +62,7 @@ export default class FakeConnection extends Connection { this.seenParameters = [] this.seenProtocolOptions = [] this._server = {} - this.protocolVersion = 1 + this.protocolVersion = new ProtocolVersion(1, 0) this.protocolErrorsHandled = 0 this.seenProtocolErrors = [] this.seenRequestRoutingInformation = [] @@ -119,7 +120,7 @@ export default class FakeConnection extends Connection { return mockResultStreamObserver('ROLLBACK', {}) } - getProtocolVersion (): number { + getProtocolVersion (): ProtocolVersion { return this.protocolVersion } @@ -152,7 +153,7 @@ export default class FakeConnection extends Connection { this.seenProtocolErrors.push(message) } - withProtocolVersion (version: number): FakeConnection { + withProtocolVersion (version: ProtocolVersion): FakeConnection { this.protocolVersion = version return this } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js index a83f32f5a..ae6cb1b63 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js @@ -100,7 +100,7 @@ export default class BoltProtocol { } /** - * Returns the numerical version identifier for this protocol + * Returns the stringified version identifier for this protocol */ get version () { return BOLT_PROTOCOL_V1 diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js index cea9b1dd4..9c8885202 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js @@ -15,7 +15,7 @@ * limitations under the License. */ -import { newError } from '../../core/index.ts' +import { newError, ProtocolVersion } from '../../core/index.ts' import BoltProtocolV1 from './bolt-protocol-v1.js' import BoltProtocolV2 from './bolt-protocol-v2.js' import BoltProtocolV3 from './bolt-protocol-v3.js' @@ -112,8 +112,11 @@ function createProtocol ( onProtocolError, log ) { - switch (version) { - case 1: + if (!(version instanceof ProtocolVersion) || version === undefined || version === null) { + throw newError('Unknown Bolt protocol version: ' + version) + } + switch (version.toString()) { + case '1.0': return new BoltProtocolV1( server, chunker, @@ -122,7 +125,7 @@ function createProtocol ( log, onProtocolError ) - case 2: + case '2.0': return new BoltProtocolV2( server, chunker, @@ -131,7 +134,7 @@ function createProtocol ( log, onProtocolError ) - case 3: + case '3.0': return new BoltProtocolV3( server, chunker, @@ -140,7 +143,7 @@ function createProtocol ( log, onProtocolError ) - case 4.0: + case '4.0': return new BoltProtocolV4x0( server, chunker, @@ -149,7 +152,7 @@ function createProtocol ( log, onProtocolError ) - case 4.1: + case '4.1': return new BoltProtocolV4x1( server, chunker, @@ -159,7 +162,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.2: + case '4.2': return new BoltProtocolV4x2( server, chunker, @@ -169,7 +172,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.3: + case '4.3': return new BoltProtocolV4x3( server, chunker, @@ -179,7 +182,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.4: + case '4.4': return new BoltProtocolV4x4( server, chunker, @@ -189,7 +192,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.0: + case '5.0': return new BoltProtocolV5x0( server, chunker, @@ -199,7 +202,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.1: + case '5.1': return new BoltProtocolV5x1( server, chunker, @@ -209,7 +212,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.2: + case '5.2': return new BoltProtocolV5x2( server, chunker, @@ -219,7 +222,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.3: + case '5.3': return new BoltProtocolV5x3(server, chunker, packingConfig, @@ -227,7 +230,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.4: + case '5.4': return new BoltProtocolV5x4(server, chunker, packingConfig, @@ -235,7 +238,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.5: + case '5.5': return new BoltProtocolV5x5(server, chunker, packingConfig, @@ -243,7 +246,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.6: + case '5.6': return new BoltProtocolV5x6(server, chunker, packingConfig, @@ -251,7 +254,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.7: + case '5.7': return new BoltProtocolV5x7(server, chunker, packingConfig, @@ -259,7 +262,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.8: + case '5.8': return new BoltProtocolV5x8(server, chunker, packingConfig, @@ -267,7 +270,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 6.0: + case '6.0': return new BoltProtocolV6x0(server, chunker, packingConfig, diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js index adcf1624f..91276257a 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js @@ -16,7 +16,7 @@ */ import { alloc } from '../channel/index.js' -import { newError } from '../../core/index.ts' +import { newError, ProtocolVersion } from '../../core/index.ts' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference @@ -69,7 +69,7 @@ function parseNegotiatedResponse (buffer, log) { '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' ) } - return Number(h[3] + '.' + h[2]) + return new ProtocolVersion(h[3], h[2]) } function handshakeNegotiationV2 (channel, buffer, log) { @@ -112,7 +112,7 @@ function handshakeNegotiationV2 (channel, buffer, log) { selectionBuffer.writeVarInt(capabilites) channel.write(selectionBuffer) resolve({ - protocolVersion: Number(major + '.' + minor), + protocolVersion: new ProtocolVersion(major, minor), capabilites, consumeRemainingBuffer: consumer => { if (buffer.hasRemaining()) { @@ -146,7 +146,7 @@ function newHandshakeBuffer () { */ /** * @typedef HandshakeResult - * @property {number} protocolVersion The protocol version negotiated in the handshake + * @property {ProtocolVersion} protocolVersion The protocol version negotiated in the handshake * @property {number} capabilites A bitmask representing the capabilities negotiated in the handshake * @property {function(BufferConsumerCallback)} consumeRemainingBuffer A function to consume the remaining buffer if it exists */ @@ -160,7 +160,7 @@ function newHandshakeBuffer () { */ export default function handshake (channel, log) { return initialHandshake(channel, log).then((result) => { - if (result.protocolVersion === 255.1) { + if (result.protocolVersion.equalTo(new ProtocolVersion(255, 1))) { return handshakeNegotiationV2(channel, result.buffer, log) } else { return result diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js index 94d864865..ce8d3c048 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js index 1fc1e8639..23f3a23af 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } @@ -611,7 +611,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider const connectionProvider = new SingleConnectionProvider(delegateConnection) const protocolVersion = connection.protocol().version - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return [new Session({ mode: WRITE, bookmarks: Bookmarks.empty(), diff --git a/packages/neo4j-driver-deno/lib/core/connection-provider.ts b/packages/neo4j-driver-deno/lib/core/connection-provider.ts index c77e64501..4f165500d 100644 --- a/packages/neo4j-driver-deno/lib/core/connection-provider.ts +++ b/packages/neo4j-driver-deno/lib/core/connection-provider.ts @@ -18,6 +18,7 @@ import Connection from './connection.ts' import { bookmarks } from './internal/index.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' import { ServerInfo } from './result-summary.ts' import { AuthToken } from './types.ts' @@ -155,7 +156,7 @@ class ConnectionProvider { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { throw Error('Not Implemented') } diff --git a/packages/neo4j-driver-deno/lib/core/connection.ts b/packages/neo4j-driver-deno/lib/core/connection.ts index b45e746ca..40bee0ecf 100644 --- a/packages/neo4j-driver-deno/lib/core/connection.ts +++ b/packages/neo4j-driver-deno/lib/core/connection.ts @@ -19,6 +19,7 @@ import { Bookmarks } from './internal/bookmarks.ts' import { AccessMode, TelemetryApis } from './internal/constants.ts' import { ResultStreamObserver } from './internal/observers.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' import { TxConfig } from './internal/tx-config.ts' import NotificationFilter from './notification-filter.ts' @@ -131,7 +132,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): number { + getProtocolVersion (): ProtocolVersion { throw new Error('Not implemented') } diff --git a/packages/neo4j-driver-deno/lib/core/driver.ts b/packages/neo4j-driver-deno/lib/core/driver.ts index 1f8019cfb..7248e9026 100644 --- a/packages/neo4j-driver-deno/lib/core/driver.ts +++ b/packages/neo4j-driver-deno/lib/core/driver.ts @@ -48,6 +48,7 @@ import { newError } from './error.ts' import NotificationFilter from './notification-filter.ts' import HomeDatabaseCache from './internal/homedb-cache.ts' import { cacheKey } from './internal/auth-util.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' const DEFAULT_MAX_CONNECTION_LIFETIME: number = 60 * 60 * 1000 // 1 hour @@ -739,7 +740,7 @@ class Driver { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { const connectionProvider = this._getOrCreateConnectionProvider() return connectionProvider.getNegotiatedProtocolVersion() } diff --git a/packages/neo4j-driver-deno/lib/core/index.ts b/packages/neo4j-driver-deno/lib/core/index.ts index b22a6600b..ec1efe74b 100644 --- a/packages/neo4j-driver-deno/lib/core/index.ts +++ b/packages/neo4j-driver-deno/lib/core/index.ts @@ -103,6 +103,7 @@ import resultTransformers, { ResultTransformer } from './result-transformers.ts' import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate.ts' import * as internal from './internal/index.ts' import Vector, { VectorType, vector } from './vector.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' /** * Object containing string constants representing predefined {@link Neo4jError} codes. @@ -189,7 +190,8 @@ const forExport = { notificationFilterDisabledClassification, notificationFilterMinimumSeverityLevel, clientCertificateProviders, - resolveCertificateProvider + resolveCertificateProvider, + ProtocolVersion } export { @@ -269,7 +271,8 @@ export { clientCertificateProviders, resolveCertificateProvider, Vector, - vector + vector, + ProtocolVersion } export type { diff --git a/packages/neo4j-driver-deno/lib/core/internal/constants.ts b/packages/neo4j-driver-deno/lib/core/internal/constants.ts index 7403677c3..b709889e3 100644 --- a/packages/neo4j-driver-deno/lib/core/internal/constants.ts +++ b/packages/neo4j-driver-deno/lib/core/internal/constants.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import { ProtocolVersion } from './protocol-version.ts' + const FETCH_ALL = -1 const DEFAULT_POOL_ACQUISITION_TIMEOUT = 60 * 1000 // 60 seconds const DEFAULT_POOL_MAX_SIZE = 100 @@ -23,24 +25,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: number = 1 -const BOLT_PROTOCOL_V2: number = 2 -const BOLT_PROTOCOL_V3: number = 3 -const BOLT_PROTOCOL_V4_0: number = 4.0 -const BOLT_PROTOCOL_V4_1: number = 4.1 -const BOLT_PROTOCOL_V4_2: number = 4.2 -const BOLT_PROTOCOL_V4_3: number = 4.3 -const BOLT_PROTOCOL_V4_4: number = 4.4 -const BOLT_PROTOCOL_V5_0: number = 5.0 -const BOLT_PROTOCOL_V5_1: number = 5.1 -const BOLT_PROTOCOL_V5_2: number = 5.2 -const BOLT_PROTOCOL_V5_3: number = 5.3 -const BOLT_PROTOCOL_V5_4: number = 5.4 -const BOLT_PROTOCOL_V5_5: number = 5.5 -const BOLT_PROTOCOL_V5_6: number = 5.6 -const BOLT_PROTOCOL_V5_7: number = 5.7 -const BOLT_PROTOCOL_V5_8: number = 5.8 -const BOLT_PROTOCOL_V6_0: number = 6.0 +const BOLT_PROTOCOL_V1: ProtocolVersion = new ProtocolVersion(1, 0) +const BOLT_PROTOCOL_V2: ProtocolVersion = new ProtocolVersion(2, 0) +const BOLT_PROTOCOL_V3: ProtocolVersion = new ProtocolVersion(3, 0) +const BOLT_PROTOCOL_V4_0: ProtocolVersion = new ProtocolVersion(4, 0) +const BOLT_PROTOCOL_V4_1: ProtocolVersion = new ProtocolVersion(4, 1) +const BOLT_PROTOCOL_V4_2: ProtocolVersion = new ProtocolVersion(4, 2) +const BOLT_PROTOCOL_V4_3: ProtocolVersion = new ProtocolVersion(4, 3) +const BOLT_PROTOCOL_V4_4: ProtocolVersion = new ProtocolVersion(4, 4) +const BOLT_PROTOCOL_V5_0: ProtocolVersion = new ProtocolVersion(5, 0) +const BOLT_PROTOCOL_V5_1: ProtocolVersion = new ProtocolVersion(5, 1) +const BOLT_PROTOCOL_V5_2: ProtocolVersion = new ProtocolVersion(5, 2) +const BOLT_PROTOCOL_V5_3: ProtocolVersion = new ProtocolVersion(5, 3) +const BOLT_PROTOCOL_V5_4: ProtocolVersion = new ProtocolVersion(5, 4) +const BOLT_PROTOCOL_V5_5: ProtocolVersion = new ProtocolVersion(5, 5) +const BOLT_PROTOCOL_V5_6: ProtocolVersion = new ProtocolVersion(5, 6) +const BOLT_PROTOCOL_V5_7: ProtocolVersion = new ProtocolVersion(5, 7) +const BOLT_PROTOCOL_V5_8: ProtocolVersion = new ProtocolVersion(5, 8) +const BOLT_PROTOCOL_V6_0: ProtocolVersion = new ProtocolVersion(6, 0) const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts b/packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts new file mode 100644 index 000000000..4a2fd2b89 --- /dev/null +++ b/packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts @@ -0,0 +1,50 @@ +export class ProtocolVersion { + private readonly major: number + private readonly minor: number + constructor (major: number, minor: number) { + this.major = major + this.minor = minor + } + + getMajor (): number { + return this.major + } + + getMinor (): number { + return this.major + } + + isLessThan (other: ProtocolVersion): boolean { + if (this.major < other.major) { + return true + } else if (this.major === other.major && this.minor < other.minor) { + return true + } + return false + } + + isGreaterThan (other: ProtocolVersion): boolean { + if (this.major > other.major) { + return true + } else if (this.major === other.major && this.minor > other.minor) { + return true + } + return false + } + + isGreaterOrEqualTo (other: ProtocolVersion): boolean { + return !this.isLessThan(other) + } + + isLessOrEqualTo (other: ProtocolVersion): boolean { + return !this.isGreaterThan(other) + } + + equalTo (other: ProtocolVersion): boolean { + return this.major === other.major && this.minor === other.minor + } + + toString (): string { + return this.major.toString() + '.' + this.minor.toString() + } +} diff --git a/packages/neo4j-driver-deno/lib/core/result-summary.ts b/packages/neo4j-driver-deno/lib/core/result-summary.ts index 2a1bedc1e..7dabd337c 100644 --- a/packages/neo4j-driver-deno/lib/core/result-summary.ts +++ b/packages/neo4j-driver-deno/lib/core/result-summary.ts @@ -19,6 +19,7 @@ import Integer from './integer.ts' import { NumberOrInteger } from './graph-types.ts' import { util } from './internal/index.ts' import GqlStatusObject, { Notification, buildGqlStatusObjectFromMetadata, buildNotificationsFromMetadata } from './notification.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' /** * A ResultSummary instance contains structured metadata for a {@link Result}. @@ -42,13 +43,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {number|undefined} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: number + protocolVersion?: ProtocolVersion ) { /** * The query and parameters this summary is for. @@ -434,7 +435,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: number + protocolVersion?: ProtocolVersion agent?: string /** @@ -442,9 +443,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {number} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: number) { + constructor (serverMeta?: any, protocolVersion?: ProtocolVersion) { if (serverMeta != null) { /** * The server adress @@ -463,7 +464,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {number} + * @type {ProtocolVersion} * @public */ this.protocolVersion = protocolVersion diff --git a/packages/neo4j-driver-lite/test/unit/index.test.ts b/packages/neo4j-driver-lite/test/unit/index.test.ts index 98971e38a..e80264abe 100644 --- a/packages/neo4j-driver-lite/test/unit/index.test.ts +++ b/packages/neo4j-driver-lite/test/unit/index.test.ts @@ -58,7 +58,7 @@ import neo4j, { RecordShape } from '../../' -import { internal } from 'neo4j-driver-core' +import { internal, ProtocolVersion } from 'neo4j-driver-core' const { logger: { Logger } @@ -261,7 +261,7 @@ describe('index', () => { supportsTransactionConfig: async () => true, supportsUserImpersonation: async () => true, verifyConnectivityAndGetServerInfo: async () => new ServerInfo({}), - getNegotiatedProtocolVersion: async () => 5.0, + getNegotiatedProtocolVersion: async () => new ProtocolVersion(5, 0), verifyAuthentication: async () => true, supportsSessionAuth: async () => true, SSREnabled: () => false diff --git a/packages/neo4j-driver/test/driver.test.js b/packages/neo4j-driver/test/driver.test.js index 7332de92b..66001d9b1 100644 --- a/packages/neo4j-driver/test/driver.test.js +++ b/packages/neo4j-driver/test/driver.test.js @@ -591,7 +591,7 @@ describe('#integration driver', () => { `neo4j://${sharedNeo4j.hostnameWithBoltPort}`, sharedNeo4j.authToken ) - if (protocolVersion >= 5.8) { + if (protocolVersion.isGreaterOrEqualTo({ major: 5, minor: 8 })) { try { const session1 = driver.session(auth) await session1.run('CREATE () RETURN 42') diff --git a/packages/neo4j-driver/test/examples.test.js b/packages/neo4j-driver/test/examples.test.js index cfec25faf..688889f98 100644 --- a/packages/neo4j-driver/test/examples.test.js +++ b/packages/neo4j-driver/test/examples.test.js @@ -118,7 +118,7 @@ describe('#integration examples', () => { }, 60000) it('rx autocommit transaction example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -617,7 +617,7 @@ describe('#integration examples', () => { }) it('rx result consume example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -795,7 +795,7 @@ describe('#integration examples', () => { }, 60000) it('rx transaction function example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -898,7 +898,7 @@ describe('#integration examples', () => { }, 60000) it('use another database example', async () => { - if (protocolVersion < 4.0 || edition !== 'enterprise') { + if (protocolVersion.isLessThan({ major: 4, minor: 0 }) || edition !== 'enterprise') { return } diff --git a/packages/neo4j-driver/test/internal/connection-channel.test.js b/packages/neo4j-driver/test/internal/connection-channel.test.js index 7e42a8c6a..b3bd61aa7 100644 --- a/packages/neo4j-driver/test/internal/connection-channel.test.js +++ b/packages/neo4j-driver/test/internal/connection-channel.test.js @@ -428,7 +428,7 @@ describe('#integration ChannelConnection', () => { expect(messages[0].signature).toEqual(0x01) // first message is either INIT or HELLO const protocolVersion = connection.protocol().version - if (protocolVersion >= 3) { + if (protocolVersion.isLessThan({ major: 3, minor: 0 })) { expect(messages[messages.length - 1].signature).toEqual(0x02) // last message is GOODBYE in V3 } }) diff --git a/packages/neo4j-driver/test/rx/navigation.test.js b/packages/neo4j-driver/test/rx/navigation.test.js index e8f0a7d6d..9252378f2 100644 --- a/packages/neo4j-driver/test/rx/navigation.test.js +++ b/packages/neo4j-driver/test/rx/navigation.test.js @@ -380,7 +380,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeys (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -401,7 +401,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -415,7 +415,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysAndRecords (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -432,7 +432,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnRecordsAndSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -449,7 +449,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysRecordsAndSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -470,7 +470,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -495,7 +495,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -515,7 +515,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -532,7 +532,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysMultipleTimes (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -551,7 +551,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummaryMultipleTimes (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -570,7 +570,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnRecordsOnlyOnce (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -596,7 +596,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -619,7 +619,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -636,7 +636,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -651,7 +651,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnKeysWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -674,7 +674,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -693,7 +693,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnRecordsWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -716,7 +716,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -742,7 +742,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnSummaryWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -765,7 +765,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -800,7 +800,7 @@ describe('#integration-rx navigation', () => { selectObservable, closeFunc ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/nested-statements.test.js b/packages/neo4j-driver/test/rx/nested-statements.test.js index 08de9eecd..2ba854eff 100644 --- a/packages/neo4j-driver/test/rx/nested-statements.test.js +++ b/packages/neo4j-driver/test/rx/nested-statements.test.js @@ -56,7 +56,7 @@ describe('#integration-rx transaction', () => { it('should handle nested queries within one transaction', async () => { const size = 1024 - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -93,7 +93,7 @@ describe('#integration-rx transaction', () => { it('should give proper error when nesting queries within one session', async () => { const size = 1024 - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/session.test.js b/packages/neo4j-driver/test/rx/session.test.js index d74915711..1c5fbdd4e 100644 --- a/packages/neo4j-driver/test/rx/session.test.js +++ b/packages/neo4j-driver/test/rx/session.test.js @@ -56,7 +56,7 @@ describe('#integration rx-session', () => { }) it('should be able to run a simple query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -80,7 +80,7 @@ describe('#integration rx-session', () => { }, 60000) it('should be able to reuse session after failure', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -109,7 +109,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transactions without retries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -131,7 +131,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on reactive failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -158,7 +158,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on synchronous failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -185,7 +185,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail on transactions that cannot be retried', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -208,7 +208,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail even after a transient error', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -239,7 +239,7 @@ describe('#integration rx-session', () => { describe('.executeWrite()', () => { it('should run transactions without retries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -261,7 +261,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on reactive failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -288,7 +288,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on synchronous failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -315,7 +315,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail on transactions that cannot be retried', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -338,7 +338,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail even after a transient error', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/summary.test.js b/packages/neo4j-driver/test/rx/summary.test.js index 0c9b6d7a9..228c5ebeb 100644 --- a/packages/neo4j-driver/test/rx/summary.test.js +++ b/packages/neo4j-driver/test/rx/summary.test.js @@ -260,7 +260,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnNonNullSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -277,7 +277,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummaryWithQueryText (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -295,7 +295,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -314,7 +314,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -333,7 +333,7 @@ describe('#integration-rx summary', () => { session, useTransaction = false ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -370,7 +370,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -402,7 +402,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -440,7 +440,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -472,7 +472,7 @@ describe('#integration-rx summary', () => { driver, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -513,7 +513,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -544,7 +544,7 @@ describe('#integration-rx summary', () => { driver, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -582,7 +582,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldNotReturnPlanAndProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -602,7 +602,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnPlanButNoProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -623,7 +623,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnPlanAndProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -645,7 +645,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldNotReturnNotification (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -663,7 +663,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnNotification (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/transaction.test.js b/packages/neo4j-driver/test/rx/transaction.test.js index 1aaf44ab3..cc28f94e0 100644 --- a/packages/neo4j-driver/test/rx/transaction.test.js +++ b/packages/neo4j-driver/test/rx/transaction.test.js @@ -55,7 +55,7 @@ describe('#integration-rx transaction', () => { }) it('should commit an empty transaction', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -72,7 +72,7 @@ describe('#integration-rx transaction', () => { }) it('should rollback an empty transaction', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -89,7 +89,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -118,7 +118,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -147,7 +147,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and close', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -200,7 +200,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after a failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -224,7 +224,7 @@ describe('#integration-rx transaction', () => { }) it('should succeed to rollback after a failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -240,7 +240,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after successful and failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -266,7 +266,7 @@ describe('#integration-rx transaction', () => { }) it('should succeed to rollback after successful and failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -284,7 +284,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to run another query after a failed one', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -309,7 +309,7 @@ describe('#integration-rx transaction', () => { }) it('should not allow commit after commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -334,7 +334,7 @@ describe('#integration-rx transaction', () => { }) it('should not allow rollback after rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -359,7 +359,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to rollback after commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -384,7 +384,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -417,7 +417,7 @@ describe('#integration-rx transaction', () => { }) it('should update bookmarks', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -441,7 +441,7 @@ describe('#integration-rx transaction', () => { }) it('should propagate failures from queries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -473,7 +473,7 @@ describe('#integration-rx transaction', () => { }) it('should not run until subscribed', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -517,7 +517,7 @@ describe('#integration-rx transaction', () => { it('should not propagate run failure from summary', async () => { pending('behaviour difference across drivers') - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -539,7 +539,7 @@ describe('#integration-rx transaction', () => { }) async function verifyNoFailureIfNotExecuted (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -551,7 +551,7 @@ describe('#integration-rx transaction', () => { } async function verifyFailToRunQueryAfterTxcIsComplete (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -576,7 +576,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueries (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -600,7 +600,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueriesWithoutWaiting (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -626,7 +626,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueriesWithoutStreaming (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/spatial-types.test.js b/packages/neo4j-driver/test/spatial-types.test.js index 94d1be2b4..5a1e766d8 100644 --- a/packages/neo4j-driver/test/spatial-types.test.js +++ b/packages/neo4j-driver/test/spatial-types.test.js @@ -309,7 +309,7 @@ describe('#integration spatial-types', () => { } function neo4jDoesNotSupportPoints (done) { - if (protocolVersion < 2) { + if (protocolVersion.isLessThan({ major: 2, minor: 0 })) { done() return true } diff --git a/packages/neo4j-driver/test/temporal-types.test.js b/packages/neo4j-driver/test/temporal-types.test.js index 9d43932b3..86eed37b8 100644 --- a/packages/neo4j-driver/test/temporal-types.test.js +++ b/packages/neo4j-driver/test/temporal-types.test.js @@ -1466,7 +1466,7 @@ describe('#integration temporal-types', () => { } function neo4jDoesNotSupportTemporalTypes () { - if (protocolVersion < 2) { + if (protocolVersion?.isLessThan({ major: 2, minor: 0 })) { return true } return false diff --git a/packages/neo4j-driver/test/vector-type.test.js b/packages/neo4j-driver/test/vector-type.test.js index 713022291..e27287a26 100644 --- a/packages/neo4j-driver/test/vector-type.test.js +++ b/packages/neo4j-driver/test/vector-type.test.js @@ -47,7 +47,7 @@ describe('#integration vector type', () => { }) it('write and read vectors', async () => { - if (protocolVersion >= 6.0 && edition === 'enterprise') { + if (protocolVersion.isGreaterOrEqualTo({ major: 6, minor: 0 }) && edition === 'enterprise') { const driver = driverGlobal const bufferWriter = Uint8Array.from([1, 1]) diff --git a/packages/testkit-backend/src/responses.js b/packages/testkit-backend/src/responses.js index b78324672..ad08e3b73 100644 --- a/packages/testkit-backend/src/responses.js +++ b/packages/testkit-backend/src/responses.js @@ -69,7 +69,7 @@ export function Bookmarks ({ bookmarks }) { export function ServerInfo ({ serverInfo }) { return response('ServerInfo', { ...serverInfo, - protocolVersion: serverInfo.protocolVersion.toFixed(1) + protocolVersion: serverInfo.protocolVersion.toString() }) } diff --git a/packages/testkit-backend/src/summary-binder.js b/packages/testkit-backend/src/summary-binder.js index 9f13f75a5..ccbc85a89 100644 --- a/packages/testkit-backend/src/summary-binder.js +++ b/packages/testkit-backend/src/summary-binder.js @@ -69,7 +69,7 @@ export function nativeToTestkitSummary (summary, binder) { }, serverInfo: { agent: summary.server.agent, - protocolVersion: summary.server.protocolVersion.toFixed(1) + protocolVersion: summary.server.protocolVersion.toString() }, counters: mapCounters(summary.counters), plan: mapPlan(summary.plan),