Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit b220149

Browse files
achingbrainAlan Shaw
authored andcommitted
test: add tests for rabin chunking (#74)
1 parent ce1b80e commit b220149

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/files.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,46 @@ describe('files', function () {
321321
)
322322
})
323323

324+
it('rabin chunker', () => {
325+
const chunkSize = 262144
326+
const buffer = Buffer.alloc(chunkSize, 0)
327+
const data = bufferStream(chunkSize, {
328+
generator: (size, callback) => {
329+
callback(null, buffer.slice(0, size))
330+
}
331+
})
332+
const options = {
333+
chunker: 'rabin-512-1024-2048',
334+
pin: false,
335+
preload: false
336+
}
337+
338+
return compare(
339+
testHashesAreEqual(go, data, options),
340+
testHashesAreEqual(js, data, options)
341+
)
342+
})
343+
344+
it('rabin chunker small chunks', () => {
345+
const chunkSize = 262144
346+
const buffer = Buffer.alloc(chunkSize, 0)
347+
const data = bufferStream(chunkSize, {
348+
generator: (size, callback) => {
349+
callback(null, buffer.slice(0, size))
350+
}
351+
})
352+
const options = {
353+
chunker: 'rabin-16-16-16',
354+
pin: false,
355+
preload: false
356+
}
357+
358+
return compare(
359+
testHashesAreEqual(go, data, options),
360+
testHashesAreEqual(js, data, options)
361+
)
362+
})
363+
324364
it('hamt shards', () => {
325365
const data = crypto.randomBytes(100)
326366
const files = []

0 commit comments

Comments
 (0)