Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sproxyd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=20"
},
"version": "8.2.0",
"version": "8.2.1",
"description": "sproxyd client",
"main": "index.js",
"scripts": {
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/sproxyd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (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" (string)', () => {
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);
Expand Down
Loading