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

Commit beff1a2

Browse files
committed
fix: fix connecting multiples node in the browser
when running with a 'proc' pre-setup we could end up with multiples in-browser setup connecting to each other. whihc isnt a very useful situation. with this the first node gets the pre-configured config and all the others get a JS daemon.
1 parent 5035a44 commit beff1a2

File tree

12 files changed

+20
-29
lines changed

12 files changed

+20
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
},
7777
"devDependencies": {
7878
"aegir": "^20.3.2",
79-
"ipfsd-ctl": "ipfs/js-ipfsd-ctl#feat/interface-tests"
79+
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#feat/interface-tests"
8080
},
8181
"contributors": [
8282
"Alan Shaw <alan.shaw@protocol.ai>",

src/bitswap/wantlist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = (common, options) => {
2525
this.timeout(60 * 1000)
2626

2727
ipfsA = await common.setup()
28-
ipfsB = await common.setup()
28+
ipfsB = await common.setup({ type: 'js' })
2929
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
3030
// Add key to the wantlist for ipfsB
3131
ipfsB.block.get(key).catch(() => {})

src/miscellaneous/resolve.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,8 @@ module.exports = (common, options) => {
8181

8282
it('should resolve IPNS link recursively', async function () {
8383
this.timeout(20 * 1000)
84-
85-
// Ensure another node exists for publishing to - only required by go-ipfs
86-
if (ipfs.peerId.agentVersion.includes('go-ipfs')) {
87-
const node = await common.setup()
88-
89-
// this fails in the browser because there is no relay node available to connect the two
90-
// nodes, but we only need this for go-ipfs as it doesn't support the `allowOffline` flag yet
91-
await ipfs.swarm.connect(node.peerId.addresses.find((a) => a.includes('127.0.0.1')))
92-
}
84+
const node = await common.setup({ type: 'js' })
85+
await ipfs.swarm.connect(node.peerId.addresses[0])
9386

9487
const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true'))
9588
const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 })

src/ping/ping-pull-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (common, options) => {
2222

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

src/ping/ping-readable-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = (common, options) => {
2323

2424
before(async () => {
2525
ipfsA = await common.setup()
26-
ipfsB = await common.setup()
26+
ipfsB = await common.setup({ type: 'js' })
2727
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2828
})
2929

src/ping/ping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = (common, options) => {
2525
this.timeout(60 * 1000)
2626

2727
ipfsA = await common.setup()
28-
ipfsB = await common.setup()
28+
ipfsB = await common.setup({ type: 'js' })
2929
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
3030
})
3131

src/pubsub/peers.js

Lines changed: 2 additions & 2 deletions
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.setup()
26-
ipfs2 = await common.setup()
27-
ipfs3 = await common.setup()
26+
ipfs2 = await common.setup({ type: 'js' })
27+
ipfs3 = await common.setup({ type: 'js' })
2828

2929
const ipfs2Addr = ipfs2.peerId.addresses.find((a) => a.includes('127.0.0.1'))
3030
const ipfs3Addr = ipfs3.peerId.addresses.find((a) => a.includes('127.0.0.1'))

src/pubsub/subscribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = (common, options) => {
3030
this.timeout(100 * 1000)
3131

3232
ipfs1 = await common.setup()
33-
ipfs2 = await common.setup()
33+
ipfs2 = await common.setup({ type: 'js' })
3434
})
3535

3636
after(() => common.teardown())

src/swarm/addrs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = (common, options) => {
2121

2222
before(async () => {
2323
ipfsA = await common.setup()
24-
ipfsB = await common.setup()
24+
ipfsB = await common.setup({ type: 'js' })
2525
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2626
})
2727

src/swarm/connect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (common, options) => {
1919

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

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

src/swarm/disconnect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = (common, options) => {
2020

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

src/swarm/peers.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = (common, options) => {
2323

2424
before(async () => {
2525
ipfsA = await common.setup()
26-
ipfsB = await common.setup()
26+
ipfsB = await common.setup({ type: 'js' })
2727
await ipfsA.swarm.connect(ipfsB.peerId.addresses[0])
2828
await delay(60 * 1000) // wait for open streams in the connection available
2929
})
@@ -84,10 +84,8 @@ module.exports = (common, options) => {
8484
}
8585

8686
it('should list peers only once', async () => {
87-
const config = getConfig(['/ip4/127.0.0.1/tcp/0'])
88-
89-
const nodeA = await common.setup({ spawnOptions: { config } })
90-
const nodeB = await common.setup({ spawnOptions: { config } })
87+
const nodeA = await common.setup()
88+
const nodeB = await common.setup({ type: 'js' })
9189
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
9290
await delay(1000)
9391
const peersA = await nodeA.swarm.peers()
@@ -103,11 +101,11 @@ module.exports = (common, options) => {
103101
'/ip4/127.0.0.1/tcp/16544'
104102
])
105103
const configB = getConfig([
106-
'/ip4/127.0.0.1/tcp/26545',
107-
'/ip4/127.0.0.1/tcp/26546'
104+
'/ip4/127.0.0.1/tcp/26545/ws',
105+
'/ip4/127.0.0.1/tcp/26546/ws'
108106
])
109-
const nodeA = await common.setup({ spawnOptions: { config: configA } })
110-
const nodeB = await common.setup({ spawnOptions: { config: configB } })
107+
const nodeA = await common.setup({ ipfsOptions: { config: configA } })
108+
const nodeB = await common.setup({ type: 'js', ipfsOptions: { config: configB } })
111109
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
112110
await delay(1000)
113111
const peersA = await nodeA.swarm.peers()

0 commit comments

Comments
 (0)