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

Commit c57f5c7

Browse files
committed
feat: use new ipfsd-ctl
1 parent a90ca29 commit c57f5c7

File tree

11 files changed

+111
-77
lines changed

11 files changed

+111
-77
lines changed

src/block.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ function expectKey (block, expected, callback) {
2020
module.exports = (common) => {
2121
describe('.block', () => {
2222
let ipfs
23+
let ipfsd
2324

2425
before(function (done) {
2526
// CI takes longer to instantiate the daemon, so we need to increase the
2627
// timeout for the before step
2728
this.timeout(60 * 1000)
2829

29-
common.setup((err, factory) => {
30+
common.setup((err, df) => {
3031
expect(err).to.not.exist()
31-
factory.spawnNode((err, node) => {
32+
df.spawn((err, node) => {
3233
expect(err).to.not.exist()
33-
ipfs = node
34+
ipfsd = node
35+
ipfs = node.api
3436
done()
3537
})
3638
})
3739
})
3840

39-
after((done) => common.teardown(done))
41+
after((done) => ipfsd.stop(done))
4042

4143
describe('.put', () => {
4244
it('a buffer, using defaults', (done) => {

src/config.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ module.exports = (common) => {
1212
describe('.config', function () {
1313
this.timeout(30 * 1000)
1414
let ipfs
15+
let ipfsd
1516

1617
before(function (done) {
1718
// CI takes longer to instantiate the daemon, so we need to increase the
1819
// timeout for the before step
1920
this.timeout(60 * 1000)
2021

21-
common.setup((err, factory) => {
22+
common.setup((err, df) => {
2223
expect(err).to.not.exist()
23-
factory.spawnNode((err, node) => {
24+
df.spawn((err, node) => {
2425
expect(err).to.not.exist()
25-
ipfs = node
26+
ipfsd = node
27+
ipfs = node.api
2628
done()
2729
})
2830
})
2931
})
3032

31-
after((done) => common.teardown(done))
33+
after((done) => ipfsd.stop(done))
3234

3335
describe('.get', () => {
3436
it('retrieve the whole config', (done) => {

src/dag.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@ const CID = require('cids')
1717
module.exports = (common) => {
1818
describe('.dag', () => {
1919
let ipfs
20+
let ipfsd
2021

2122
before(function (done) {
2223
// CI takes longer to instantiate the daemon, so we need to increase the
2324
// timeout for the before step
2425
this.timeout(60 * 1000)
2526

26-
common.setup((err, factory) => {
27+
common.setup((err, df) => {
2728
expect(err).to.not.exist()
28-
factory.spawnNode((err, node) => {
29+
df.spawn((err, node) => {
2930
expect(err).to.not.exist()
30-
ipfs = node
31+
ipfs = node.api
32+
ipfsd = node
3133
done()
3234
})
3335
})
3436
})
3537

36-
after((done) => common.teardown(done))
38+
after((done) => ipfsd.stop(done))
3739

3840
let pbNode
3941
let cborNode

src/dht.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const series = require('async/series')
1010
const parallel = require('async/parallel')
1111
const CID = require('cids')
1212

13-
function spawnWithId (factory, callback) {
13+
function spawnWithId (df, callback) {
1414
waterfall([
15-
(cb) => factory.spawnNode(cb),
16-
(node, cb) => node.id((err, peerId) => {
15+
(cb) => df.spawn(cb),
16+
(node, cb) => node.api.id((err, peerId) => {
1717
if (err) {
1818
return cb(err)
1919
}
20-
node.peerId = peerId
20+
node.api.peerId = peerId
2121
cb(null, node)
2222
})
2323
], callback)
@@ -31,6 +31,7 @@ module.exports = (common) => {
3131
let nodeB
3232
let nodeC
3333

34+
let ipfsdNodes
3435
before(function (done) {
3536
// CI takes longer to instantiate the daemon, so we need to increase the
3637
// timeout for the before step
@@ -45,9 +46,11 @@ module.exports = (common) => {
4546
], (err, nodes) => {
4647
expect(err).to.not.exist()
4748

48-
nodeA = nodes[0]
49-
nodeB = nodes[1]
50-
nodeC = nodes[2]
49+
ipfsdNodes = nodes
50+
51+
nodeA = nodes[0].api
52+
nodeB = nodes[1].api
53+
nodeC = nodes[2].api
5154

5255
parallel([
5356
(cb) => nodeA.swarm.connect(nodeB.peerId.addresses[0], cb),
@@ -58,7 +61,7 @@ module.exports = (common) => {
5861
})
5962
})
6063

61-
after((done) => common.teardown(done))
64+
after((done) => parallel(ipfsdNodes.map((node) => (cb) => node.stop(cb)), done))
6265

6366
describe('.get and .put', () => {
6467
it('errors when getting a non-existent key from the DHT', (done) => {

src/files.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = (common) => {
2424
this.timeout(40 * 1000)
2525

2626
let ipfs
27+
let ipfsd
2728

2829
function fixture (path) {
2930
return loadFixture(__dirname, path, 'interface-ipfs-core')
@@ -55,17 +56,18 @@ module.exports = (common) => {
5556
// timeout for the before step
5657
this.timeout(60 * 1000)
5758

58-
common.setup((err, factory) => {
59+
common.setup((err, fd) => {
5960
expect(err).to.not.exist()
60-
factory.spawnNode((err, node) => {
61+
fd.spawn((err, node) => {
6162
expect(err).to.not.exist()
62-
ipfs = node
63+
ipfs = node.api
64+
ipfsd = node
6365
done()
6466
})
6567
})
6668
})
6769

68-
after((done) => common.teardown(done))
70+
after((done) => ipfsd.stop(done))
6971

7072
describe('.add', () => {
7173
it('a Buffer', (done) => {

src/key.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@ module.exports = (common) => {
1616
]
1717
const keys = []
1818
let ipfs
19+
let ipfsd
1920

2021
before(function (done) {
2122
// CI takes longer to instantiate the daemon, so we need to increase the
2223
// timeout for the before step
2324
this.timeout(60 * 1000)
2425

25-
common.setup((err, factory) => {
26+
common.setup((err, df) => {
2627
expect(err).to.not.exist()
27-
factory.spawnNode((err, node) => {
28+
df.spawn((err, node) => {
2829
expect(err).to.not.exist()
29-
ipfs = node
30+
ipfs = node.api
31+
ipfsd = node
3032
done()
3133
})
3234
})
3335
})
3436

35-
after((done) => common.teardown(done))
37+
after((done) => ipfsd.stop(done))
3638

3739
describe('.gen', () => {
3840
keyTypes.forEach((kt) => {

src/miscellaneous.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ chai.use(dirtyChai)
1111
module.exports = (common) => {
1212
describe('.miscellaneous', () => {
1313
let ipfs
14+
let ipfsd
1415

1516
before(function (done) {
1617
// CI takes longer to instantiate the daemon, so we need to increase the
1718
// timeout for the before step
1819
this.timeout(60 * 1000)
1920

20-
common.setup((err, factory) => {
21+
common.setup((err, df) => {
2122
expect(err).to.not.exist()
22-
factory.spawnNode((err, node) => {
23+
df.spawn((err, node) => {
2324
expect(err).to.not.exist()
24-
ipfs = node
25+
ipfs = node.api
26+
ipfsd = node
2527
done()
2628
})
2729
})
2830
})
2931

30-
after((done) => {
31-
common.teardown(done)
32-
})
32+
after((done) => ipfsd.stop(done))
3333

3434
it('.id', (done) => {
3535
ipfs.id((err, res) => {

src/object.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ module.exports = (common) => {
1717
this.timeout(80 * 1000)
1818

1919
let ipfs
20+
let ipfsd
2021

2122
before(function (done) {
2223
// CI takes longer to instantiate the daemon, so we need to increase the
2324
// timeout for the before step
2425
this.timeout(60 * 1000)
2526

26-
common.setup((err, factory) => {
27+
common.setup((err, df) => {
2728
expect(err).to.not.exist()
28-
factory.spawnNode((err, node) => {
29+
df.spawn((err, node) => {
2930
expect(err).to.not.exist()
30-
ipfs = node
31+
ipfs = node.api
32+
ipfsd = node
3133
done()
3234
})
3335
})
3436
})
3537

36-
after((done) => {
37-
common.teardown(done)
38-
})
38+
after((done) => ipfsd.stop(done))
3939

4040
describe('callback API', () => {
4141
describe('.new', () => {

src/pin.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ module.exports = (common) => {
1717
this.timeout(50 * 1000)
1818

1919
let ipfs
20+
let ipfsd
2021

2122
before(function (done) {
2223
// CI takes longer to instantiate the daemon, so we need to increase the
2324
// timeout for the before step
2425
this.timeout(60 * 1000)
2526

26-
common.setup((err, factory) => {
27+
common.setup((err, df) => {
2728
expect(err).to.not.exist()
28-
factory.spawnNode((err, node) => {
29+
df.spawn((err, node) => {
2930
expect(err).to.not.exist()
30-
ipfs = node
31+
ipfs = node.api
32+
ipfsd = node
3133
populate()
3234
})
3335
})
@@ -43,7 +45,7 @@ module.exports = (common) => {
4345
}
4446
})
4547

46-
after((done) => common.teardown(done))
48+
after((done) => ipfsd.stop(done))
4749

4850
describe('callback API', () => {
4951
// 1st, because ipfs.files.add pins automatically

src/pubsub.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ function waitForPeers (ipfs, topic, peersToWait, callback) {
3232
}, 500)
3333
}
3434

35-
function spawnWithId (factory, callback) {
35+
function spawnWithId (df, callback) {
3636
waterfall([
37-
(cb) => factory.spawnNode(cb),
38-
(node, cb) => node.id((err, res) => {
37+
(cb) => df.spawn({ args: ['--enable-pubsub-experiment'] }, cb),
38+
(node, cb) => node.api.id((err, res) => {
3939
if (err) {
4040
return cb(err)
4141
}
42-
node.peerId = res
42+
node.api.peerId = res
4343
cb(null, node)
4444
})
4545
], callback)
@@ -68,36 +68,37 @@ module.exports = (common) => {
6868
let ipfs2
6969
let ipfs3
7070

71+
let ipfsdNodes
7172
before(function (done) {
7273
// CI takes longer to instantiate the daemon, so we need to increase the
7374
// timeout for the before step
7475
this.timeout(100 * 1000)
7576

76-
common.setup((err, factory) => {
77+
common.setup((err, df) => {
7778
if (err) {
7879
return done(err)
7980
}
8081

8182
series([
82-
(cb) => spawnWithId(factory, cb),
83-
(cb) => spawnWithId(factory, cb),
84-
(cb) => spawnWithId(factory, cb)
83+
(cb) => spawnWithId(df, cb),
84+
(cb) => spawnWithId(df, cb),
85+
(cb) => spawnWithId(df, cb)
8586
], (err, nodes) => {
8687
if (err) {
8788
return done(err)
8889
}
8990

90-
ipfs1 = nodes[0]
91-
ipfs2 = nodes[1]
92-
ipfs3 = nodes[2]
91+
ipfsdNodes = nodes
92+
93+
ipfs1 = nodes[0].api
94+
ipfs2 = nodes[1].api
95+
ipfs3 = nodes[2].api
9396
done()
9497
})
9598
})
9699
})
97100

98-
after((done) => {
99-
common.teardown(done)
100-
})
101+
after((done) => parallel(ipfsdNodes.map((node) => (cb) => node.stop(cb)), done))
101102

102103
describe('single node', () => {
103104
describe('.publish', () => {

0 commit comments

Comments
 (0)