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

Commit 2b1820b

Browse files
authoredJan 23, 2018
feat: integrate new ipfsd-ctl
1 parent 98000af commit 2b1820b

34 files changed

+479
-582
lines changed
 

‎.aegir.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
'use strict'
22

3-
const factory = require('./test/ipfs-factory/tasks')
3+
const createServer = require('ipfsd-ctl').createServer
44

5+
const server = createServer()
56
module.exports = {
67
karma: {
78
files: [{
89
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
910
watched: false,
1011
served: true,
1112
included: false
12-
}]
13+
}],
14+
browserNoActivityTimeout: 100 * 1000,
15+
singleRun: true
1316
},
1417
hooks: {
15-
pre: factory.start,
16-
post: factory.stop
18+
pre: server.start.bind(server),
19+
post: server.stop.bind(server)
1720
}
1821
}

‎package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"http": "stream-http"
1111
},
1212
"scripts": {
13-
"test": "aegir test ",
14-
"test:node": "aegir test -t node ",
13+
"test": "aegir test",
14+
"test:node": "aegir test -t node",
1515
"test:browser": "aegir test -t browser",
16+
"test:webworker": "aegir test -t webworker",
1617
"lint": "aegir lint",
1718
"build": "aegir build",
1819
"release": "aegir release ",
@@ -65,10 +66,11 @@
6566
"chai": "^4.1.2",
6667
"dirty-chai": "^2.0.1",
6768
"eslint-plugin-react": "^7.5.1",
69+
"go-ipfs-dep": "^0.4.13",
6870
"gulp": "^3.9.1",
69-
"interface-ipfs-core": "~0.40.0",
71+
"interface-ipfs-core": "~0.41.0",
7072
"hapi": "^16.6.2",
71-
"ipfsd-ctl": "~0.26.0",
73+
"ipfsd-ctl": "~0.27.0",
7274
"pre-commit": "^1.2.2",
7375
"socket.io": "^2.0.4",
7476
"socket.io-client": "^2.0.4",

‎test/bitswap.spec.js

+32-60
Original file line numberDiff line numberDiff line change
@@ -5,86 +5,58 @@ const chai = require('chai')
55
const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
8-
const FactoryClient = require('./ipfs-factory/client')
8+
9+
const IPFSApi = require('../src')
10+
11+
const DaemonFactory = require('ipfsd-ctl')
12+
const df = DaemonFactory.create()
913

1014
describe('.bitswap', function () {
1115
this.timeout(20 * 1000) // slow CI
1216
let ipfs
13-
let fc
17+
let ipfsd = null
1418

1519
before((done) => {
1620
this.timeout(20 * 1000) // slow CI
17-
fc = new FactoryClient()
18-
fc.spawnNode((err, node) => {
21+
df.spawn((err, _ipfsd) => {
1922
expect(err).to.not.exist()
20-
ipfs = node
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2125
done()
2226
})
2327
})
2428

25-
after((done) => {
26-
fc.dismantle(done)
27-
})
28-
29-
describe('Callback API', () => {
30-
it('.wantlist', (done) => {
31-
ipfs.bitswap.wantlist((err, res) => {
32-
expect(err).to.not.exist()
33-
expect(res).to.have.to.be.eql({
34-
Keys: null
35-
})
36-
done()
37-
})
38-
})
39-
40-
it('.stat', (done) => {
41-
ipfs.bitswap.stat((err, res) => {
42-
expect(err).to.not.exist()
43-
expect(res).to.have.property('BlocksReceived')
44-
expect(res).to.have.property('DupBlksReceived')
45-
expect(res).to.have.property('DupDataReceived')
46-
expect(res).to.have.property('Peers')
47-
expect(res).to.have.property('ProvideBufLen')
48-
expect(res).to.have.property('Wantlist')
49-
50-
done()
51-
})
52-
})
29+
after((done) => ipfsd.stop(done))
5330

54-
it('.unwant', (done) => {
55-
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
56-
ipfs.bitswap.unwant(key, (err) => {
57-
expect(err).to.not.exist()
58-
done()
31+
it('.wantlist', (done) => {
32+
ipfs.bitswap.wantlist((err, res) => {
33+
expect(err).to.not.exist()
34+
expect(res).to.have.to.eql({
35+
Keys: null
5936
})
37+
done()
6038
})
6139
})
6240

63-
describe('Promise API', () => {
64-
it('.wantlist', () => {
65-
return ipfs.bitswap.wantlist()
66-
.then((res) => {
67-
expect(res).to.have.to.be.eql({
68-
Keys: null
69-
})
70-
})
71-
})
41+
it('.stat', (done) => {
42+
ipfs.bitswap.stat((err, res) => {
43+
expect(err).to.not.exist()
44+
expect(res).to.have.property('BlocksReceived')
45+
expect(res).to.have.property('DupBlksReceived')
46+
expect(res).to.have.property('DupDataReceived')
47+
expect(res).to.have.property('Peers')
48+
expect(res).to.have.property('ProvideBufLen')
49+
expect(res).to.have.property('Wantlist')
7250

73-
it('.stat', () => {
74-
return ipfs.bitswap.stat()
75-
.then((res) => {
76-
expect(res).to.have.property('BlocksReceived')
77-
expect(res).to.have.property('DupBlksReceived')
78-
expect(res).to.have.property('DupDataReceived')
79-
expect(res).to.have.property('Peers')
80-
expect(res).to.have.property('ProvideBufLen')
81-
expect(res).to.have.property('Wantlist')
82-
})
51+
done()
8352
})
53+
})
8454

85-
it('.unwant', () => {
86-
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
87-
return ipfs.bitswap.unwant(key)
55+
it('.unwant', (done) => {
56+
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
57+
ipfs.bitswap.unwant(key, (err) => {
58+
expect(err).to.not.exist()
59+
done()
8860
})
8961
})
9062
})

‎test/bootstrap.spec.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,31 @@ const chai = require('chai')
66
const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
9-
const FactoryClient = require('./ipfs-factory/client')
9+
10+
const IPFSApi = require('../src')
11+
12+
const DaemonFactory = require('ipfsd-ctl')
13+
const df = DaemonFactory.create()
1014

1115
const invalidArg = 'this/Is/So/Invalid/'
1216
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
1317

1418
describe('.bootstrap', function () {
1519
this.timeout(100 * 1000)
1620

21+
let ipfsd
1722
let ipfs
18-
let fc
1923

2024
before((done) => {
21-
fc = new FactoryClient()
22-
fc.spawnNode((err, node) => {
25+
df.spawn((err, _ipfsd) => {
2326
expect(err).to.not.exist()
24-
ipfs = node
27+
ipfsd = _ipfsd
28+
ipfs = IPFSApi(_ipfsd.apiAddr)
2529
done()
2630
})
2731
})
2832

29-
after((done) => {
30-
fc.dismantle(done)
31-
})
33+
after((done) => ipfsd.stop(done))
3234

3335
let peers
3436

‎test/commands.spec.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9-
const FactoryClient = require('./ipfs-factory/client')
9+
const IPFSApi = require('../src')
10+
11+
const DaemonFactory = require('ipfsd-ctl')
12+
const df = DaemonFactory.create()
1013

1114
describe('.commands', function () {
1215
this.timeout(20 * 1000)
1316

17+
let ipfsd
1418
let ipfs
15-
let fc
1619

1720
before((done) => {
18-
fc = new FactoryClient()
19-
fc.spawnNode((err, node) => {
21+
df.spawn((err, _ipfsd) => {
2022
expect(err).to.not.exist()
21-
ipfs = node
23+
ipfsd = _ipfsd
24+
ipfs = IPFSApi(_ipfsd.apiAddr)
2225
done()
2326
})
2427
})
2528

26-
after((done) => {
27-
fc.dismantle(done)
28-
})
29+
after((done) => ipfsd.stop(done))
2930

3031
it('lists commands', (done) => {
3132
ipfs.commands((err, res) => {

‎test/constructor.spec.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const chai = require('chai')
55
const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
8-
const FactoryClient = require('./ipfs-factory/client')
8+
9+
const DaemonFactory = require('ipfsd-ctl')
10+
const df = DaemonFactory.create()
911

1012
const ipfsAPI = require('../src/index.js')
1113

@@ -22,19 +24,19 @@ function clientWorks (client, done) {
2224
describe('ipfs-api constructor tests', () => {
2325
describe('parameter permuations', () => {
2426
let apiAddr
25-
let fc
27+
let ipfsd
2628

2729
before(function (done) {
2830
this.timeout(20 * 1000) // slow CI
29-
fc = new FactoryClient()
30-
fc.spawnNode((err, node) => {
31+
df.spawn((err, node) => {
3132
expect(err).to.not.exist()
32-
apiAddr = node.apiAddr
33+
ipfsd = node
34+
apiAddr = node.apiAddr.toString()
3335
done()
3436
})
3537
})
3638

37-
after((done) => fc.dismantle(done))
39+
after((done) => ipfsd.stop(done))
3840

3941
it('opts', (done) => {
4042
const splitted = apiAddr.split('/')

‎test/diag.spec.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const FactoryClient = require('./ipfs-factory/client')
54
const chai = require('chai')
65
const dirtyChai = require('dirty-chai')
76
const expect = chai.expect
87
chai.use(dirtyChai)
98
const os = require('os')
109

10+
const IPFSApi = require('../src')
11+
12+
const DaemonFactory = require('ipfsd-ctl')
13+
const df = DaemonFactory.create()
14+
1115
describe('.diag', function () {
1216
this.timeout(50 * 1000)
1317

@@ -16,19 +20,19 @@ describe('.diag', function () {
1620
return
1721
}
1822

23+
let ipfsd
1924
let ipfs
20-
let fc
2125

2226
before((done) => {
23-
fc = new FactoryClient()
24-
fc.spawnNode((err, node) => {
27+
df.spawn((err, _ipfsd) => {
2528
expect(err).to.not.exist()
26-
ipfs = node
29+
ipfsd = _ipfsd
30+
ipfs = IPFSApi(_ipfsd.apiAddr)
2731
done()
2832
})
2933
})
3034

31-
after((done) => fc.dismantle(done))
35+
after((done) => ipfsd.stop(done))
3236

3337
describe('Callback API', () => {
3438
// Disabled in go-ipfs 0.4.10

‎test/files.spec.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const loadFixture = require('aegir/fixtures')
1111
const mh = require('multihashes')
1212
const CID = require('cids')
1313

14-
const FactoryClient = require('./ipfs-factory/client')
14+
const IPFSApi = require('../src')
15+
16+
const DaemonFactory = require('ipfsd-ctl')
17+
const df = DaemonFactory.create()
1518

1619
const testfile = isNode
1720
? loadFixture(__dirname, '/fixtures/testfile.txt')
@@ -32,21 +35,21 @@ const HASH_ALGS = [
3235
describe('.files (the MFS API part)', function () {
3336
this.timeout(120 * 1000)
3437

38+
let ipfsd
3539
let ipfs
36-
let fc
3740

3841
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
3942

4043
before((done) => {
41-
fc = new FactoryClient()
42-
fc.spawnNode((err, node) => {
44+
df.spawn((err, _ipfsd) => {
4345
expect(err).to.not.exist()
44-
ipfs = node
46+
ipfsd = _ipfsd
47+
ipfs = IPFSApi(_ipfsd.apiAddr)
4548
done()
4649
})
4750
})
4851

49-
after((done) => fc.dismantle(done))
52+
after((done) => ipfsd.stop(done))
5053

5154
describe('Callback API', function () {
5255
this.timeout(120 * 1000)

‎test/fixtures/test-folder/hello-link

-1
This file was deleted.

‎test/fixtures/test-folder/hello-link

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
files/hello.txt

0 commit comments

Comments
 (0)
This repository has been archived.