@libp2p/interop 12.0.1 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/connect/index.js +17 -4
- package/dist/src/connect/index.js.map +1 -1
- package/dist/src/dht/content-fetching.js +31 -22
- package/dist/src/dht/content-fetching.js.map +1 -1
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +2 -0
- package/package.json +2 -2
- package/src/connect/index.ts +18 -4
- package/src/dht/content-fetching.ts +37 -22
- package/src/index.ts +13 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { expect } from 'aegir/chai';
|
|
2
2
|
export function connectTests(factory) {
|
|
3
3
|
const nodeTypes = ['js', 'go'];
|
|
4
|
-
const transportTypes = ['tcp', 'webtransport'];
|
|
4
|
+
const transportTypes = ['tcp', 'webtransport', 'webrtc-direct'];
|
|
5
5
|
for (const typeA of nodeTypes) {
|
|
6
6
|
for (const typeB of nodeTypes) {
|
|
7
7
|
transportTypes.forEach(transport => {
|
|
8
|
-
runConnectTests(transport, factory, { type: typeA, transport }, { type: typeB, transport });
|
|
8
|
+
runConnectTests(transport, factory, { type: typeA, transport, noListen: true }, { type: typeB, transport });
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -14,11 +14,21 @@ function runConnectTests(name, factory, optionsA, optionsB) {
|
|
|
14
14
|
describe(`connection.${name}`, () => {
|
|
15
15
|
let daemonA;
|
|
16
16
|
let daemonB;
|
|
17
|
+
let skipped;
|
|
17
18
|
// Start Daemons
|
|
18
19
|
before(async function () {
|
|
19
20
|
this.timeout(20 * 1000);
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
try {
|
|
22
|
+
daemonA = await factory.spawn(optionsA);
|
|
23
|
+
daemonB = await factory.spawn(optionsB);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err.name === 'UnsupportedError') {
|
|
27
|
+
skipped = true;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
22
32
|
});
|
|
23
33
|
// Stop daemons
|
|
24
34
|
after(async function () {
|
|
@@ -28,6 +38,9 @@ function runConnectTests(name, factory, optionsA, optionsB) {
|
|
|
28
38
|
});
|
|
29
39
|
it(`${optionsA.type} peer to ${optionsB.type} peer over ${name}`, async function () {
|
|
30
40
|
this.timeout(10 * 1000);
|
|
41
|
+
if (skipped) {
|
|
42
|
+
return this.skip();
|
|
43
|
+
}
|
|
31
44
|
const identify1 = await daemonA.client.identify();
|
|
32
45
|
const identify2 = await daemonB.client.identify();
|
|
33
46
|
// verify connected peers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGnC,MAAM,UAAU,YAAY,CAAE,OAAsB;IAClD,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC1C,MAAM,cAAc,GAAoB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGnC,MAAM,UAAU,YAAY,CAAE,OAAsB;IAClD,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC1C,MAAM,cAAc,GAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,eAAe,CAAC,CAAA;IAEhF,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;YAC9B,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,EAA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CAAC,QAAQ,EAAE,CAAC,CAAA;YAEnF,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;YAChE,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAA;YACpE,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACrF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -20,41 +20,50 @@ export function contentFetchingTests(factory) {
|
|
|
20
20
|
}
|
|
21
21
|
function runContentFetchingTests(factory, optionsA, optionsB) {
|
|
22
22
|
describe('dht.contentFetching', () => {
|
|
23
|
-
let
|
|
24
|
-
let daemonB;
|
|
25
|
-
let daemonC;
|
|
26
|
-
let daemonD;
|
|
23
|
+
let nodes;
|
|
27
24
|
// Start Daemons
|
|
28
25
|
before(async function () {
|
|
29
26
|
this.timeout(20 * 1000);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
nodes = await Promise.all([
|
|
28
|
+
factory.spawn(optionsA),
|
|
29
|
+
...new Array(3).fill(0).map(async () => factory.spawn(optionsB))
|
|
30
|
+
]);
|
|
31
|
+
const identify = await Promise.all(nodes.map(async (node) => node.client.identify()));
|
|
32
|
+
// connect them all
|
|
33
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
34
|
+
for (let k = 0; k < nodes.length; k++) {
|
|
35
|
+
if (i === k) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const a = nodes[i];
|
|
39
|
+
const b = identify[k];
|
|
40
|
+
await a.client.connect(b.peerId, b.addrs);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
42
43
|
// wait for identify
|
|
43
44
|
await delay(1000);
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// ensure they can all find each other
|
|
46
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
47
|
+
for (let k = 0; k < nodes.length; k++) {
|
|
48
|
+
if (i === k) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const a = nodes[i];
|
|
52
|
+
const b = identify[k];
|
|
53
|
+
await expect(a.client.dht.findPeer(b.peerId)).to.eventually.be.ok();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
47
56
|
});
|
|
48
57
|
// Stop daemons
|
|
49
58
|
after(async function () {
|
|
50
|
-
await Promise.all(
|
|
59
|
+
await Promise.all(nodes
|
|
51
60
|
.filter(Boolean)
|
|
52
61
|
.map(async (d) => { await d.stop(); }));
|
|
53
62
|
});
|
|
54
63
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
55
64
|
this.timeout(10 * 1000);
|
|
56
|
-
await
|
|
57
|
-
const data = await
|
|
65
|
+
await nodes[0].client.dht.put(record.key, record.value);
|
|
66
|
+
const data = await nodes[1].client.dht.get(record.key);
|
|
58
67
|
expect(data).to.equalBytes(record.value);
|
|
59
68
|
});
|
|
60
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fetching.js","sourceRoot":"","sources":["../../../src/dht/content-fetching.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAG5E,MAAM,MAAM,GAAG;IACb,GAA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AAC,CAAC,CAAC,CACtC,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,YAAY,QAAQ,CAAC,IAAI,OAAO,EAAE,KAAK;YACxD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;YAEvB,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;YAEvD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACtD,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type PeerIdType = 'rsa' | 'ed25519' | 'secp256k1';
|
|
|
56
56
|
export type PubSubRouter = 'gossipsub' | 'floodsub';
|
|
57
57
|
export type Muxer = 'mplex' | 'yamux';
|
|
58
58
|
export type Encryption = 'noise' | 'tls';
|
|
59
|
-
export type TransportType = 'tcp' | 'webtransport';
|
|
59
|
+
export type TransportType = 'tcp' | 'webtransport' | 'webrtc-direct';
|
|
60
60
|
export interface SpawnOptions {
|
|
61
61
|
type: NodeType;
|
|
62
62
|
key?: string;
|
|
@@ -74,4 +74,11 @@ export interface DaemonFactory {
|
|
|
74
74
|
}
|
|
75
75
|
export declare function interopTests(factory: DaemonFactory): Promise<void>;
|
|
76
76
|
export { connectTests as connectInteropTests, dhtTests as dhtInteropTests, pubsubTests as pubsubInteropTests, streamTests as streamInteropTests, relayTests as relayInteropTests };
|
|
77
|
+
/**
|
|
78
|
+
* Some tests allow skipping certain configurations. When this is necessary,
|
|
79
|
+
* `DaemonFactory.spawn` should thow an instance of this error.
|
|
80
|
+
*/
|
|
81
|
+
export declare class UnsupportedError extends Error {
|
|
82
|
+
constructor(message?: string);
|
|
83
|
+
}
|
|
77
84
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEzD,MAAM,WAAW,MAAM;IACrB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,MAAM,EAAE,YAAY,CAAA;CACrB;AAED,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAA;AAClC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,CAAA;AACxD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAA;AACnD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;AACrC,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,KAAK,CAAA;AACxC,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC9C;AAED,wBAAsB,YAAY,CAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzE;AAED,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,QAAQ,IAAI,eAAe,EAC3B,WAAW,IAAI,kBAAkB,EACjC,WAAW,IAAI,kBAAkB,EACjC,UAAU,IAAI,iBAAiB,EAChC,CAAA;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC5B,OAAO,SAAmC;CAKxD"}
|
package/dist/src/index.js
CHANGED
|
@@ -54,4 +54,14 @@ export async function interopTests(factory) {
|
|
|
54
54
|
await streamTests(factory);
|
|
55
55
|
}
|
|
56
56
|
export { connectTests as connectInteropTests, dhtTests as dhtInteropTests, pubsubTests as pubsubInteropTests, streamTests as streamInteropTests, relayTests as relayInteropTests };
|
|
57
|
+
/**
|
|
58
|
+
* Some tests allow skipping certain configurations. When this is necessary,
|
|
59
|
+
* `DaemonFactory.spawn` should thow an instance of this error.
|
|
60
|
+
*/
|
|
61
|
+
export class UnsupportedError extends Error {
|
|
62
|
+
constructor(message = 'Unsupported test configuration') {
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = 'UnsupportedError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
57
67
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CA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AAI,kBAAkB,EACjC,UAAU,IAAI,iBAAiB,EAChC,CAAA;AAED;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAa,OAAO,GAAG,gCAAgC;QACrD,KAAK,CAAC,OAAO,CAAC,CAAA;QAEd,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC;CACF"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"UnsupportedError": "https://libp2p.github.io/interop/classes/UnsupportedError.html",
|
|
3
|
+
".:UnsupportedError": "https://libp2p.github.io/interop/classes/UnsupportedError.html",
|
|
2
4
|
"Daemon": "https://libp2p.github.io/interop/interfaces/Daemon.html",
|
|
3
5
|
".:Daemon": "https://libp2p.github.io/interop/interfaces/Daemon.html",
|
|
4
6
|
"DaemonFactory": "https://libp2p.github.io/interop/interfaces/DaemonFactory.html",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interop",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Interoperability Tests for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/interop#readme",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"uint8arrays": "^5.0.0"
|
|
155
155
|
},
|
|
156
156
|
"devDependencies": {
|
|
157
|
-
"aegir": "^
|
|
157
|
+
"aegir": "^43.0.1",
|
|
158
158
|
"protons": "^7.0.2"
|
|
159
159
|
},
|
|
160
160
|
"peerDependencies": {
|
package/src/connect/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Daemon, DaemonFactory, NodeType, SpawnOptions, TransportType } fro
|
|
|
3
3
|
|
|
4
4
|
export function connectTests (factory: DaemonFactory): void {
|
|
5
5
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
6
|
-
const transportTypes: TransportType[] = ['tcp', 'webtransport']
|
|
6
|
+
const transportTypes: TransportType[] = ['tcp', 'webtransport', 'webrtc-direct']
|
|
7
7
|
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
9
9
|
for (const typeB of nodeTypes) {
|
|
@@ -11,7 +11,7 @@ export function connectTests (factory: DaemonFactory): void {
|
|
|
11
11
|
runConnectTests(
|
|
12
12
|
transport,
|
|
13
13
|
factory,
|
|
14
|
-
{ type: typeA, transport },
|
|
14
|
+
{ type: typeA, transport, noListen: true },
|
|
15
15
|
{ type: typeB, transport }
|
|
16
16
|
)
|
|
17
17
|
})
|
|
@@ -23,13 +23,23 @@ function runConnectTests (name: string, factory: DaemonFactory, optionsA: SpawnO
|
|
|
23
23
|
describe(`connection.${name}`, () => {
|
|
24
24
|
let daemonA: Daemon
|
|
25
25
|
let daemonB: Daemon
|
|
26
|
+
let skipped: boolean
|
|
26
27
|
|
|
27
28
|
// Start Daemons
|
|
28
29
|
before(async function () {
|
|
29
30
|
this.timeout(20 * 1000)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
try {
|
|
33
|
+
daemonA = await factory.spawn(optionsA)
|
|
34
|
+
daemonB = await factory.spawn(optionsB)
|
|
35
|
+
} catch (err: any) {
|
|
36
|
+
if (err.name === 'UnsupportedError') {
|
|
37
|
+
skipped = true
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw err
|
|
42
|
+
}
|
|
33
43
|
})
|
|
34
44
|
|
|
35
45
|
// Stop daemons
|
|
@@ -44,6 +54,10 @@ function runConnectTests (name: string, factory: DaemonFactory, optionsA: SpawnO
|
|
|
44
54
|
it(`${optionsA.type} peer to ${optionsB.type} peer over ${name}`, async function () {
|
|
45
55
|
this.timeout(10 * 1000)
|
|
46
56
|
|
|
57
|
+
if (skipped) {
|
|
58
|
+
return this.skip()
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
const identify1 = await daemonA.client.identify()
|
|
48
62
|
const identify2 = await daemonB.client.identify()
|
|
49
63
|
|
|
@@ -30,42 +30,57 @@ export function contentFetchingTests (factory: DaemonFactory): void {
|
|
|
30
30
|
|
|
31
31
|
function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
|
|
32
32
|
describe('dht.contentFetching', () => {
|
|
33
|
-
let
|
|
34
|
-
let daemonB: Daemon
|
|
35
|
-
let daemonC: Daemon
|
|
36
|
-
let daemonD: Daemon
|
|
33
|
+
let nodes: Daemon[]
|
|
37
34
|
|
|
38
35
|
// Start Daemons
|
|
39
36
|
before(async function () {
|
|
40
37
|
this.timeout(20 * 1000)
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
nodes = await Promise.all([
|
|
40
|
+
factory.spawn(optionsA),
|
|
41
|
+
...new Array(3).fill(0).map(async () => factory.spawn(optionsB))
|
|
42
|
+
])
|
|
46
43
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const identify = await Promise.all(
|
|
45
|
+
nodes.map(async node => node.client.identify())
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
// connect them all
|
|
49
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
50
|
+
for (let k = 0; k < nodes.length; k++) {
|
|
51
|
+
if (i === k) {
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const a = nodes[i]
|
|
56
|
+
const b = identify[k]
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await daemonC.client.connect(identifyD.peerId, identifyD.addrs)
|
|
58
|
+
await a.client.connect(b.peerId, b.addrs)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
56
61
|
|
|
57
62
|
// wait for identify
|
|
58
63
|
await delay(1000)
|
|
59
64
|
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
// ensure they can all find each other
|
|
66
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
67
|
+
for (let k = 0; k < nodes.length; k++) {
|
|
68
|
+
if (i === k) {
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const a = nodes[i]
|
|
73
|
+
const b = identify[k]
|
|
74
|
+
|
|
75
|
+
await expect(a.client.dht.findPeer(b.peerId)).to.eventually.be.ok()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
})
|
|
64
79
|
|
|
65
80
|
// Stop daemons
|
|
66
81
|
after(async function () {
|
|
67
82
|
await Promise.all(
|
|
68
|
-
|
|
83
|
+
nodes
|
|
69
84
|
.filter(Boolean)
|
|
70
85
|
.map(async d => { await d.stop() })
|
|
71
86
|
)
|
|
@@ -74,9 +89,9 @@ function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions
|
|
|
74
89
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
75
90
|
this.timeout(10 * 1000)
|
|
76
91
|
|
|
77
|
-
await
|
|
92
|
+
await nodes[0].client.dht.put(record.key, record.value)
|
|
78
93
|
|
|
79
|
-
const data = await
|
|
94
|
+
const data = await nodes[1].client.dht.get(record.key)
|
|
80
95
|
expect(data).to.equalBytes(record.value)
|
|
81
96
|
})
|
|
82
97
|
})
|
package/src/index.ts
CHANGED
|
@@ -59,7 +59,7 @@ export type PeerIdType = 'rsa' | 'ed25519' | 'secp256k1'
|
|
|
59
59
|
export type PubSubRouter = 'gossipsub' | 'floodsub'
|
|
60
60
|
export type Muxer = 'mplex' | 'yamux'
|
|
61
61
|
export type Encryption = 'noise' | 'tls'
|
|
62
|
-
export type TransportType = 'tcp' | 'webtransport'
|
|
62
|
+
export type TransportType = 'tcp' | 'webtransport' | 'webrtc-direct'
|
|
63
63
|
|
|
64
64
|
export interface SpawnOptions {
|
|
65
65
|
type: NodeType
|
|
@@ -95,3 +95,15 @@ export {
|
|
|
95
95
|
streamTests as streamInteropTests,
|
|
96
96
|
relayTests as relayInteropTests
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Some tests allow skipping certain configurations. When this is necessary,
|
|
101
|
+
* `DaemonFactory.spawn` should thow an instance of this error.
|
|
102
|
+
*/
|
|
103
|
+
export class UnsupportedError extends Error {
|
|
104
|
+
constructor (message = 'Unsupported test configuration') {
|
|
105
|
+
super(message)
|
|
106
|
+
|
|
107
|
+
this.name = 'UnsupportedError'
|
|
108
|
+
}
|
|
109
|
+
}
|