Skip to content

Commit f86432a

Browse files
committed
test: refactor tests + updated config (libp2p#1573)
1 parent df1ba0e commit f86432a

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

packages/libp2p/src/connection-manager/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const validateConnectionManagerConfig = (opts: ConnectionManagerInit): Ob
9292
inboundUpgradeTimeout: number().integer().default(INBOUND_UPGRADE_TIMEOUT),
9393
allow: array().of(string()).test('is multiaddr', validateMultiaddr).optional(),
9494
deny: array().of(string()).test('is multiaddr', validateMultiaddr).optional(),
95-
inboundConnectionThreshold: number().max(opts?.maxConnections ?? MAX_CONNECTIONS, `inboundConnectionThreshold must be less than the max connections limit: ${opts?.maxConnections}`).integer().default(INBOUND_CONNECTION_THRESHOLD),
96-
maxIncomingPendingConnections: number().integer().max(opts?.maxConnections ?? MAX_CONNECTIONS, `maxIncomingPendingConnections must be less than the max connections limit: ${opts?.maxConnections}`).default(MAX_INCOMING_PENDING_CONNECTIONS)
95+
inboundConnectionThreshold: number().max(opts?.maxConnections ?? MAX_CONNECTIONS, `inboundConnectionThreshold must be less than the max connections limit: ${opts?.inboundConnectionThreshold}`).integer().default(INBOUND_CONNECTION_THRESHOLD),
96+
maxIncomingPendingConnections: number().integer().max(opts?.maxConnections ?? MAX_CONNECTIONS, `maxIncomingPendingConnections must be less than the max connections limit: ${opts?.maxIncomingPendingConnections}`).default(MAX_INCOMING_PENDING_CONNECTIONS)
9797
})
9898
}

packages/libp2p/src/fetch/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class DefaultFetchService implements Startable, FetchService {
101101
constructor (components: FetchServiceComponents, init: FetchServiceInit) {
102102
this.started = false
103103
this.components = components
104-
this.protocol = `/${init.protocolPrefix ?? 'libp2p'}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
104+
this.protocol = `/${init.protocolPrefix}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
105105
this.lookupFunctions = new Map() // Maps key prefix to value lookup function
106106
this.handleMessage = this.handleMessage.bind(this)
107107
this.init = init
@@ -311,7 +311,7 @@ class DefaultFetchService implements Startable, FetchService {
311311

312312
export function fetchService (init: FetchServiceInit = {}): (components: FetchServiceComponents) => FetchService {
313313
const validatedConfig = object({
314-
protocolPrefix: string().default('ipfs'),
314+
protocolPrefix: string().default('libp2p'),
315315
timeout: number().integer().default(TIMEOUT),
316316
maxInboundStreams: number().integer().min(0).default(MAX_INBOUND_STREAMS),
317317
maxOutboundStreams: number().integer().min(0).default(MAX_OUTBOUND_STREAMS)

packages/libp2p/test/configuration/protocol-prefix.node.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ describe('Protocol prefix is configurable', () => {
6767
'/ipfs/id/1.0.0',
6868
'/ipfs/id/push/1.0.0',
6969
'/ipfs/ping/1.0.0',
70-
'/libp2p/fetch/0.0.1'
70+
'/libp2p/fetch/0.0.1',
71+
'/libp2p/circuit/relay/0.2.0/stop'
7172
])
7273
})
7374
})

packages/libp2p/test/connection-manager/index.node.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ describe('libp2p.connections', () => {
236236
},
237237
connectionManager: {
238238
minConnections,
239-
maxConnections: 1
239+
maxConnections: 1,
240+
inboundConnectionThreshold: 1,
241+
maxIncomingPendingConnections: 1
240242
}
241243
}
242244
})

packages/libp2p/test/ping/ping.node.ts

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pingService, type PingService } from '../../src/ping/index.js'
99
import { createBaseOptions } from '../fixtures/base-options.js'
1010
import { createNode, populateAddressBooks } from '../fixtures/creators/peer.js'
1111
import type { Libp2p } from '@libp2p/interface'
12+
import { identifyService } from '../../src/identify/index.js'
1213

1314
describe('ping', () => {
1415
let nodes: Array<Libp2p<{ ping: PingService }>>
@@ -18,20 +19,23 @@ describe('ping', () => {
1819
createNode({
1920
config: createBaseOptions({
2021
services: {
22+
identify: identifyService(),
2123
ping: pingService()
2224
}
2325
})
2426
}),
2527
createNode({
2628
config: createBaseOptions({
2729
services: {
30+
identify: identifyService(),
2831
ping: pingService()
2932
}
3033
})
3134
}),
3235
createNode({
3336
config: createBaseOptions({
3437
services: {
38+
identify: identifyService(),
3539
ping: pingService()
3640
}
3741
})
@@ -104,6 +108,7 @@ describe('ping', () => {
104108
const client = await createNode({
105109
config: createBaseOptions({
106110
services: {
111+
identify: identifyService(),
107112
ping: pingService({
108113
// Allow two outbound ping streams.
109114
// It is not allowed by the spec, but this test needs to open two concurrent streams.

packages/transport-webrtc/.aegir.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/** @type {import('aegir').PartialOptions} */
32
export default {
43
build: {
@@ -35,7 +34,7 @@ export default {
3534
services: {
3635
relay: circuitRelayServer({
3736
reservations: {
38-
maxReservations: Infinity
37+
maxReservations: 10000
3938
}
4039
}),
4140
identify: identifyService()

0 commit comments

Comments
 (0)