Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit b042d74

Browse files
committed
rebase from master
1 parent cfd1db2 commit b042d74

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/ipfs-core/index.js

-6
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ function IPFS (repo) {
134134
get: (multihash, callback) => {
135135
bs.getBlock(multihash, callback)
136136
},
137-
<<<<<<< 712c6909108f5dcf37f3856a04bcd1a4f690b2d8
138-
put: (multihash, callback) => {},
139-
del: (multihash, callback) => {},
140-
stat: (multihash, callback) => {}
141-
=======
142137
put: (block, callback) => {
143138
bs.addBlock(block, callback)
144139
},
@@ -156,6 +151,5 @@ function IPFS (repo) {
156151
})
157152
})
158153
}
159-
>>>>>>> finish block on js-ipfs-core impl + tests
160154
}
161155
}

tests/test-core/test-block.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,39 @@ const expect = require('chai').expect
66
const base58 = require('bs58')
77
const fs = require('fs')
88
const IPFS = require('../../src/ipfs-core')
9+
const Block = require('ipfs-merkle-dag').Block
10+
11+
const isNode = !global.window
12+
13+
const fileA = isNode
14+
? fs.readFileSync(process.cwd() + '/tests/repo-example/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')
15+
: new Buffer(require('raw!./../repo-example/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))
916

1017
describe('block', () => {
18+
var ipfs
19+
1120
it('get', done => {
12-
const ipfs = new IPFS()
21+
ipfs = new IPFS()
1322
const b58mh = 'QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe'
1423
const mh = new Buffer(base58.decode(b58mh))
1524
ipfs.block.get(mh, (err, block) => {
1625
expect(err).to.not.exist
17-
const eq = fs.readFileSync(process.cwd() + '/tests/repo-example/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data').equals(block.data)
26+
const eq = fileA.equals(block.data)
1827
expect(eq).to.equal(true)
1928
done()
2029
})
2130
})
22-
it.skip('put', done => {
23-
done()
31+
it('put', done => {
32+
var b = new Block('random data')
33+
ipfs.block.put(b, function (err) {
34+
expect(err).to.not.exist
35+
ipfs.block.get(b.key, function (err, block) {
36+
expect(err).to.not.exist
37+
expect(b.data.equals(block.data)).to.equal(true)
38+
expect(b.key.equals(block.key)).to.equal(true)
39+
done()
40+
})
41+
})
2442
})
2543

2644
it('rm', done => {
@@ -42,7 +60,7 @@ describe('block', () => {
4260

4361
it('stat', done => {
4462
const mh = new Buffer(base58
45-
.decode('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG'))
63+
.decode('QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe'))
4664
ipfs.block.stat(mh, (err, stats) => {
4765
expect(err).to.not.exist
4866
expect(stats.Key.equals(mh)).to.equal(true)

0 commit comments

Comments
 (0)