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

Commit d32b03d

Browse files
committed
fix: setup interface test node in ipfs-api
1 parent af4dd75 commit d32b03d

File tree

11 files changed

+183
-11
lines changed

11 files changed

+183
-11
lines changed

test/interface/block.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/config.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/dht.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
'use strict'
33

44
const test = require('interface-ipfs-core')
5+
const IPFSApi = require('../../src')
56

67
const DaemonFactory = require('ipfsd-ctl')
78
const df = DaemonFactory.create()
89

10+
let ipfsd = null
911
const common = {
1012
setup: function (callback) {
11-
callback(null, df)
13+
callback(null, {
14+
spawnNode: (cb) => {
15+
df.spawn((err, _ipfsd) => {
16+
if (err) {
17+
return cb(err)
18+
}
19+
20+
ipfsd = _ipfsd
21+
cb(null, IPFSApi(_ipfsd.apiAddr))
22+
})
23+
}
24+
})
25+
},
26+
teardown: function (callback) {
27+
ipfsd.stop(callback)
1228
}
1329
}
1430

test/interface/files.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/generic.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/key.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/object.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/pin.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (cb) => {
16+
df.spawn((err, _ipfsd) => {
17+
if (err) {
18+
return cb(err)
19+
}
20+
21+
ipfsd = _ipfsd
22+
cb(null, IPFSApi(_ipfsd.apiAddr))
23+
})
24+
}
25+
})
26+
},
27+
teardown: function (callback) {
28+
ipfsd.stop(callback)
1329
}
1430
}
1531

test/interface/pubsub.spec.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@
55
const test = require('interface-ipfs-core')
66
const isNode = require('detect-node')
77

8+
const IPFSApi = require('../../src')
9+
810
const DaemonFactory = require('ipfsd-ctl')
911
const df = DaemonFactory.create()
1012

1113
if (isNode) {
14+
let ipfsd = null
1215
const common = {
1316
setup: function (callback) {
14-
callback(null, df)
17+
callback(null, {
18+
spawnNode: (cb) => {
19+
df.spawn({ args: ['--enable-pubsub-experiment'] }, (err, _ipfsd) => {
20+
if (err) {
21+
return cb(err)
22+
}
23+
24+
ipfsd = _ipfsd
25+
cb(null, IPFSApi(_ipfsd.apiAddr))
26+
})
27+
}
28+
})
29+
},
30+
teardown: function (callback) {
31+
ipfsd.stop(callback)
1532
}
1633
}
1734

test/interface/swarm.spec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,39 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const IPFSApi = require('../../src')
67

78
const DaemonFactory = require('ipfsd-ctl')
89
const df = DaemonFactory.create()
910

11+
let ipfsd = null
1012
const common = {
1113
setup: function (callback) {
12-
callback(null, df)
14+
callback(null, {
15+
spawnNode: (repoPath, config, cb) => {
16+
if (typeof repoPath === 'function') {
17+
cb = repoPath
18+
repoPath = undefined
19+
}
20+
21+
if (typeof config === 'function') {
22+
cb = config
23+
config = undefined
24+
}
25+
26+
df.spawn({ repoPath, config }, (err, _ipfsd) => {
27+
if (err) {
28+
return cb(err)
29+
}
30+
31+
ipfsd = _ipfsd
32+
cb(null, IPFSApi(_ipfsd.apiAddr))
33+
})
34+
}
35+
})
36+
},
37+
teardown: function (callback) {
38+
ipfsd.stop(callback)
1339
}
1440
}
1541

test/name.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ describe('.name', function () {
7979
})
8080
})
8181

82-
it('.name.publish', (done) => {
82+
it('.name.publish', function (done) {
83+
this.timeout(50 * 1000)
8384
ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => {
8485
expect(err).to.not.exist()
8586
name = res

0 commit comments

Comments
 (0)