From 60488115d1ea667d2f71f1ed5648ab2943d0a204 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 20:23:53 +0000 Subject: [PATCH 1/2] test: block put with CID string --- src/block/put.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/block/put.js b/src/block/put.js index 877457330..162daa5ef 100644 --- a/src/block/put.js +++ b/src/block/put.js @@ -45,6 +45,16 @@ module.exports = (common, options) => { expect(block.cid.multihash).to.eql(multihash.fromB58String(expectedHash)) }) + it('should put a buffer, using CID string', async () => { + const expectedCid = 'bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae' + const blob = Buffer.from(JSON.stringify({ hello: 'world' })) + + const block = await ipfs.block.put(blob, { cid: expectedCid }) + + expect(block.data).to.be.eql(blob) + expect(block.cid.toString()).to.eql(expectedCid) + }) + it('should put a buffer, using options', async () => { const blob = Buffer.from(`TEST${Date.now()}`) From 910807d23adba5aad430a594a7769fbed017eb33 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 21:53:33 +0000 Subject: [PATCH 2/2] fix: cid of added data and update deps --- package.json | 4 ++-- src/block/put.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 177c5a177..ede4bfe9b 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "hat": "0.0.3", "ipfs-block": "~0.8.0", "ipfs-unixfs": "^0.3.0", - "ipfs-utils": "^0.6.0", + "ipfs-utils": "^0.7.1", "ipld-dag-cbor": "~0.15.0", "ipld-dag-pb": "^0.18.1", "is-ipfs": "~0.6.1", @@ -64,7 +64,7 @@ }, "devDependencies": { "aegir": "^20.3.2", - "ipfsd-ctl": "^1.0.0" + "ipfsd-ctl": "^2.1.0" }, "contributors": [ "Alan Shaw ", diff --git a/src/block/put.js b/src/block/put.js index 162daa5ef..3e228207d 100644 --- a/src/block/put.js +++ b/src/block/put.js @@ -46,7 +46,7 @@ module.exports = (common, options) => { }) it('should put a buffer, using CID string', async () => { - const expectedCid = 'bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae' + const expectedCid = 'bafyreietui4xdkiu4xvmx4fi2jivjtndbhb4drzpxomrjvd4mdz4w2avra' const blob = Buffer.from(JSON.stringify({ hello: 'world' })) const block = await ipfs.block.put(blob, { cid: expectedCid })