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

Commit

Permalink
test: block put with CID string (#588)
Browse files Browse the repository at this point in the history
* test: block put with CID string

* fix: cid of added data and update deps
  • Loading branch information
Alan Shaw authored Feb 9, 2020
1 parent f440560 commit e5c6e22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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 <alan.shaw@protocol.ai>",
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

0 comments on commit e5c6e22

Please sign in to comment.