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

Commit 9850c4a

Browse files
committed
feat: ensure backwards compatibility at the block API
1 parent 75f8899 commit 9850c4a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/block.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ module.exports = (common) => {
5959
})
6060
})
6161

62+
it('.put a block (without using CID, legacy mode)', (done) => {
63+
const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
64+
const blob = new Block(new Buffer('blorb'))
65+
66+
ipfs.block.put(blob, (err, block) => {
67+
expect(err).to.not.exist
68+
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(expectedHash))
69+
expect(block.data).to.eql(new Buffer('blorb'))
70+
done()
71+
})
72+
})
73+
6274
it('.put error with array of blocks', () => {
6375
const blob = Buffer('blorb')
6476

@@ -79,6 +91,17 @@ module.exports = (common) => {
7991
})
8092
})
8193

94+
it('block.get (without using CID, legacy mode)', (done) => {
95+
const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
96+
97+
ipfs.block.get(hash, (err, block) => {
98+
expect(err).to.not.exist
99+
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(hash))
100+
expect(block.data).to.eql(new Buffer('blorb'))
101+
done()
102+
})
103+
})
104+
82105
it('block.stat', (done) => {
83106
const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
84107
const cid = new CID(hash)

0 commit comments

Comments
 (0)