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

Commit 67b74a3

Browse files
dryajovdaviddias
authored andcommitted
fix: Revert "feat: use new ipfsd-ctl (#186)" (#203)
This reverts commit 4d4ef7f.
1 parent 52e67ad commit 67b74a3

File tree

11 files changed

+83
-137
lines changed

11 files changed

+83
-137
lines changed

src/block.js

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

2524
before(function (done) {
2625
// CI takes longer to instantiate the daemon, so we need to increase the
2726
// timeout for the before step
2827
this.timeout(60 * 1000)
2928

30-
common.setup((err, df, type, exec) => {
29+
common.setup((err, factory) => {
3130
expect(err).to.not.exist()
32-
df.spawn({ type, exec }, (err, node) => {
31+
factory.spawnNode((err, node) => {
3332
expect(err).to.not.exist()
34-
ipfsd = node
35-
ipfs = node.api
33+
ipfs = node
3634
done()
3735
})
3836
})
3937
})
4038

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

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

src/config.js

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

1716
before(function (done) {
1817
// CI takes longer to instantiate the daemon, so we need to increase the
1918
// timeout for the before step
2019
this.timeout(60 * 1000)
2120

22-
common.setup((err, df, type, exec) => {
21+
common.setup((err, factory) => {
2322
expect(err).to.not.exist()
24-
df.spawn({ type, exec }, (err, node) => {
23+
factory.spawnNode((err, node) => {
2524
expect(err).to.not.exist()
26-
ipfsd = node
27-
ipfs = node.api
25+
ipfs = node
2826
done()
2927
})
3028
})
3129
})
3230

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

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

src/dag.js

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

2221
before(function (done) {
2322
// CI takes longer to instantiate the daemon, so we need to increase the
2423
// timeout for the before step
2524
this.timeout(60 * 1000)
2625

27-
common.setup((err, df, type, exec) => {
26+
common.setup((err, factory) => {
2827
expect(err).to.not.exist()
29-
df.spawn({ type, exec }, (err, node) => {
28+
factory.spawnNode((err, node) => {
3029
expect(err).to.not.exist()
31-
ipfs = node.api
32-
ipfsd = node
30+
ipfs = node
3331
done()
3432
})
3533
})
3634
})
3735

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

4038
let pbNode
4139
let cborNode

src/dht.js

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

13-
function spawnWithId (df, type, exec, callback) {
14-
if (typeof type === 'function') {
15-
callback = type
16-
type = undefined
17-
}
18-
19-
if (typeof exec === 'function') {
20-
callback = exec
21-
exec = undefined
22-
}
23-
13+
function spawnWithId (factory, callback) {
2414
waterfall([
25-
(cb) => df.spawn({ type, exec }, cb),
26-
(node, cb) => node.api.id((err, peerId) => {
15+
(cb) => factory.spawnNode(cb),
16+
(node, cb) => node.id((err, peerId) => {
2717
if (err) {
2818
return cb(err)
2919
}
30-
node.api.peerId = peerId
20+
node.peerId = peerId
3121
cb(null, node)
3222
})
3323
], callback)
@@ -41,26 +31,23 @@ module.exports = (common) => {
4131
let nodeB
4232
let nodeC
4333

44-
let ipfsdNodes
4534
before(function (done) {
4635
// CI takes longer to instantiate the daemon, so we need to increase the
4736
// timeout for the before step
4837
this.timeout(60 * 1000)
4938

50-
common.setup((err, df, type) => {
39+
common.setup((err, factory) => {
5140
expect(err).to.not.exist()
5241
series([
53-
(cb) => spawnWithId(df, type, cb),
54-
(cb) => spawnWithId(df, type, cb),
55-
(cb) => spawnWithId(df, type, cb)
42+
(cb) => spawnWithId(factory, cb),
43+
(cb) => spawnWithId(factory, cb),
44+
(cb) => spawnWithId(factory, cb)
5645
], (err, nodes) => {
5746
expect(err).to.not.exist()
5847

59-
ipfsdNodes = nodes
60-
61-
nodeA = nodes[0].api
62-
nodeB = nodes[1].api
63-
nodeC = nodes[2].api
48+
nodeA = nodes[0]
49+
nodeB = nodes[1]
50+
nodeC = nodes[2]
6451

6552
parallel([
6653
(cb) => nodeA.swarm.connect(nodeB.peerId.addresses[0], cb),
@@ -71,7 +58,7 @@ module.exports = (common) => {
7158
})
7259
})
7360

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

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

src/files.js

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

2626
let ipfs
27-
let ipfsd
2827

2928
function fixture (path) {
3029
return loadFixture(__dirname, path, 'interface-ipfs-core')
@@ -56,18 +55,17 @@ module.exports = (common) => {
5655
// timeout for the before step
5756
this.timeout(60 * 1000)
5857

59-
common.setup((err, df, type, exec) => {
58+
common.setup((err, factory) => {
6059
expect(err).to.not.exist()
61-
df.spawn({ type, exec }, (err, node) => {
60+
factory.spawnNode((err, node) => {
6261
expect(err).to.not.exist()
63-
ipfs = node.api
64-
ipfsd = node
62+
ipfs = node
6563
done()
6664
})
6765
})
6866
})
6967

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

7270
describe('.add', () => {
7371
it('a Buffer', (done) => {

src/key.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ const hat = require('hat')
1212
module.exports = (common) => {
1313
describe('.key', () => {
1414
const keyTypes = [
15-
{ type: 'rsa', size: 2048 }
15+
{type: 'rsa', size: 2048}
1616
]
1717
const keys = []
1818
let ipfs
19-
let ipfsd
2019
let withGo
2120

2221
before(function (done) {
2322
// CI takes longer to instantiate the daemon, so we need to increase the
2423
// timeout for the before step
2524
this.timeout(60 * 1000)
2625

27-
common.setup((err, df, type, exec) => {
26+
common.setup((err, factory) => {
2827
expect(err).to.not.exist()
29-
df.spawn({ type, exec }, (err, node) => {
28+
factory.spawnNode((err, node) => {
3029
expect(err).to.not.exist()
31-
ipfsd = node
32-
ipfs = node.api
30+
ipfs = node
3331
ipfs.id((err, id) => {
3432
expect(err).to.not.exist()
3533
withGo = id.agentVersion.startsWith('go-ipfs')
@@ -39,7 +37,7 @@ module.exports = (common) => {
3937
})
4038
})
4139

42-
after((done) => ipfsd.stop(done))
40+
after((done) => common.teardown(done))
4341

4442
describe('.gen', () => {
4543
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
1514

1615
before(function (done) {
1716
// CI takes longer to instantiate the daemon, so we need to increase the
1817
// timeout for the before step
1918
this.timeout(60 * 1000)
2019

21-
common.setup((err, df, type, exec) => {
20+
common.setup((err, factory) => {
2221
expect(err).to.not.exist()
23-
df.spawn({ type, exec }, (err, node) => {
22+
factory.spawnNode((err, node) => {
2423
expect(err).to.not.exist()
25-
ipfs = node.api
26-
ipfsd = node
24+
ipfs = node
2725
done()
2826
})
2927
})
3028
})
3129

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

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

src/object.js

+7-7
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
2120

2221
before(function (done) {
2322
// CI takes longer to instantiate the daemon, so we need to increase the
2423
// timeout for the before step
2524
this.timeout(60 * 1000)
2625

27-
common.setup((err, df, type, exec) => {
26+
common.setup((err, factory) => {
2827
expect(err).to.not.exist()
29-
df.spawn({ type, exec }, (err, node) => {
28+
factory.spawnNode((err, node) => {
3029
expect(err).to.not.exist()
31-
ipfs = node.api
32-
ipfsd = node
30+
ipfs = node
3331
done()
3432
})
3533
})
3634
})
3735

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

4040
describe('callback API', () => {
4141
describe('.new', () => {
@@ -843,7 +843,7 @@ module.exports = (common) => {
843843
return ipfs.object.put(testObj, (err, node) => {
844844
expect(err).to.not.exist()
845845

846-
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', { enc: 'base58' })
846+
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', {enc: 'base58'})
847847
.then((stats) => {
848848
const expected = {
849849
Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ',

src/pin.js

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

1919
let ipfs
20-
let ipfsd
2120

2221
before(function (done) {
2322
// CI takes longer to instantiate the daemon, so we need to increase the
2423
// timeout for the before step
2524
this.timeout(60 * 1000)
2625

27-
common.setup((err, df, type, exec) => {
26+
common.setup((err, factory) => {
2827
expect(err).to.not.exist()
29-
df.spawn({ type, exec }, (err, node) => {
28+
factory.spawnNode((err, node) => {
3029
expect(err).to.not.exist()
31-
ipfs = node.api
32-
ipfsd = node
30+
ipfs = node
3331
populate()
3432
})
3533
})
@@ -45,7 +43,7 @@ module.exports = (common) => {
4543
}
4644
})
4745

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

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

0 commit comments

Comments
 (0)