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

Commit 3d24911

Browse files
authored
fix: do not assume certain implementations of ipfs are present (#584)
* fix: do not assume js-ipfs is present Passing `type: 'js'` requires the containing project to have a dependency on js-IPFS which may not be the case. * fix: one more reference * fix: do not assume go-ipfs is present either * fix: configure webrtc for browser nodes ipfs-http-client tests might need to start a webrtc signalling server in the background. * fix: fix up http client tests
1 parent ceb4eef commit 3d24911

File tree

9 files changed

+21
-15
lines changed

9 files changed

+21
-15
lines changed

src/bitswap/wantlist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = (common, options) => {
2121

2222
before(async () => {
2323
ipfsA = (await common.spawn()).api
24-
ipfsB = (await common.spawn({ type: 'go' })).api
24+
ipfsB = (await common.spawn()).api
2525
// Add key to the wantlist for ipfsB
2626
ipfsB.block.get(key).catch(() => { /* is ok, expected on teardown */ })
2727
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])

src/miscellaneous/resolve.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = (common, options) => {
8282

8383
it('should resolve IPNS link recursively', async function () {
8484
this.timeout(20 * 1000)
85-
const node = (await common.spawn({ type: 'go' })).api
85+
const node = (await common.spawn()).api
8686
await ipfs.swarm.connect(node.peerId.addresses[0])
8787
const [{ path }] = await all(ipfs.add(Buffer.from('should resolve a record recursive === true')))
8888
const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 })

src/ping/ping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (common, options) => {
2222

2323
before(async () => {
2424
ipfsA = (await common.spawn()).api
25-
ipfsB = (await common.spawn({ type: 'js' })).api
25+
ipfsB = (await common.spawn()).api
2626
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2727
})
2828

src/pubsub/peers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module.exports = (common, options) => {
2323
let subscribedTopics = []
2424
before(async () => {
2525
ipfs1 = (await common.spawn()).api
26-
ipfs2 = (await common.spawn({ type: 'go' })).api
27-
ipfs3 = (await common.spawn({ type: 'go' })).api
26+
ipfs2 = (await common.spawn()).api
27+
ipfs3 = (await common.spawn()).api
2828

2929
const ipfs2Addr = ipfs2.peerId.addresses
3030
.find(ma => ma.nodeAddress().address === '127.0.0.1')

src/pubsub/subscribe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = (common, options) => {
2828
ipfs1 = (await common.spawn()).api
2929
// TODO 'multiple connected nodes' tests fails with go in Firefox
3030
// and JS is flaky everywhere
31-
ipfs2 = (await common.spawn({ type: 'go' })).api
31+
ipfs2 = (await common.spawn()).api
3232
})
3333

3434
beforeEach(() => {

src/swarm/addrs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (common, options) => {
2222

2323
before(async () => {
2424
ipfsA = (await common.spawn()).api
25-
ipfsB = (await common.spawn({ type: 'js' })).api
25+
ipfsB = (await common.spawn()).api
2626
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2727
})
2828

src/swarm/connect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (common, options) => {
1919

2020
before(async () => {
2121
ipfsA = (await common.spawn()).api
22-
ipfsB = (await common.spawn({ type: 'js' })).api
22+
ipfsB = (await common.spawn()).api
2323
})
2424

2525
after(() => common.clean())

src/swarm/disconnect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = (common, options) => {
2020

2121
before(async () => {
2222
ipfsA = (await common.spawn()).api
23-
ipfsB = (await common.spawn({ type: 'js' })).api
23+
ipfsB = (await common.spawn()).api
2424
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2525
})
2626

src/swarm/peers.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = (common, options) => {
2424

2525
before(async () => {
2626
ipfsA = (await common.spawn()).api
27-
ipfsB = (await common.spawn({ type: 'go' })).api
27+
ipfsB = (await common.spawn()).api
2828
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2929
/* TODO: Seen if we still need this after this is fixed
3030
https://github.com/ipfs/js-ipfs/issues/2601 gets resolved */
@@ -88,7 +88,7 @@ module.exports = (common, options) => {
8888

8989
it('should list peers only once', async () => {
9090
const nodeA = (await common.spawn()).api
91-
const nodeB = (await common.spawn({ type: 'go' })).api
91+
const nodeB = (await common.spawn()).api
9292
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
9393
await delay(1000)
9494
const peersA = await nodeA.swarm.peers()
@@ -99,16 +99,22 @@ module.exports = (common, options) => {
9999

100100
it('should list peers only once even if they have multiple addresses', async () => {
101101
// TODO: Change to port 0, needs: https://github.com/ipfs/interface-ipfs-core/issues/152
102-
const configA = getConfig(isNode ? [ // browser nodes cannot listen
102+
const configA = getConfig(isNode || (common.opts && common.opts.type === 'go') ? [
103103
'/ip4/127.0.0.1/tcp/16543',
104104
'/ip4/127.0.0.1/tcp/16544'
105-
] : [])
106-
const configB = getConfig([
105+
] : [
106+
'/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star',
107+
'/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
108+
])
109+
const configB = getConfig(isNode || (common.opts && common.opts.type === 'go') ? [
107110
'/ip4/127.0.0.1/tcp/26545/ws',
108111
'/ip4/127.0.0.1/tcp/26546/ws'
112+
] : [
113+
'/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star',
114+
'/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
109115
])
110116
const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api
111-
const nodeB = (await common.spawn({ type: 'js', ipfsOptions: { config: configB } })).api
117+
const nodeB = (await common.spawn({ ipfsOptions: { config: configB } })).api
112118
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
113119
await delay(1000)
114120
const peersA = await nodeA.swarm.peers()

0 commit comments

Comments
 (0)