mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-23 14:01:35 +00:00
fix: add timeout for incoming connections and build-in protocols (#1292)
Ensure that we don't wait forever for upgrading an inbound connection to occur. Note that transports should return an AbortableSource when passed an AbortSignal so outbound connections to not need the same fix. Also adds default timeouts for the ping, fetch, and identify protocols.
This commit is contained in:
@ -10,6 +10,7 @@ import { mockConnection, mockDuplex, mockMultiaddrConnection } from '@libp2p/int
|
||||
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
||||
import { CustomEvent } from '@libp2p/interfaces/events'
|
||||
import { KEEP_ALIVE } from '@libp2p/interface-peer-store/tags'
|
||||
import pWaitFor from 'p-wait-for'
|
||||
|
||||
describe('Connection Manager', () => {
|
||||
let libp2p: Libp2pNode
|
||||
@ -163,6 +164,10 @@ describe('Connection Manager', () => {
|
||||
await libp2p.stop()
|
||||
await libp2p.start()
|
||||
|
||||
await pWaitFor(() => connectionManagerOpenConnectionSpy.called, {
|
||||
interval: 100
|
||||
})
|
||||
|
||||
expect(connectionManagerOpenConnectionSpy.called).to.be.true('Did not attempt to connect to important peer')
|
||||
expect(connectionManagerOpenConnectionSpy.getCall(0).args[0].toString()).to.equal(peerId.toString(), 'Attempted to connect to the wrong peer')
|
||||
})
|
||||
|
Reference in New Issue
Block a user