From 7964f401a5c2645ef742cf5b66d6fbafe73a3152 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 21 Jun 2018 22:59:02 +0100 Subject: [PATCH] test: add test for retrieving an empty block License: MIT Signed-off-by: Alan Shaw --- js/src/block.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/src/block.js b/js/src/block.js index d0cf8af68..38219db5b 100644 --- a/js/src/block.js +++ b/js/src/block.js @@ -123,6 +123,22 @@ module.exports = (common) => { }) }) + it('should get an empty block', (done) => { + ipfs.block.put(Buffer.alloc(0), { + format: 'dag-pb', + mhtype: 'sha2-256', + version: 0 + }, (err, block) => { + expect(err).to.not.exist() + + ipfs.block.get(block.cid, (err, block) => { + expect(err).to.not.exist() + expect(block.data).to.eql(Buffer.alloc(0)) + done() + }) + }) + }) + // TODO it.skip('Promises support', (done) => {}) })