diff --git a/package.json b/package.json index f91fafe..40d75dc 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", "go-libp2p-dep": "~0.1.0", - "libp2p-daemon": "libp2p/js-libp2p-daemon#feat/integrate-gossipsub-by-default", + "libp2p-daemon": "~0.2.3", "libp2p-daemon-client": "~0.2.1", "multiaddr": "^6.0.6", "rimraf": "^2.6.3" diff --git a/test/pubsub/floodsub/go2go.js b/test/pubsub/floodsub/go2go.js index 319c676..9aa5082 100644 --- a/test/pubsub/floodsub/go2go.js +++ b/test/pubsub/floodsub/go2go.js @@ -26,7 +26,7 @@ describe('pubsub - floodsub', () => { }) it('go publish to go subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/floodsub/go2js.js b/test/pubsub/floodsub/go2js.js index 508ae5a..d0f5210 100644 --- a/test/pubsub/floodsub/go2js.js +++ b/test/pubsub/floodsub/go2js.js @@ -26,7 +26,7 @@ describe('pubsub - floodsub', () => { }) it('go publish to js subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/floodsub/js2go.js b/test/pubsub/floodsub/js2go.js index 3963faf..ea3572c 100644 --- a/test/pubsub/floodsub/js2go.js +++ b/test/pubsub/floodsub/js2go.js @@ -26,7 +26,7 @@ describe('pubsub - floodsub', () => { }) it('js publish to go subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/floodsub/js2js.js b/test/pubsub/floodsub/js2js.js index 1e0dd34..dc3b379 100644 --- a/test/pubsub/floodsub/js2js.js +++ b/test/pubsub/floodsub/js2js.js @@ -26,7 +26,7 @@ describe('pubsub - floodsub', () => { }) it('js publish to js subscriber', function () { - this.timeout(10 * 1000) + this.timeout(30 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/gossipsub/go2go.js b/test/pubsub/gossipsub/go2go.js index 6225c14..4c560d8 100644 --- a/test/pubsub/gossipsub/go2go.js +++ b/test/pubsub/gossipsub/go2go.js @@ -26,7 +26,7 @@ describe('pubsub - gossipsub', () => { }) it('go publish to go subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/gossipsub/go2js.js b/test/pubsub/gossipsub/go2js.js index 20b2255..a48ad48 100644 --- a/test/pubsub/gossipsub/go2js.js +++ b/test/pubsub/gossipsub/go2js.js @@ -26,7 +26,7 @@ describe('pubsub - gossipsub', () => { }) it('go publish to js subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/gossipsub/js2go.js b/test/pubsub/gossipsub/js2go.js index a611e8d..0f58e53 100644 --- a/test/pubsub/gossipsub/js2go.js +++ b/test/pubsub/gossipsub/js2go.js @@ -26,7 +26,7 @@ describe('pubsub - gossipsub', () => { }) it('js publish to go subscriber', function () { - this.timeout(10 * 1000) + this.timeout(20 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/gossipsub/js2js.js b/test/pubsub/gossipsub/js2js.js index d58d208..76fb94a 100644 --- a/test/pubsub/gossipsub/js2js.js +++ b/test/pubsub/gossipsub/js2js.js @@ -26,7 +26,7 @@ describe('pubsub - gossipsub', () => { }) it('js publish to js subscriber', function () { - this.timeout(10 * 1000) + this.timeout(30 * 1000) return pubsubTest(daemons) }) diff --git a/test/pubsub/hybrid/go2go.js b/test/pubsub/hybrid/go2go.js new file mode 100644 index 0000000..da066e1 --- /dev/null +++ b/test/pubsub/hybrid/go2go.js @@ -0,0 +1,38 @@ +/* eslint-env mocha */ +'use strict' + +const spawnDaemons = require('../../utils/spawnDaemons') +const { pubsubTest } = require('../test') + +describe('pubsub - hybrid', () => { + let daemons + + // Start daemons + before(async function () { + this.timeout(20 * 1000) + + const daemonOptions = [ + { pubsub: true, pubsubRouter: 'floodsub' }, + { pubsub: true, pubsubRouter: 'gossipsub' } + ] + + daemons = await spawnDaemons(2, 'go', daemonOptions) + + // connect them + const identify0 = await daemons[0].client.identify() + await daemons[1].client.connect(identify0.peerId, identify0.addrs) + }) + + // Stop daemons + after(async function () { + await Promise.all( + daemons.map((daemon) => daemon.stop()) + ) + }) + + it('go floodsub publish to go gossipsub subscriber', function () { + this.timeout(20 * 1000) + + return pubsubTest(daemons) + }) +}) diff --git a/test/pubsub/hybrid/go2js.js b/test/pubsub/hybrid/go2js.js new file mode 100644 index 0000000..654a20f --- /dev/null +++ b/test/pubsub/hybrid/go2js.js @@ -0,0 +1,38 @@ +/* eslint-env mocha */ +'use strict' + +const spawnDaemons = require('../../utils/spawnDaemons') +const { pubsubTest } = require('../test') + +describe('pubsub - hybrid', () => { + let daemons + + // Start daemons + before(async function () { + this.timeout(20 * 1000) + + const daemonOptions = [ + { pubsub: true, pubsubRouter: 'floodsub' }, + { pubsub: true, pubsubRouter: 'gossipsub' } + ] + + daemons = await spawnDaemons(2, ['go', 'js'], daemonOptions) + + // connect them + const identify0 = await daemons[0].client.identify() + await daemons[1].client.connect(identify0.peerId, identify0.addrs) + }) + + // Stop daemons + after(async function () { + await Promise.all( + daemons.map((daemon) => daemon.stop()) + ) + }) + + it('go floodsub publish to js gossipsub subscriber', function () { + this.timeout(20 * 1000) + + return pubsubTest(daemons) + }) +}) diff --git a/test/pubsub/hybrid/index.js b/test/pubsub/hybrid/index.js new file mode 100644 index 0000000..dbe06c2 --- /dev/null +++ b/test/pubsub/hybrid/index.js @@ -0,0 +1,6 @@ +'use strict' + +require('./go2go') +require('./go2js') +require('./js2go') +require('./js2js') diff --git a/test/pubsub/hybrid/js2go.js b/test/pubsub/hybrid/js2go.js new file mode 100644 index 0000000..c40f8ed --- /dev/null +++ b/test/pubsub/hybrid/js2go.js @@ -0,0 +1,38 @@ +/* eslint-env mocha */ +'use strict' + +const spawnDaemons = require('../../utils/spawnDaemons') +const { pubsubTest } = require('../test') + +describe('pubsub - hybrid', () => { + let daemons + + // Start daemons + before(async function () { + this.timeout(20 * 1000) + + const daemonOptions = [ + { pubsub: true, pubsubRouter: 'floodsub' }, + { pubsub: true, pubsubRouter: 'gossipsub' } + ] + + daemons = await spawnDaemons(2, ['js', 'go'], daemonOptions) + + // connect them + const identify0 = await daemons[0].client.identify() + await daemons[1].client.connect(identify0.peerId, identify0.addrs) + }) + + // Stop daemons + after(async function () { + await Promise.all( + daemons.map((daemon) => daemon.stop()) + ) + }) + + it('js floodsub publish to go gossipsub subscriber', function () { + this.timeout(20 * 1000) + + return pubsubTest(daemons) + }) +}) diff --git a/test/pubsub/hybrid/js2js.js b/test/pubsub/hybrid/js2js.js new file mode 100644 index 0000000..ef4ca56 --- /dev/null +++ b/test/pubsub/hybrid/js2js.js @@ -0,0 +1,38 @@ +/* eslint-env mocha */ +'use strict' + +const spawnDaemons = require('../../utils/spawnDaemons') +const { pubsubTest } = require('../test') + +describe('pubsub - hybrid', () => { + let daemons + + // Start daemons + before(async function () { + this.timeout(20 * 1000) + + const daemonOptions = [ + { pubsub: true, pubsubRouter: 'floodsub' }, + { pubsub: true, pubsubRouter: 'gossipsub' } + ] + + daemons = await spawnDaemons(2, 'js', daemonOptions) + + // connect them + const identify0 = await daemons[0].client.identify() + await daemons[1].client.connect(identify0.peerId, identify0.addrs) + }) + + // Stop daemons + after(async function () { + await Promise.all( + daemons.map((daemon) => daemon.stop()) + ) + }) + + it('js floodsub publish to js gossipsub subscriber', function () { + this.timeout(30 * 1000) + + return pubsubTest(daemons) + }) +}) diff --git a/test/pubsub/index.js b/test/pubsub/index.js index 2726aa0..d56d736 100644 --- a/test/pubsub/index.js +++ b/test/pubsub/index.js @@ -2,3 +2,4 @@ require('./gossipsub') require('./floodsub') +require('./hybrid') diff --git a/test/pubsub/test.js b/test/pubsub/test.js index ba6aa51..1773911 100644 --- a/test/pubsub/test.js +++ b/test/pubsub/test.js @@ -21,7 +21,7 @@ exports.pubsubTest = async (daemons) => { const publisher = async () => { // wait for subscription stream - await new Promise(resolve => setTimeout(resolve, 200)) + await new Promise(resolve => setTimeout(resolve, 800)) daemons[0].client.pubsub.publish(topic, data) }