blob: 97d6512100bbf1f205ff5b4b7b8fdb0cddf37182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
'use strict';
const common = require('../common');
const assert = require('assert');
const zlib = require('zlib');
// String "test" encoded with dictionary "dict".
const input = Buffer.from([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5]);
{
const stream = zlib.createInflate();
stream.on('error', common.mustCall(function(err) {
assert(/Missing dictionary/.test(err.message));
}));
stream.write(input);
}
{
const stream = zlib.createInflate({ dictionary: Buffer.from('fail') });
stream.on('error', common.mustCall(function(err) {
assert(/Bad dictionary/.test(err.message));
}));
stream.write(input);
}
{
const stream = zlib.createInflateRaw({ dictionary: Buffer.from('fail') });
stream.on('error', common.mustCall(function(err) {
// It's not possible to separate invalid dict and invalid data when using
// the raw format
assert(/invalid/.test(err.message));
}));
stream.write(input);
}
|