From 81b5154dccb3b286d0f58447d9df80fe3e842639 Mon Sep 17 00:00:00 2001 From: chad Date: Mon, 30 Jan 2023 21:08:25 -0500 Subject: [PATCH] fix: throw error for non-integer connection limits (#1571) --- src/connection-manager/index.ts | 20 ++++++++++++--- test/connection-manager/index.spec.ts | 37 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/connection-manager/index.ts b/src/connection-manager/index.ts index 0c40953863..80d041589a 100644 --- a/src/connection-manager/index.ts +++ b/src/connection-manager/index.ts @@ -167,12 +167,10 @@ export class DefaultConnectionManager extends EventEmitter { expect(spy).to.have.property('callCount', 1) }) + it('should fail if the connection manager has negative maxConnections limit', async () => { + await expect(createNode({ + config: createBaseOptions({ + connectionManager: { maxConnections: -5 } + }), + started: false + })).to.eventually.rejected('maxConnections must be greater than 0').with.property('code', codes.ERR_INVALID_PARAMETERS) + }) + + it('should fail if the connection manager has negative minConnections limit', async () => { + await expect(createNode({ + config: createBaseOptions({ + connectionManager: { minConnections: -5 } + }), + started: false + })).to.eventually.rejected('minConnections must be greater than 0').with.property('code', codes.ERR_INVALID_PARAMETERS) + }) + + it('should fail if the connection manager has non-integer maxConnections limit', async () => { + await expect(createNode({ + config: createBaseOptions({ + connectionManager: { maxConnections: 1.5 } + }), + started: false + })).to.eventually.rejected('maxConnections must be an integer').with.property('code', codes.ERR_INVALID_PARAMETERS) + }) + + it('should fail if the connection manager has non-integer minConnections limit', async () => { + await expect(createNode({ + config: createBaseOptions({ + connectionManager: { minConnections: 1.5 } + }), + started: false + })).to.eventually.rejected('minConnections must be an integer').with.property('code', codes.ERR_INVALID_PARAMETERS) + }) + it('should fail if the connection manager has mismatched connection limit options', async () => { await expect(createNode({ config: createBaseOptions({