From 1247205ce0d6cbe7ce84377139a7f56978e99a54 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Fri, 26 Jun 2026 16:33:59 +0200 Subject: [PATCH 1/3] support 0 in chordCos Issue: SPRXCLT-25 --- lib/sproxyd.js | 2 +- tests/unit/sproxyd.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/sproxyd.js b/lib/sproxyd.js index 67300ea..3e9ea72 100644 --- a/lib/sproxyd.js +++ b/lib/sproxyd.js @@ -81,7 +81,7 @@ class SproxydClient { this.bootstrap = opts.bootstrap === undefined ? [['localhost', '81']] : _parseBootstrapList(opts.bootstrap); this.bootstrap = shuffle(this.bootstrap); - if (options.chordCos) { + if (options.chordCos !== undefined && options.chordCos !== null) { this.cos = options.chordCos; this.path = options.path || '/proxy/chord/'; } else { diff --git a/tests/unit/sproxyd.js b/tests/unit/sproxyd.js index 0d9d780..20f83cd 100644 --- a/tests/unit/sproxyd.js +++ b/tests/unit/sproxyd.js @@ -374,6 +374,38 @@ const clientImmutableWithFailover = new Sproxy({ }); }); +describe('Sproxyd constructor chordCos', () => { + it('should default to cos 2 when chordCos is absent', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'] }); + assert.strictEqual(c.cos, 0x2); + }); + + it('should default to cos 2 when chordCos is undefined', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: undefined }); + assert.strictEqual(c.cos, 0x2); + }); + + it('should default to cos 2 when chordCos is null', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: null }); + assert.strictEqual(c.cos, 0x2); + }); + + it('should set cos 0 when chordCos is 0', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: 0 }); + assert.strictEqual(c.cos, 0); + }); + + it('should set cos 0 when chordCos is "0"', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: '0' }); + assert.strictEqual(c.cos, '0'); + }); + + it('should set cos when chordCos is a non-zero integer', () => { + const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: 3 }); + assert.strictEqual(c.cos, 3); + }); +}); + describe('Sproxyd client', () => { const client = new Sproxy({ bootstrap: ['127.0.0.1:9000'] }); clientAssert(client.bootstrap, client.path); From 67f4a8658c44ef54ae2bb5d3635972e57022a3ce Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Fri, 26 Jun 2026 17:48:57 +0200 Subject: [PATCH 2/3] Update tests/unit/sproxyd.js Co-authored-by: Mickael Bourgois <35171168+BourgoisMickael@users.noreply.github.com> --- tests/unit/sproxyd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/sproxyd.js b/tests/unit/sproxyd.js index 20f83cd..fbe7ec8 100644 --- a/tests/unit/sproxyd.js +++ b/tests/unit/sproxyd.js @@ -390,12 +390,12 @@ describe('Sproxyd constructor chordCos', () => { assert.strictEqual(c.cos, 0x2); }); - it('should set cos 0 when chordCos is 0', () => { + it('should set cos 0 when chordCos is 0 (integer)', () => { const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: 0 }); assert.strictEqual(c.cos, 0); }); - it('should set cos 0 when chordCos is "0"', () => { + it('should set cos "0" when chordCos is "0" (string)', () => { const c = new Sproxy({ bootstrap: ['127.0.0.1:9000'], chordCos: '0' }); assert.strictEqual(c.cos, '0'); }); From 501829f5521787e7e946de6792f5806ffa6ec437 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Mon, 29 Jun 2026 11:07:05 +0200 Subject: [PATCH 3/3] bump version to 8.2.1 Issue: SPRXCLT-25 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5493a54..61849f7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "engines": { "node": ">=20" }, - "version": "8.2.0", + "version": "8.2.1", "description": "sproxyd client", "main": "index.js", "scripts": {