Skip to content

Commit 48bbf8b

Browse files
authored
feat!: test different transports (#149)
Split `connect` tests into TCP and WebTransport
1 parent efb27b6 commit 48bbf8b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/connect.ts src/connect/index.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import { expect } from 'aegir/chai'
2-
import { runTests } from './utils/test-matrix.js'
3-
import type { Daemon, SpawnOptions, DaemonFactory } from './index.js'
2+
import type { Daemon, DaemonFactory, NodeType, SpawnOptions, TransportType } from '../index.js'
43

54
export function connectTests (factory: DaemonFactory): void {
6-
runTests('connect', runConnectTests, factory)
5+
const nodeTypes: NodeType[] = ['js', 'go']
6+
const transportTypes: TransportType[] = ['tcp', 'webtransport']
7+
8+
for (const typeA of nodeTypes) {
9+
for (const typeB of nodeTypes) {
10+
transportTypes.forEach(transport => {
11+
runConnectTests(
12+
transport,
13+
factory,
14+
{ type: typeA, transport },
15+
{ type: typeB, transport }
16+
)
17+
})
18+
}
19+
}
720
}
821

922
function runConnectTests (name: string, factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
10-
describe(name, () => {
23+
describe(`connection.${name}`, () => {
1124
let daemonA: Daemon
1225
let daemonB: Daemon
1326

@@ -28,7 +41,7 @@ function runConnectTests (name: string, factory: DaemonFactory, optionsA: SpawnO
2841
)
2942
})
3043

31-
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
44+
it(`${optionsA.type} peer to ${optionsB.type} peer over ${name}`, async function () {
3245
this.timeout(10 * 1000)
3346

3447
const identify1 = await daemonA.client.identify()

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* For an example, see the js-libp2p interop test runner.
4343
*/
4444

45-
import { connectTests } from './connect.js'
45+
import { connectTests } from './connect/index.js'
4646
import { dhtTests } from './dht/index.js'
4747
import { pubsubTests } from './pubsub/index.js'
4848
import { relayTests } from './relay/index.js'
@@ -59,6 +59,7 @@ export type PeerIdType = 'rsa' | 'ed25519' | 'secp256k1'
5959
export type PubSubRouter = 'gossipsub' | 'floodsub'
6060
export type Muxer = 'mplex' | 'yamux'
6161
export type Encryption = 'noise' | 'tls'
62+
export type TransportType = 'tcp' | 'webtransport'
6263

6364
export interface SpawnOptions {
6465
type: NodeType
@@ -72,6 +73,7 @@ export interface SpawnOptions {
7273
// the node will not listen on any
7374
// addresses if true
7475
noListen?: boolean
76+
transport?: TransportType
7577
}
7678

7779
export interface DaemonFactory {

0 commit comments

Comments
 (0)