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

fix: do not assume certain implementations of ipfs are present #584

Merged
merged 5 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/miscellaneous/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
2 changes: 1 addition & 1 deletion src/ping/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})

Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/swarm/addrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})

Expand Down
2 changes: 1 addition & 1 deletion src/swarm/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/swarm/disconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})

Expand Down
18 changes: 12 additions & 6 deletions src/swarm/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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()
Expand All @@ -99,16 +99,22 @@ 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 || (common.opts && common.opts.type === 'go') ? [
'/ip4/127.0.0.1/tcp/16543',
'/ip4/127.0.0.1/tcp/16544'
] : [])
const configB = getConfig([
] : [
'/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 || (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'
])
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()
Expand Down