Skip to content

Commit 3694e01

Browse files
committed
Add test for broken block CRC
The stream CRC is a combination of all block CRCs but the individual block content might not match the block CRC which is a different error.
1 parent 28bf414 commit 3694e01

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/fixtures/brokenblockcrc.bz2

37 Bytes
Binary file not shown.

test/simple.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ test('should emit error when crc is broken', function(t) {
5454
unbz2.end(compressed);
5555
});
5656

57+
test('should emit error when block crc is wrong', function(t) {
58+
t.plan(1);
59+
var compressed = fs.readFileSync('test/fixtures/brokenblockcrc.bz2');
60+
var unbz2 = unbzip2Stream();
61+
unbz2.on('error', function(err) { t.pass(err.message); });
62+
unbz2.pipe(concat());
63+
unbz2.end(compressed);
64+
});
65+
5766
test('should emit error when stream is broken in a different way?', function(t) {
5867
t.plan(1);
5968
// this is the smallest truncated file I found that reproduced the bug, but

0 commit comments

Comments
 (0)