Skip to content

Commit 1b29ee0

Browse files
committed
feat!: test tls encryption
Adds tests for tls encryption but as a major to control when it is pulled in to the js-libp2p monorepo. BREAKING CHANGE: tls support is required
1 parent ba8a627 commit 1b29ee0

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/connect.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import { expect } from 'aegir/chai'
22
import { keys } from './resources/keys/index.js'
3-
import type { Daemon, NodeType, SpawnOptions, DaemonFactory, PeerIdType } from './index.js'
3+
import type { Daemon, NodeType, SpawnOptions, DaemonFactory, PeerIdType, Encryption } from './index.js'
44

55
export function connectTests (factory: DaemonFactory): void {
66
const keyTypes: PeerIdType[] = ['ed25519', 'rsa', 'secp256k1']
77
const impls: NodeType[] = ['js', 'go']
8+
const encrypters: Encryption[] = ['noise', 'tls']
89

910
for (const keyType of keyTypes) {
1011
for (const implA of impls) {
1112
for (const implB of impls) {
12-
runConnectTests(
13-
`noise/${keyType}`,
14-
factory,
15-
{ type: implA, noise: true, key: keys.go[keyType] },
16-
{ type: implB, noise: true, key: keys.js[keyType] }
17-
)
13+
for (const encrypter of encrypters) {
14+
runConnectTests(
15+
`${encrypter}/${keyType}`,
16+
factory,
17+
{ type: implA, encryption: encrypter, key: keys.go[keyType] },
18+
{ type: implB, encryption: encrypter, key: keys.js[keyType] }
19+
)
20+
}
1821
}
1922
}
2023
}

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ export type NodeType = 'js' | 'go'
5858
export type PeerIdType = 'rsa' | 'ed25519' | 'secp256k1'
5959
export type PubSubRouter = 'gossipsub' | 'floodsub'
6060
export type Muxer = 'mplex' | 'yamux'
61+
export type Encryption = 'noise' | 'tls'
6162

6263
export interface SpawnOptions {
6364
type: NodeType
6465
key?: string
65-
noise?: true
66+
encryption?: Encryption
6667
dht?: boolean
6768
pubsub?: boolean
6869
pubsubRouter?: PubSubRouter

src/relay/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export function relayTests (factory: DaemonFactory): void {
1515
function relayTest (factory: DaemonFactory, aType: NodeType, bType: NodeType, relayType: NodeType): void {
1616
describe(`${aType} to ${bType} over relay ${relayType}`, () => {
1717
const opts: SpawnOptions[] = [
18-
{ type: aType, noise: true, noListen: true },
19-
{ type: bType, noise: true, noListen: true },
20-
{ type: relayType, noise: true, relay: true }
18+
{ type: aType, encryption: 'noise', noListen: true },
19+
{ type: bType, encryption: 'noise', noListen: true },
20+
{ type: relayType, encryption: 'noise', relay: true }
2121
]
2222

2323
let aNode: Daemon

0 commit comments

Comments
 (0)