From 01adb7c3cdf26fd54df199c5df01e24e10284d3c Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Wed, 23 Sep 2026 13:26:18 -0400 Subject: [PATCH] chore: make capacity test expectations independent of Buffer.poolSize --- test/capacity_test.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/capacity_test.js b/test/capacity_test.js index c3d635ee..04f504d1 100644 --- a/test/capacity_test.js +++ b/test/capacity_test.js @@ -18,16 +18,18 @@ it('Does not increase capacity when there is sufficient capacity', () => { }) it('Uses exponential doubling capacity scaling', () => { - const res1 = CalculateCapacity(8192, 8193, 1024 * 1024) - assert.deepEqual(res1, [true, 16384]) - const res2 = CalculateCapacity(16384, 16385, 1024 * 1024) - assert.deepEqual(res2, [true, 32768]) + // Capacities at or above Buffer.poolSize are unaffected by the minimum-capacity + // floor, so these exercise pure doubling regardless of the platform's pool size. + const res1 = CalculateCapacity(Buffer.poolSize, Buffer.poolSize + 1, 1024 * 1024) + assert.deepEqual(res1, [true, Buffer.poolSize * 2]) + const res2 = CalculateCapacity(Buffer.poolSize * 2, Buffer.poolSize * 2 + 1, 1024 * 1024) + assert.deepEqual(res2, [true, Buffer.poolSize * 4]) }) it('Uses required capacity when it exceeds doubling', () => { - const [resize, newCapacity] = CalculateCapacity(1024, 16384, 1024 * 1024) + const [resize, newCapacity] = CalculateCapacity(Buffer.poolSize, Buffer.poolSize * 4, 1024 * 1024) assert.equal(resize, true) - assert.equal(newCapacity, 16384) + assert.equal(newCapacity, Buffer.poolSize * 4) }) it('Does not exceed max over allocation', () => {