Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit ceafe3e

Browse files
committed
fix: bring back reverted changes
1 parent 54d4055 commit ceafe3e

File tree

4 files changed

+40
-65
lines changed

4 files changed

+40
-65
lines changed

test/cli/pubsub.js

+23-33
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ chai.use(dirtyChai)
99
const delay = require('delay')
1010
const series = require('async/series')
1111
const ipfsExec = require('../utils/ipfs-exec')
12-
const createRepo = require('../utils/create-repo-nodejs')
1312
const IPFS = require('../../src')
1413

1514
const DaemonFactory = require('ipfsd-ctl')
16-
const df = DaemonFactory.create()
15+
const df = DaemonFactory.create({ type: 'js' })
1716

1817
const config = {
1918
Bootstrap: [],
@@ -29,59 +28,50 @@ describe('pubsub', function () {
2928
this.timeout(80 * 1000)
3029

3130
let node
32-
let ipfsd
31+
let ipfsdA
32+
let ipfsdB
3333
let cli
3434
let httpApi
3535

3636
const topicA = 'nonscentsA'
3737
const topicB = 'nonscentsB'
3838
const topicC = 'nonscentsC'
3939

40-
let repo = createRepo()
4140
before(function (done) {
4241
this.timeout(60 * 1000)
4342

44-
node = new IPFS({
45-
repo: createRepo(),
46-
init: { bits: 1024 },
47-
EXPERIMENTAL: {
48-
pubsub: true
49-
},
50-
config
51-
})
52-
53-
node.once('ready', () => {
54-
done()
55-
})
56-
57-
node.once('error', (err) => {
58-
done(err)
59-
})
43+
DaemonFactory
44+
.create({ type: 'proc' })
45+
.spawn({
46+
exec: IPFS,
47+
config,
48+
args: ['--enable-pubsub-experiment']
49+
}, (err, _ipfsd) => {
50+
expect(err).to.not.exist()
51+
ipfsdA = _ipfsd
52+
node = _ipfsd.api
53+
done()
54+
})
6055
})
6156

62-
after((done) => {
63-
node.stop((err) => {
64-
expect(err).to.not.exist()
65-
repo.teardown(done)
66-
})
67-
})
57+
after((done) => ipfsdB.stop(done))
6858

6959
before((done) => {
7060
df.spawn({
71-
type: 'js',
7261
args: ['--enable-pubsub-experiment'],
73-
exec: `${process.cwd()}/src/cli/bin.js`,
62+
exec: `./src/cli/bin.js`,
7463
config
75-
}, (err, _node) => {
64+
}, (err, _ipfsd) => {
7665
expect(err).to.not.exist()
77-
httpApi = _node.api
78-
ipfsd = _node
79-
httpApi.repoPath = ipfsd.repoPath
66+
httpApi = _ipfsd.api
67+
ipfsdB = _ipfsd
68+
httpApi.repoPath = ipfsdB.repoPath
8069
done()
8170
})
8271
})
8372

84-
after((done) => ipfsd.stop(done))
73+
after((done) => ipfsdA.stop(done))
74+
after((done) => ipfsdB.stop(done))
8575

8676
before((done) => {
8777
cli = ipfsExec(httpApi.repoPath)

test/cli/swarm.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ipfsExec = require('../utils/ipfs-exec')
1212
const parallel = require('async/parallel')
1313

1414
const DaemonFactory = require('ipfsd-ctl')
15-
const df = DaemonFactory.create()
15+
const df = DaemonFactory.create({ type: 'js' })
1616

1717
const config = {
1818
Bootstrap: [],
@@ -36,15 +36,15 @@ describe('swarm', () => {
3636

3737
series([
3838
(cb) => {
39-
df.spawn({ type: 'js', exec: `${process.cwd()}/src/cli/bin.js`, config }, (err, node) => {
39+
df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => {
4040
expect(err).to.not.exist()
4141
ipfsA = ipfsExec(node.repoPath)
4242
nodes.push(node)
4343
cb()
4444
})
4545
},
4646
(cb) => {
47-
df.spawn({ type: 'js', exec: `${process.cwd()}/src/cli/bin.js`, config }, (err, node) => {
47+
df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => {
4848
expect(err).to.not.exist()
4949
node.api.id((err, id) => {
5050
expect(err).to.not.exist()

test/core/bitswap.spec.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ const isNode = require('detect-node')
1616
const multihashing = require('multihashing-async')
1717
const CID = require('cids')
1818

19-
const IPFS = require('../../src/core')
20-
2119
const DaemonFactory = require('ipfsd-ctl')
22-
const df = DaemonFactory.create({ type: 'js', exec: `./src/cli/bin.js` })
20+
const df = DaemonFactory.create({ type: 'js' })
2321

24-
const dfProc = DaemonFactory.create({ type: 'proc', exec: IPFS })
22+
const dfProc = DaemonFactory.create({ type: 'proc' })
2523

2624
// This gets replaced by '../utils/create-repo-browser.js' in the browser
2725
const createTempRepo = require('../utils/create-repo-nodejs.js')
2826

27+
const IPFS = require('../../src/core')
28+
2929
function makeBlock (callback) {
3030
const d = Buffer.from(`IPFS is awesome ${Math.random()}`)
3131

@@ -70,6 +70,7 @@ let nodes = []
7070

7171
function addNode (inProcNode, callback) {
7272
df.spawn({
73+
exec: `./src/cli/bin.js`,
7374
config: {
7475
Addresses: {
7576
Swarm: [`/ip4/127.0.0.1/tcp/0/ws`]
@@ -114,7 +115,7 @@ describe('bitswap', function () {
114115
})
115116
}
116117

117-
dfProc.spawn({ config }, (err, _ipfsd) => {
118+
dfProc.spawn({ exec: IPFS, config }, (err, _ipfsd) => {
118119
expect(err).to.not.exist()
119120
nodes.push(_ipfsd)
120121
inProcNode = _ipfsd.api

test/core/kad-dht.node.js

+8-24
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,26 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99
const parallel = require('async/parallel')
10-
const IPFS = require('../../src')
1110

12-
const createRepo = require('../utils/create-repo-nodejs')
11+
const DaemonFactory = require('ipfsd-ctl')
12+
const df = DaemonFactory.create({ type: 'js' })
1313

1414
const config = {
1515
Addresses: {
16-
Swarm: [`/ip4/127.0.0.1/tcp/0`],
16+
Swarm: [`/ip4/127.0.0.1/tcp/0`, `/ip4/127.0.0.1/tcp/0/ws`],
1717
API: `/ip4/127.0.0.1/tcp/0`,
1818
Gateway: `/ip4/127.0.0.1/tcp/0`
1919
},
2020
Bootstrap: [],
2121
Discovery: {
2222
MDNS: {
23-
Enabled:
24-
false
23+
Enabled: false
2524
}
2625
}
2726
}
2827

2928
function createNode (callback) {
30-
const node = new IPFS({
31-
repo: createRepo(),
32-
init: { bits: 1024 },
33-
EXPERIMENTAL: {
34-
pubsub: true
35-
},
36-
config
37-
})
38-
39-
node.once('ready', () => {
40-
callback(null, node)
41-
})
42-
43-
node.once('error', (err) => {
44-
callback(err)
45-
})
29+
df.spawn({ exec: './src/cli/bin.js', config }, callback)
4630
}
4731

4832
describe('verify that kad-dht is doing its thing', () => {
@@ -62,9 +46,9 @@ describe('verify that kad-dht is doing its thing', () => {
6246
], (err, _nodes) => {
6347
expect(err).to.not.exist()
6448
nodes = _nodes
65-
nodeA = _nodes[0]
66-
nodeB = _nodes[1]
67-
nodeC = _nodes[2]
49+
nodeA = _nodes[0].api
50+
nodeB = _nodes[1].api
51+
nodeC = _nodes[2].api
6852
parallel([
6953
(cb) => nodeA.id(cb),
7054
(cb) => nodeB.id(cb),

0 commit comments

Comments
 (0)