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

Commit 0b80a20

Browse files
committed
fix: fix up peer test
1 parent 816cd8d commit 0b80a20

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/swarm/peers.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const multiaddr = require('multiaddr')
55
const CID = require('cids')
66
const delay = require('delay')
7-
const { isNode } = require('ipfs-utils/src/env')
7+
const { isNode, isBrowser } = require('ipfs-utils/src/env')
88
const { getDescribe, getIt, expect } = require('../utils/mocha')
99

1010
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
@@ -103,19 +103,24 @@ module.exports = (common, options) => {
103103
'/ip4/127.0.0.1/tcp/16543',
104104
'/ip4/127.0.0.1/tcp/16544'
105105
] : [
106-
'/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star',
107-
'/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
106+
'/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star',
107+
'/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star'
108108
])
109109
const configB = getConfig(isNode || (common.opts && common.opts.type === 'go') ? [
110110
'/ip4/127.0.0.1/tcp/26545/ws',
111111
'/ip4/127.0.0.1/tcp/26546/ws'
112112
] : [
113-
'/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star',
114-
'/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
113+
'/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star',
114+
'/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star'
115115
])
116116
const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api
117117
const nodeB = (await common.spawn({ ipfsOptions: { config: configB } })).api
118-
await nodeA.swarm.connect(nodeB.peerId.addresses[0])
118+
119+
// TODO: the webrtc-star transport only keeps the last listened on address around
120+
// so the browser has to use 1 as the array index
121+
// await nodeA.swarm.connect(nodeB.peerId.addresses[0])
122+
await nodeA.swarm.connect(nodeB.peerId.addresses[isBrowser ? 1 : 0])
123+
119124
await delay(1000)
120125
const peersA = await nodeA.swarm.peers()
121126
const peersB = await nodeB.swarm.peers()

0 commit comments

Comments
 (0)