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

Commit c90fdc2

Browse files
round1 for new aegir
1 parent 3a79b79 commit c90fdc2

File tree

17 files changed

+42
-36
lines changed

17 files changed

+42
-36
lines changed

API/block/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ block API
1111

1212
`multihash` is a [multihash][multihash] which can be passed as:
1313

14-
- Buffer, the raw Buffer of the multihash
14+
- Buffer, the raw Buffer of the multihash
1515
- String, the base58 encoded version of the multihash
1616

1717
`callback` must follow `function (err, block) {}` signature, where `err` is an error if the operation was not successful and `block` is a [Block][block] type object, containing both the data and the hash of the block.
@@ -21,7 +21,12 @@ ipfs.block.get(multihash, function (err, block) {
2121
if (err) {
2222
throw err
2323
}
24-
console.log(block.key, block.data)
24+
block.key((err, key) => {
25+
if (err) {
26+
throw err
27+
}
28+
console.log(key, block.data)
29+
})
2530
})
2631
```
2732

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
"name": "interface-ipfs-core",
33
"version": "0.16.2",
44
"description": "A test suite and interface you can use to implement a IPFS core interface.",
5-
"main": "lib/index.js",
6-
"jsnext:main": "src/index.js",
5+
"main": "src/index.js",
76
"scripts": {
87
"test": "exit(0)",
9-
"build": "aegir-build node",
108
"lint": "aegir-lint",
119
"release": "aegir-release node",
1210
"release-minor": "aegir-release node --type minor",
@@ -40,7 +38,7 @@
4038
"readable-stream": "1.1.13"
4139
},
4240
"devDependencies": {
43-
"aegir": "^8.1.2"
41+
"aegir": "^9.0.1"
4442
},
4543
"contributors": [
4644
"David Dias <daviddias.p@gmail.com>",

src/block.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ const Block = require('ipfs-block')
88
const multihash = require('multihashes')
99
const CID = require('cids')
1010

11+
function expectKey (block, expected, callback) {
12+
block.key((err, key) => {
13+
if (err) {
14+
return callback(err)
15+
}
16+
expect(key).to.be.eql(expected)
17+
callback()
18+
})
19+
}
20+
1121
module.exports = (common) => {
1222
describe('.block', () => {
1323
let ipfs
@@ -40,9 +50,8 @@ module.exports = (common) => {
4050

4151
ipfs.block.put(blob, cid, (err, block) => {
4252
expect(err).to.not.exist
43-
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(expectedHash))
4453
expect(block).to.have.a.property('data', blob)
45-
done()
54+
expectKey(block, multihash.fromB58String(expectedHash), done)
4655
})
4756
})
4857

@@ -53,9 +62,8 @@ module.exports = (common) => {
5362

5463
ipfs.block.put(blob, cid, (err, block) => {
5564
expect(err).to.not.exist
56-
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(expectedHash))
5765
expect(block.data).to.eql(new Buffer('blorb'))
58-
done()
66+
expectKey(block, multihash.fromB58String(expectedHash), done)
5967
})
6068
})
6169

@@ -65,17 +73,17 @@ module.exports = (common) => {
6573

6674
ipfs.block.put(blob, (err, block) => {
6775
expect(err).to.not.exist
68-
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(expectedHash))
6976
expect(block.data).to.eql(new Buffer('blorb'))
70-
done()
77+
expectKey(block, multihash.fromB58String(expectedHash), done)
7178
})
7279
})
7380

74-
it('.put error with array of blocks', () => {
81+
it('.put error with array of blocks', (done) => {
7582
const blob = Buffer('blorb')
7683

7784
ipfs.block.put([blob, blob], 'fake cids', (err) => {
7885
expect(err).to.be.an.instanceof(Error)
86+
done()
7987
})
8088
})
8189

@@ -85,9 +93,8 @@ module.exports = (common) => {
8593

8694
ipfs.block.get(cid, (err, block) => {
8795
expect(err).to.not.exist
88-
expect(block.key('sha2-256')).to.eql(cid.multihash)
8996
expect(block.data).to.eql(new Buffer('blorb'))
90-
done()
97+
expectKey(block, cid.multihash, done)
9198
})
9299
})
93100

@@ -96,9 +103,8 @@ module.exports = (common) => {
96103

97104
ipfs.block.get(hash, (err, block) => {
98105
expect(err).to.not.exist
99-
expect(block.key('sha2-256')).to.eql(multihash.fromB58String(hash))
100106
expect(block.data).to.eql(new Buffer('blorb'))
101-
done()
107+
expectKey(block, multihash.fromB58String(hash), done)
102108
})
103109
})
104110

src/files.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
const expect = require('chai').expect
77
const bs58 = require('bs58')
88
const Readable = require('readable-stream')
9-
const path = require('path')
10-
const fs = require('fs')
9+
const loadFixture = require('aegir/fixtures')
1110
const bl = require('bl')
1211
const concat = require('concat-stream')
1312
const through = require('through2')
@@ -23,16 +22,16 @@ module.exports = (common) => {
2322
// CI is slow
2423
this.timeout(20 * 1000)
2524

26-
smallFile = fs.readFileSync(path.join(__dirname, './data/testfile.txt'))
27-
bigFile = fs.readFileSync(path.join(__dirname, './data/15mb.random'))
25+
smallFile = loadFixture(__dirname, '../test/fixtures/testfile.txt')
26+
bigFile = loadFixture(__dirname, '../test/fixtures/15mb.random')
2827

2928
directoryContent = {
30-
'pp.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/pp.txt')),
31-
'holmes.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/holmes.txt')),
32-
'jungle.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/jungle.txt')),
33-
'alice.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/alice.txt')),
34-
'files/hello.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/files/hello.txt')),
35-
'files/ipfs.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/files/ipfs.txt'))
29+
'pp.txt': loadFixture(__dirname, '../test/fixtures/test-folder/pp.txt'),
30+
'holmes.txt': loadFixture(__dirname, '../test/fixtures/test-folder/holmes.txt'),
31+
'jungle.txt': loadFixture(__dirname, '../test/fixtures/test-folder/jungle.txt'),
32+
'alice.txt': loadFixture(__dirname, '../test/fixtures/test-folder/alice.txt'),
33+
'files/hello.txt': loadFixture(__dirname, '../test/fixtures/test-folder/files/hello.txt'),
34+
'files/ipfs.txt': loadFixture(__dirname, '../test/fixtures/test-folder/files/ipfs.txt')
3635
}
3736

3837
common.setup((err, factory) => {
@@ -436,10 +435,9 @@ module.exports = (common) => {
436435
})
437436
})
438437

439-
it('errors on invalid key', (done) => {
438+
it('errors on invalid key', () => {
440439
const hash = 'somethingNotMultihash'
441-
ipfs.files.get(hash)
442-
.then((stream) => {})
440+
return ipfs.files.get(hash)
443441
.catch((err) => {
444442
expect(err).to.exist
445443
const errString = err.toString()
@@ -449,7 +447,6 @@ module.exports = (common) => {
449447
if (errString === 'Error: Invalid Key') {
450448
expect(err.toString()).to.contain('Error: Invalid Key')
451449
}
452-
done()
453450
})
454451
})
455452
})

src/object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ module.exports = (common) => {
834834
})
835835

836836
it('object.stat', () => {
837-
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ')
837+
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', {enc: 'base58'})
838838
.then((stats) => {
839839
const expected = {
840840
Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ',

src/pin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
'use strict'
55

66
const expect = require('chai').expect
7-
const fs = require('fs')
8-
const path = require('path')
7+
const loadFixture = require('aegir/fixtures')
98

10-
const testfile = fs.readFileSync(path.join(__dirname, './data/testfile.txt'))
9+
const testfile = loadFixture(__dirname, '../test/fixtures/testfile.txt')
1110

1211
module.exports = (common) => {
1312
describe('.pin', () => {

src/swarm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ module.exports = (common) => {
6565
expect(err).to.not.exist
6666
expect(multiaddrs).to.not.be.empty
6767
expect(multiaddrs).to.be.an('array')
68-
expect(multiaddrs[0].constructor.name).to.be.eql('Peer')
68+
console.log(multiaddrs)
69+
expect(multiaddrs[0].constructor.name).to.be.eql('PeerInfo')
6970
done()
7071
})
7172
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)