Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 3699c17

Browse files
authored
fix: remove timeouts (#104)
Control them with global --timeout settings instead as some CI systems have worse performance than others.
1 parent cd4c409 commit 3699c17

File tree

6 files changed

+44
-25
lines changed

6 files changed

+44
-25
lines changed

packages/compliance-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"bugs": {
3333
"url": "https://github.com/libp2p/js-libp2p-interfaces/issues"
3434
},
35-
"homepage": "https://github.com/libp2p/js-libp2p-interfaces#readme",
35+
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/compliance-tests#readme#readme",
3636
"dependencies": {
3737
"abort-controller": "^3.0.0",
3838
"abortable-iterator": "^3.0.0",

packages/compliance-tests/src/pubsub/connection-handlers.js

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ module.exports = (common) => {
4545
})
4646

4747
it('existing subscriptions are sent upon peer connection', async function () {
48-
this.timeout(10e3)
49-
5048
await Promise.all([
5149
psA._libp2p.dial(psB.peerId),
5250
new Promise((resolve) => psA.once('pubsub:subscription-change', resolve)),
@@ -206,7 +204,6 @@ module.exports = (common) => {
206204
})
207205

208206
it('should receive pubsub messages after a node restart', async function () {
209-
this.timeout(10e3)
210207
const topic = 'test-topic'
211208
const data = uint8ArrayFromString('hey!')
212209
const psAid = psA.peerId.toB58String()
@@ -261,15 +258,40 @@ module.exports = (common) => {
261258

262259
it('should handle quick reconnects with a delayed disconnect', async () => {
263260
// Subscribe on both
264-
const handlerSpy = sinon.spy()
261+
let aReceivedFirstMessageFromB = false
262+
let aReceivedSecondMessageFromB = false
263+
let bReceivedFirstMessageFromA = false
264+
let bReceivedSecondMessageFromA = false
265+
266+
const handlerSpyA = (message) => {
267+
const data = uint8ArrayToString(message.data)
268+
269+
if (data === 'message-from-b-1') {
270+
aReceivedFirstMessageFromB = true
271+
}
272+
273+
if (data === 'message-from-b-2') {
274+
aReceivedSecondMessageFromB = true
275+
}
276+
}
277+
const handlerSpyB = (message) => {
278+
const data = uint8ArrayToString(message.data)
279+
280+
if (data === 'message-from-a-1') {
281+
bReceivedFirstMessageFromA = true
282+
}
283+
284+
if (data === 'message-from-a-2') {
285+
bReceivedSecondMessageFromA = true
286+
}
287+
}
288+
265289
const topic = 'reconnect-channel'
266290

267-
psA.on(topic, handlerSpy)
268-
psB.on(topic, handlerSpy)
269-
await Promise.all([
270-
psA.subscribe(topic),
271-
psB.subscribe(topic)
272-
])
291+
psA.on(topic, handlerSpyA)
292+
psB.on(topic, handlerSpyB)
293+
psA.subscribe(topic)
294+
psB.subscribe(topic)
273295

274296
// Create two connections to the remote peer
275297
const originalConnection = await psA._libp2p.dialer.connectToPeer(psB.peerId)
@@ -284,10 +306,11 @@ module.exports = (common) => {
284306
})
285307

286308
// Verify messages go both ways
287-
psA.publish(topic, uint8ArrayFromString('message1'))
288-
psB.publish(topic, uint8ArrayFromString('message2'))
289-
await pWaitFor(() => handlerSpy.callCount >= 2)
290-
expect(handlerSpy.args.map(([message]) => uint8ArrayToString(message.data))).to.include.members(['message1', 'message2'])
309+
psA.publish(topic, uint8ArrayFromString('message-from-a-1'))
310+
psB.publish(topic, uint8ArrayFromString('message-from-b-1'))
311+
await pWaitFor(() => {
312+
return aReceivedFirstMessageFromB && bReceivedFirstMessageFromA
313+
})
291314

292315
// Disconnect the first connection (this acts as a delayed reconnect)
293316
const psAConnUpdateSpy = sinon.spy(psA._libp2p.connectionManager.connections, 'set')
@@ -296,11 +319,11 @@ module.exports = (common) => {
296319
await pWaitFor(() => psAConnUpdateSpy.callCount === 1)
297320

298321
// Verify messages go both ways after the disconnect
299-
handlerSpy.resetHistory()
300-
psA.publish(topic, uint8ArrayFromString('message3'))
301-
psB.publish(topic, uint8ArrayFromString('message4'))
302-
await pWaitFor(() => handlerSpy.callCount >= 2)
303-
expect(handlerSpy.args.map(([message]) => uint8ArrayToString(message.data))).to.include.members(['message3', 'message4'])
322+
psA.publish(topic, uint8ArrayFromString('message-from-a-2'))
323+
psB.publish(topic, uint8ArrayFromString('message-from-b-2'))
324+
await pWaitFor(() => {
325+
return aReceivedSecondMessageFromB && bReceivedSecondMessageFromA
326+
})
304327
})
305328
})
306329
})

packages/compliance-tests/src/pubsub/multiple-nodes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const { expectSet } = require('./utils')
1616

1717
module.exports = (common) => {
1818
describe('pubsub with multiple nodes', function () {
19-
this.timeout(10e3)
2019
describe('every peer subscribes to the topic', () => {
2120
describe('line', () => {
2221
// line
@@ -253,7 +252,6 @@ module.exports = (common) => {
253252
})
254253

255254
it('publishes from c', async function () {
256-
this.timeout(30 * 1000)
257255
const defer = pDefer()
258256
let counter = 0
259257

packages/compliance-tests/src/stream-muxer/mega-stress-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const spawn = require('./spawner')
66

77
module.exports = (common) => {
88
describe.skip('mega stress test', function () {
9-
this.timeout(100 * 200 * 1000)
109
let Muxer
1110

1211
beforeEach(async () => {

packages/compliance-tests/src/stream-muxer/stress-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = (common) => {
2424
it('1000 streams with 1 msg', () => spawn(Muxer, 1000, 1))
2525
it('1000 streams with 10 msg', () => spawn(Muxer, 1000, 10))
2626
it('1000 streams with 100 msg', function () {
27-
this.timeout(30 * 1000)
2827
return spawn(Muxer, 1000, 100)
2928
})
3029
})

packages/interfaces/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"bugs": {
5353
"url": "https://github.com/libp2p/js-interfaces/issues"
5454
},
55-
"homepage": "https://github.com/libp2p/js-interfaces#readme",
55+
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interfaces#readme",
5656
"dependencies": {
5757
"abort-controller": "^3.0.0",
5858
"abortable-iterator": "^3.0.0",

0 commit comments

Comments
 (0)