@libp2p/interop 12.0.0 → 12.0.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fetching.d.ts","sourceRoot":"","sources":["../../../src/dht/content-fetching.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-fetching.d.ts","sourceRoot":"","sources":["../../../src/dht/content-fetching.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;AAUhF,wBAAgB,oBAAoB,CAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAYlE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-env mocha */
|
|
2
2
|
import { expect } from 'aegir/chai';
|
|
3
|
+
import delay from 'delay';
|
|
3
4
|
import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
|
|
4
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
5
6
|
const record = {
|
|
@@ -21,27 +22,39 @@ function runContentFetchingTests(factory, optionsA, optionsB) {
|
|
|
21
22
|
describe('dht.contentFetching', () => {
|
|
22
23
|
let daemonA;
|
|
23
24
|
let daemonB;
|
|
25
|
+
let daemonC;
|
|
26
|
+
let daemonD;
|
|
24
27
|
// Start Daemons
|
|
25
28
|
before(async function () {
|
|
26
29
|
this.timeout(20 * 1000);
|
|
27
30
|
daemonA = await factory.spawn(optionsA);
|
|
28
|
-
daemonB = await factory.spawn(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
daemonB = await factory.spawn(optionsA);
|
|
32
|
+
daemonC = await factory.spawn(optionsB);
|
|
33
|
+
daemonD = await factory.spawn(optionsB);
|
|
34
|
+
const identifyA = await daemonA.client.identify();
|
|
35
|
+
const identifyB = await daemonB.client.identify();
|
|
36
|
+
const identifyC = await daemonC.client.identify();
|
|
37
|
+
const identifyD = await daemonD.client.identify();
|
|
38
|
+
// connect them A -> B -> C -> D
|
|
39
|
+
await daemonA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
40
|
+
await daemonB.client.connect(identifyC.peerId, identifyC.addrs);
|
|
41
|
+
await daemonC.client.connect(identifyD.peerId, identifyD.addrs);
|
|
42
|
+
// wait for identify
|
|
43
|
+
await delay(1000);
|
|
44
|
+
// B can find D and C can find A, so their routing tables are not empty
|
|
45
|
+
await expect(daemonB.client.dht.findPeer(identifyD.peerId)).to.eventually.be.ok();
|
|
46
|
+
await expect(daemonC.client.dht.findPeer(identifyA.peerId)).to.eventually.be.ok();
|
|
34
47
|
});
|
|
35
48
|
// Stop daemons
|
|
36
49
|
after(async function () {
|
|
37
|
-
await Promise.all([daemonA, daemonB]
|
|
50
|
+
await Promise.all([daemonA, daemonB, daemonC, daemonD]
|
|
38
51
|
.filter(Boolean)
|
|
39
52
|
.map(async (d) => { await d.stop(); }));
|
|
40
53
|
});
|
|
41
54
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
42
55
|
this.timeout(10 * 1000);
|
|
43
|
-
await
|
|
44
|
-
const data = await
|
|
56
|
+
await daemonB.client.dht.put(record.key, record.value);
|
|
57
|
+
const data = await daemonC.client.dht.get(record.key);
|
|
45
58
|
expect(data).to.equalBytes(record.value);
|
|
46
59
|
});
|
|
47
60
|
});
|
|
@@ -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,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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AAE,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA,CAAC,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,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;YAEtD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACrD,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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-env mocha */
|
|
2
2
|
|
|
3
3
|
import { expect } from 'aegir/chai'
|
|
4
|
+
import delay from 'delay'
|
|
4
5
|
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
5
6
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
7
|
import type { Daemon, DaemonFactory, NodeType, SpawnOptions } from '../index.js'
|
|
@@ -31,27 +32,40 @@ function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions
|
|
|
31
32
|
describe('dht.contentFetching', () => {
|
|
32
33
|
let daemonA: Daemon
|
|
33
34
|
let daemonB: Daemon
|
|
35
|
+
let daemonC: Daemon
|
|
36
|
+
let daemonD: Daemon
|
|
34
37
|
|
|
35
38
|
// Start Daemons
|
|
36
39
|
before(async function () {
|
|
37
40
|
this.timeout(20 * 1000)
|
|
38
41
|
|
|
39
42
|
daemonA = await factory.spawn(optionsA)
|
|
40
|
-
daemonB = await factory.spawn(
|
|
43
|
+
daemonB = await factory.spawn(optionsA)
|
|
44
|
+
daemonC = await factory.spawn(optionsB)
|
|
45
|
+
daemonD = await factory.spawn(optionsB)
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
const
|
|
47
|
+
const identifyA = await daemonA.client.identify()
|
|
48
|
+
const identifyB = await daemonB.client.identify()
|
|
49
|
+
const identifyC = await daemonC.client.identify()
|
|
50
|
+
const identifyD = await daemonD.client.identify()
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
// connect them A -> B -> C -> D
|
|
53
|
+
await daemonA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
54
|
+
await daemonB.client.connect(identifyC.peerId, identifyC.addrs)
|
|
55
|
+
await daemonC.client.connect(identifyD.peerId, identifyD.addrs)
|
|
46
56
|
|
|
47
|
-
//
|
|
48
|
-
await
|
|
57
|
+
// wait for identify
|
|
58
|
+
await delay(1000)
|
|
59
|
+
|
|
60
|
+
// B can find D and C can find A, so their routing tables are not empty
|
|
61
|
+
await expect(daemonB.client.dht.findPeer(identifyD.peerId)).to.eventually.be.ok()
|
|
62
|
+
await expect(daemonC.client.dht.findPeer(identifyA.peerId)).to.eventually.be.ok()
|
|
49
63
|
})
|
|
50
64
|
|
|
51
65
|
// Stop daemons
|
|
52
66
|
after(async function () {
|
|
53
67
|
await Promise.all(
|
|
54
|
-
[daemonA, daemonB]
|
|
68
|
+
[daemonA, daemonB, daemonC, daemonD]
|
|
55
69
|
.filter(Boolean)
|
|
56
70
|
.map(async d => { await d.stop() })
|
|
57
71
|
)
|
|
@@ -60,9 +74,9 @@ function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions
|
|
|
60
74
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
61
75
|
this.timeout(10 * 1000)
|
|
62
76
|
|
|
63
|
-
await
|
|
77
|
+
await daemonB.client.dht.put(record.key, record.value)
|
|
64
78
|
|
|
65
|
-
const data = await
|
|
79
|
+
const data = await daemonC.client.dht.get(record.key)
|
|
66
80
|
expect(data).to.equalBytes(record.value)
|
|
67
81
|
})
|
|
68
82
|
})
|