@libp2p/interop 12.0.1 → 12.0.2
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.
|
@@ -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,GAAG,EAAE,gBAAgB,CAAC;QACpB,oBAAoB,CAAC,MAAM,CAAC;QAC5B,oBAAoB,CAAC,sDAAsD,EAAE,QAAQ,CAAC;KACvF,CAAC;IACF,KAAK,EAAE,oBAAoB,CAAC,wlBAAwlB,EAAE,KAAK,CAAC;CAC7nB,CAAA;AAED,MAAM,UAAU,oBAAoB,CAAE,OAAsB;IAC1D,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE1C,KAAK,MAAM,KAAK,I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K,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/package.json
CHANGED
|
@@ -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
|
})
|