mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-28 08:21:33 +00:00
refactor: connection manager (#511)
* refactor: initial refactor of the connection manager * fix: start/stop issues * fix: add tests and resolve pruning issues * chore: fix lint * test: move conn manager tests to node only for now * chore: apply suggestions from code review Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio> * fix: assert min max connection options * test: fix assertion check for browser * docs: add api and config docs for conn manager
This commit is contained in:
@ -33,9 +33,16 @@ describe('libp2p.metrics', () => {
|
||||
})
|
||||
|
||||
it('should start/stop metrics on startup/shutdown when enabled', async () => {
|
||||
const config = { ...baseOptions }
|
||||
config.metrics = {
|
||||
enabled: true
|
||||
const config = {
|
||||
...baseOptions,
|
||||
connectionManager: {
|
||||
movingAverageIntervals: [10]
|
||||
},
|
||||
metrics: {
|
||||
enabled: true,
|
||||
computeThrottleMaxQueueSize: 1, // compute after every message
|
||||
movingAverageIntervals: [10]
|
||||
}
|
||||
}
|
||||
;[libp2p] = await createPeer({ started: false, config })
|
||||
|
||||
@ -51,11 +58,16 @@ describe('libp2p.metrics', () => {
|
||||
})
|
||||
|
||||
it('should record metrics on connections and streams when enabled', async () => {
|
||||
const config = { ...baseOptions }
|
||||
config.metrics = {
|
||||
enabled: true,
|
||||
computeThrottleMaxQueueSize: 1, // compute after every message
|
||||
movingAverageIntervals: [10]
|
||||
const config = {
|
||||
...baseOptions,
|
||||
connectionManager: {
|
||||
movingAverageIntervals: [10]
|
||||
},
|
||||
metrics: {
|
||||
enabled: true,
|
||||
computeThrottleMaxQueueSize: 1, // compute after every message
|
||||
movingAverageIntervals: [10]
|
||||
}
|
||||
}
|
||||
let remoteLibp2p
|
||||
;[libp2p, remoteLibp2p] = await createPeer({ number: 2, config })
|
||||
@ -88,11 +100,16 @@ describe('libp2p.metrics', () => {
|
||||
})
|
||||
|
||||
it('should move disconnected peers to the old peers list', async () => {
|
||||
const config = { ...baseOptions }
|
||||
config.metrics = {
|
||||
enabled: true,
|
||||
computeThrottleMaxQueueSize: 1, // compute after every message
|
||||
movingAverageIntervals: [10]
|
||||
const config = {
|
||||
...baseOptions,
|
||||
connectionManager: {
|
||||
movingAverageIntervals: [10]
|
||||
},
|
||||
metrics: {
|
||||
enabled: true,
|
||||
computeThrottleMaxQueueSize: 1, // compute after every message
|
||||
movingAverageIntervals: [10]
|
||||
}
|
||||
}
|
||||
let remoteLibp2p
|
||||
;[libp2p, remoteLibp2p] = await createPeer({ number: 2, config })
|
||||
|
Reference in New Issue
Block a user