Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit e5c6e22

Browse files
author
Alan Shaw
authored
test: block put with CID string (#588)
* test: block put with CID string * fix: cid of added data and update deps
1 parent f440560 commit e5c6e22

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"hat": "0.0.3",
4848
"ipfs-block": "~0.8.0",
4949
"ipfs-unixfs": "^0.3.0",
50-
"ipfs-utils": "^0.6.0",
50+
"ipfs-utils": "^0.7.1",
5151
"ipld-dag-cbor": "~0.15.0",
5252
"ipld-dag-pb": "^0.18.1",
5353
"is-ipfs": "~0.6.1",
@@ -64,7 +64,7 @@
6464
},
6565
"devDependencies": {
6666
"aegir": "^20.3.2",
67-
"ipfsd-ctl": "^1.0.0"
67+
"ipfsd-ctl": "^2.1.0"
6868
},
6969
"contributors": [
7070
"Alan Shaw <alan.shaw@protocol.ai>",

Diff for: src/block/put.js

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ module.exports = (common, options) => {
4545
expect(block.cid.multihash).to.eql(multihash.fromB58String(expectedHash))
4646
})
4747

48+
it('should put a buffer, using CID string', async () => {
49+
const expectedCid = 'bafyreietui4xdkiu4xvmx4fi2jivjtndbhb4drzpxomrjvd4mdz4w2avra'
50+
const blob = Buffer.from(JSON.stringify({ hello: 'world' }))
51+
52+
const block = await ipfs.block.put(blob, { cid: expectedCid })
53+
54+
expect(block.data).to.be.eql(blob)
55+
expect(block.cid.toString()).to.eql(expectedCid)
56+
})
57+
4858
it('should put a buffer, using options', async () => {
4959
const blob = Buffer.from(`TEST${Date.now()}`)
5060

0 commit comments

Comments
 (0)