From 4cf3c65268c8b4a0ee64ec0da3c757934a2c112a Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 23:44:34 +0000 Subject: [PATCH 1/5] 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. --- src/ping/ping.js | 2 +- src/swarm/addrs.js | 2 +- src/swarm/connect.js | 2 +- src/swarm/disconnect.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ping/ping.js b/src/ping/ping.js index 12a77d6c..905b511e 100644 --- a/src/ping/ping.js +++ b/src/ping/ping.js @@ -22,7 +22,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'js' })).api + ipfsB = (await common.spawn()).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) }) diff --git a/src/swarm/addrs.js b/src/swarm/addrs.js index 994a4d0f..a9aea724 100644 --- a/src/swarm/addrs.js +++ b/src/swarm/addrs.js @@ -22,7 +22,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'js' })).api + ipfsB = (await common.spawn()).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) }) diff --git a/src/swarm/connect.js b/src/swarm/connect.js index 21f501d6..4701c695 100644 --- a/src/swarm/connect.js +++ b/src/swarm/connect.js @@ -19,7 +19,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'js' })).api + ipfsB = (await common.spawn()).api }) after(() => common.clean()) diff --git a/src/swarm/disconnect.js b/src/swarm/disconnect.js index 09f01a40..214b0d9e 100644 --- a/src/swarm/disconnect.js +++ b/src/swarm/disconnect.js @@ -20,7 +20,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'js' })).api + ipfsB = (await common.spawn()).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) }) From 56e09cc394a94efdcb3c2a444bc2ceb2a3d20902 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 29 Jan 2020 23:56:08 +0000 Subject: [PATCH 2/5] fix: one more reference --- src/swarm/peers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swarm/peers.js b/src/swarm/peers.js index 404b9e4a..6e125bb3 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -108,7 +108,7 @@ module.exports = (common, options) => { '/ip4/127.0.0.1/tcp/26546/ws' ]) const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api - const nodeB = (await common.spawn({ type: 'js', ipfsOptions: { config: configB } })).api + const nodeB = (await common.spawn({ ipfsOptions: { config: configB } })).api await nodeA.swarm.connect(nodeB.peerId.addresses[0]) await delay(1000) const peersA = await nodeA.swarm.peers() From a197632344375b1a5ff08962fda9d2b2ec86dcdc Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 30 Jan 2020 09:12:11 +0000 Subject: [PATCH 3/5] fix: do not assume go-ipfs is present either --- src/bitswap/wantlist.js | 2 +- src/miscellaneous/resolve.js | 2 +- src/pubsub/peers.js | 4 ++-- src/pubsub/subscribe.js | 2 +- src/swarm/peers.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bitswap/wantlist.js b/src/bitswap/wantlist.js index 7d673258..7d97c6c1 100644 --- a/src/bitswap/wantlist.js +++ b/src/bitswap/wantlist.js @@ -21,7 +21,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'go' })).api + ipfsB = (await common.spawn()).api // Add key to the wantlist for ipfsB ipfsB.block.get(key).catch(() => { /* is ok, expected on teardown */ }) await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) diff --git a/src/miscellaneous/resolve.js b/src/miscellaneous/resolve.js index 8674425f..27bb397b 100644 --- a/src/miscellaneous/resolve.js +++ b/src/miscellaneous/resolve.js @@ -82,7 +82,7 @@ module.exports = (common, options) => { it('should resolve IPNS link recursively', async function () { this.timeout(20 * 1000) - const node = (await common.spawn({ type: 'go' })).api + const node = (await common.spawn()).api await ipfs.swarm.connect(node.peerId.addresses[0]) const [{ path }] = await all(ipfs.add(Buffer.from('should resolve a record recursive === true'))) const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 }) diff --git a/src/pubsub/peers.js b/src/pubsub/peers.js index ff56ba3d..eb75d914 100644 --- a/src/pubsub/peers.js +++ b/src/pubsub/peers.js @@ -23,8 +23,8 @@ module.exports = (common, options) => { let subscribedTopics = [] before(async () => { ipfs1 = (await common.spawn()).api - ipfs2 = (await common.spawn({ type: 'go' })).api - ipfs3 = (await common.spawn({ type: 'go' })).api + ipfs2 = (await common.spawn()).api + ipfs3 = (await common.spawn()).api const ipfs2Addr = ipfs2.peerId.addresses .find(ma => ma.nodeAddress().address === '127.0.0.1') diff --git a/src/pubsub/subscribe.js b/src/pubsub/subscribe.js index 17354377..6dad3bbe 100644 --- a/src/pubsub/subscribe.js +++ b/src/pubsub/subscribe.js @@ -28,7 +28,7 @@ module.exports = (common, options) => { ipfs1 = (await common.spawn()).api // TODO 'multiple connected nodes' tests fails with go in Firefox // and JS is flaky everywhere - ipfs2 = (await common.spawn({ type: 'go' })).api + ipfs2 = (await common.spawn()).api }) beforeEach(() => { diff --git a/src/swarm/peers.js b/src/swarm/peers.js index 6e125bb3..3a7f5a4b 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -24,7 +24,7 @@ module.exports = (common, options) => { before(async () => { ipfsA = (await common.spawn()).api - ipfsB = (await common.spawn({ type: 'go' })).api + ipfsB = (await common.spawn()).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) /* TODO: Seen if we still need this after this is fixed https://github.com/ipfs/js-ipfs/issues/2601 gets resolved */ @@ -88,7 +88,7 @@ module.exports = (common, options) => { it('should list peers only once', async () => { const nodeA = (await common.spawn()).api - const nodeB = (await common.spawn({ type: 'go' })).api + const nodeB = (await common.spawn()).api await nodeA.swarm.connect(nodeB.peerId.addresses[0]) await delay(1000) const peersA = await nodeA.swarm.peers() From c5f549b2d9b2bd0dc51647bf6dd297047ed60a43 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 30 Jan 2020 20:34:41 +0000 Subject: [PATCH 4/5] fix: configure webrtc for browser nodes ipfs-http-client tests might need to start a webrtc signalling server in the background. --- src/swarm/peers.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/swarm/peers.js b/src/swarm/peers.js index 3a7f5a4b..217bbabc 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -99,13 +99,19 @@ module.exports = (common, options) => { it('should list peers only once even if they have multiple addresses', async () => { // TODO: Change to port 0, needs: https://github.com/ipfs/interface-ipfs-core/issues/152 - const configA = getConfig(isNode ? [ // browser nodes cannot listen + const configA = getConfig(isNode ? [ '/ip4/127.0.0.1/tcp/16543', '/ip4/127.0.0.1/tcp/16544' - ] : []) - const configB = getConfig([ + ] : [ + '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' + ]) + const configB = getConfig(isNode ? [ '/ip4/127.0.0.1/tcp/26545/ws', '/ip4/127.0.0.1/tcp/26546/ws' + ] : [ + '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' ]) const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api const nodeB = (await common.spawn({ ipfsOptions: { config: configB } })).api From a02a18bd50c0b7b61f4c6b6449c388cd8d59c453 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 30 Jan 2020 21:46:28 +0000 Subject: [PATCH 5/5] fix: fix up http client tests --- src/swarm/peers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/swarm/peers.js b/src/swarm/peers.js index 217bbabc..d908d3d1 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -99,18 +99,18 @@ module.exports = (common, options) => { it('should list peers only once even if they have multiple addresses', async () => { // TODO: Change to port 0, needs: https://github.com/ipfs/interface-ipfs-core/issues/152 - const configA = getConfig(isNode ? [ + const configA = getConfig(isNode || (common.opts && common.opts.type === 'go') ? [ '/ip4/127.0.0.1/tcp/16543', '/ip4/127.0.0.1/tcp/16544' ] : [ - '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' ]) - const configB = getConfig(isNode ? [ + 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/14579/wss/p2p-webrtc-star', + '/ip4/127.0.0.1/tcp/14578/wss/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star' ]) const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api