Skip to content

Commit

Permalink
test: check zlib version for createDeflateRaw
Browse files Browse the repository at this point in the history
We are currenly builing Node with --shared-zlib which happens to be
version 1.2.8. The test for zlib.createDeflateRaw is expected to fail
but does not when using version 1.2.8.

As far as I can tell the fix referred to in the comments was
introduced in version 1.2.9:
- Reject a window size of 256 bytes if not using the zlib wrapper

This commit suggests adding a check for the version and skipping this
assert if the version is less than 1.2.9.

Refs: http://zlib.net/ChangeLog.txt
PR-URL: #13697
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
danbev authored and addaleax committed Jun 21, 2017
1 parent 0d3b52e commit 10aee10
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/parallel/test-zlib-failed-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ const assert = require('assert');
const zlib = require('zlib');

// For raw deflate encoding, requests for 256-byte windows are rejected as
// invalid by zlib.
// (http://zlib.net/manual.html#Advanced)
assert.throws(() => {
zlib.createDeflateRaw({ windowBits: 8 });
}, /^Error: Init error$/);
// invalid by zlib (http://zlib.net/manual.html#Advanced).
// This check was introduced in version 1.2.9 and prior to that there was
// no such rejection which is the reason for the version check below
// (http://zlib.net/ChangeLog.txt).
if (!/^1\.2\.[0-8]$/.test(process.versions.zlib)) {
assert.throws(() => {
zlib.createDeflateRaw({ windowBits: 8 });
}, /^Error: Init error$/);
}

// Regression tests for bugs in the validation logic.

Expand Down

0 comments on commit 10aee10

Please sign in to comment.