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

test: block put with CID string #588

Merged
merged 2 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -64,7 +64,7 @@
},
"devDependencies": {
"aegir": "^20.3.2",
"ipfsd-ctl": "^1.0.0"
"ipfsd-ctl": "^2.1.0"
},
"contributors": [
"Alan Shaw <[email protected]>",
Expand Down
10 changes: 10 additions & 0 deletions src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 'bafyreietui4xdkiu4xvmx4fi2jivjtndbhb4drzpxomrjvd4mdz4w2avra'
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()}`)

Expand Down