Skip to content

Commit

Permalink
chore: added hybrid tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Aug 27, 2019
1 parent ff5a41d commit 20e8cf3
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/floodsub/go2go.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/floodsub/go2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/floodsub/js2go.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/floodsub/js2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/gossipsub/go2go.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/gossipsub/go2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/gossipsub/js2go.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub/gossipsub/js2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
38 changes: 38 additions & 0 deletions test/pubsub/hybrid/go2go.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
38 changes: 38 additions & 0 deletions test/pubsub/hybrid/go2js.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
6 changes: 6 additions & 0 deletions test/pubsub/hybrid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

require('./go2go')
require('./go2js')
require('./js2go')
require('./js2js')
38 changes: 38 additions & 0 deletions test/pubsub/hybrid/js2go.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
38 changes: 38 additions & 0 deletions test/pubsub/hybrid/js2js.js
Original file line number Diff line number Diff line change
@@ -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)
})
})
1 change: 1 addition & 0 deletions test/pubsub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

require('./gossipsub')
require('./floodsub')
require('./hybrid')
2 changes: 1 addition & 1 deletion test/pubsub/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 20e8cf3

Please sign in to comment.