From 0b80a20bc5bde25360fd2562ff7f6371286274cc Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 31 Jan 2020 20:12:49 +0000 Subject: [PATCH] fix: fix up peer test --- src/swarm/peers.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/swarm/peers.js b/src/swarm/peers.js index d908d3d1..0474223e 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -4,7 +4,7 @@ const multiaddr = require('multiaddr') const CID = require('cids') const delay = require('delay') -const { isNode } = require('ipfs-utils/src/env') +const { isNode, isBrowser } = require('ipfs-utils/src/env') const { getDescribe, getIt, expect } = require('../utils/mocha') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ @@ -103,19 +103,24 @@ module.exports = (common, options) => { '/ip4/127.0.0.1/tcp/16543', '/ip4/127.0.0.1/tcp/16544' ] : [ - '/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star', - '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' + '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' ]) const configB = getConfig(isNode || (common.opts && common.opts.type === 'go') ? [ '/ip4/127.0.0.1/tcp/26545/ws', '/ip4/127.0.0.1/tcp/26546/ws' ] : [ - '/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star', - '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' + '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' ]) const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api const nodeB = (await common.spawn({ ipfsOptions: { config: configB } })).api - await nodeA.swarm.connect(nodeB.peerId.addresses[0]) + + // TODO: the webrtc-star transport only keeps the last listened on address around + // so the browser has to use 1 as the array index + // await nodeA.swarm.connect(nodeB.peerId.addresses[0]) + await nodeA.swarm.connect(nodeB.peerId.addresses[isBrowser ? 1 : 0]) + await delay(1000) const peersA = await nodeA.swarm.peers() const peersB = await nodeB.swarm.peers()