@libp2p/interop 12.0.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"content-fetching.d.ts","sourceRoot":"","sources":["../../../src/dht/content-fetching.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;AAUhF,wBAAgB,oBAAoB,CAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAYlE"}
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 = {
@@ -19,29 +20,50 @@ export function contentFetchingTests(factory) {
19
20
  }
20
21
  function runContentFetchingTests(factory, optionsA, optionsB) {
21
22
  describe('dht.contentFetching', () => {
22
- let daemonA;
23
- let daemonB;
23
+ let nodes;
24
24
  // Start Daemons
25
25
  before(async function () {
26
26
  this.timeout(20 * 1000);
27
- daemonA = await factory.spawn(optionsA);
28
- daemonB = await factory.spawn(optionsB);
29
- // connect them
30
- const identify0 = await daemonA.client.identify();
31
- await daemonB.client.connect(identify0.peerId, identify0.addrs);
32
- // jsDaemon1 will take some time to get the peers
33
- await new Promise(resolve => setTimeout(resolve, 1000));
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
+ }
43
+ // wait for identify
44
+ await delay(1000);
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
+ }
34
56
  });
35
57
  // Stop daemons
36
58
  after(async function () {
37
- await Promise.all([daemonA, daemonB]
59
+ await Promise.all(nodes
38
60
  .filter(Boolean)
39
61
  .map(async (d) => { await d.stop(); }));
40
62
  });
41
63
  it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
42
64
  this.timeout(10 * 1000);
43
- await daemonA.client.dht.put(record.key, record.value);
44
- const data = await daemonB.client.dht.get(record.key);
65
+ await nodes[0].client.dht.put(record.key, record.value);
66
+ const data = await nodes[1].client.dht.get(record.key);
45
67
  expect(data).to.equalBytes(record.value);
46
68
  });
47
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,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,E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AAC,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,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interop",
3
- "version": "12.0.0",
3
+ "version": "12.0.2",
4
4
  "description": "Interoperability Tests for libp2p",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/interop#readme",
@@ -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'
@@ -29,29 +30,57 @@ export function contentFetchingTests (factory: DaemonFactory): void {
29
30
 
30
31
  function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
31
32
  describe('dht.contentFetching', () => {
32
- let daemonA: Daemon
33
- let daemonB: Daemon
33
+ let nodes: Daemon[]
34
34
 
35
35
  // Start Daemons
36
36
  before(async function () {
37
37
  this.timeout(20 * 1000)
38
38
 
39
- daemonA = await factory.spawn(optionsA)
40
- daemonB = await factory.spawn(optionsB)
39
+ nodes = await Promise.all([
40
+ factory.spawn(optionsA),
41
+ ...new Array(3).fill(0).map(async () => factory.spawn(optionsB))
42
+ ])
41
43
 
42
- // connect them
43
- const identify0 = await daemonA.client.identify()
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]
57
+
58
+ await a.client.connect(b.peerId, b.addrs)
59
+ }
60
+ }
61
+
62
+ // wait for identify
63
+ await delay(1000)
64
+
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
+ }
44
71
 
45
- await daemonB.client.connect(identify0.peerId, identify0.addrs)
72
+ const a = nodes[i]
73
+ const b = identify[k]
46
74
 
47
- // jsDaemon1 will take some time to get the peers
48
- await new Promise(resolve => setTimeout(resolve, 1000))
75
+ await expect(a.client.dht.findPeer(b.peerId)).to.eventually.be.ok()
76
+ }
77
+ }
49
78
  })
50
79
 
51
80
  // Stop daemons
52
81
  after(async function () {
53
82
  await Promise.all(
54
- [daemonA, daemonB]
83
+ nodes
55
84
  .filter(Boolean)
56
85
  .map(async d => { await d.stop() })
57
86
  )
@@ -60,9 +89,9 @@ function runContentFetchingTests (factory: DaemonFactory, optionsA: SpawnOptions
60
89
  it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
61
90
  this.timeout(10 * 1000)
62
91
 
63
- await daemonA.client.dht.put(record.key, record.value)
92
+ await nodes[0].client.dht.put(record.key, record.value)
64
93
 
65
- const data = await daemonB.client.dht.get(record.key)
94
+ const data = await nodes[1].client.dht.get(record.key)
66
95
  expect(data).to.equalBytes(record.value)
67
96
  })
68
97
  })