@libp2p/interop 6.0.2 → 7.0.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/index.min.js +5 -5
- package/dist/src/pubsub/floodsub.d.ts.map +1 -1
- package/dist/src/pubsub/floodsub.js +5 -10
- package/dist/src/pubsub/floodsub.js.map +1 -1
- package/dist/src/pubsub/gossipsub.d.ts.map +1 -1
- package/dist/src/pubsub/gossipsub.js +9 -12
- package/dist/src/pubsub/gossipsub.js.map +1 -1
- package/dist/src/pubsub/hybrid.d.ts.map +1 -1
- package/dist/src/pubsub/hybrid.js +9 -12
- package/dist/src/pubsub/hybrid.js.map +1 -1
- package/dist/src/pubsub/utils.d.ts +3 -0
- package/dist/src/pubsub/utils.d.ts.map +1 -0
- package/dist/src/pubsub/utils.js +23 -0
- package/dist/src/pubsub/utils.js.map +1 -0
- package/package.json +3 -3
- package/src/pubsub/floodsub.ts +5 -12
- package/src/pubsub/gossipsub.ts +9 -14
- package/src/pubsub/hybrid.ts +9 -13
- package/src/pubsub/utils.ts +26 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floodsub.d.ts","sourceRoot":"","sources":["../../../src/pubsub/floodsub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"floodsub.d.ts","sourceRoot":"","sources":["../../../src/pubsub/floodsub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;AAKhF,wBAAgB,aAAa,CAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAY3D"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { expect } from 'aegir/chai';
|
|
3
3
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
4
4
|
import first from 'it-first';
|
|
5
|
-
import
|
|
5
|
+
import { waitForBothSubscribed } from './utils.js';
|
|
6
6
|
export function floodsubTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -14,7 +14,6 @@ export function floodsubTests(factory) {
|
|
|
14
14
|
function runFloodsubTests(factory, optionsA, optionsB) {
|
|
15
15
|
describe('pubsub.floodSub', () => {
|
|
16
16
|
let daemons;
|
|
17
|
-
let identifyB;
|
|
18
17
|
// Start Daemons
|
|
19
18
|
before(async function () {
|
|
20
19
|
this.timeout(20 * 1000);
|
|
@@ -23,7 +22,7 @@ function runFloodsubTests(factory, optionsA, optionsB) {
|
|
|
23
22
|
factory.spawn(optionsB)
|
|
24
23
|
]);
|
|
25
24
|
const [peerA, peerB] = daemons;
|
|
26
|
-
identifyB = await peerB.client.identify();
|
|
25
|
+
const identifyB = await peerB.client.identify();
|
|
27
26
|
await peerA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
28
27
|
});
|
|
29
28
|
// Stop daemons
|
|
@@ -36,18 +35,14 @@ function runFloodsubTests(factory, optionsA, optionsB) {
|
|
|
36
35
|
const topic = 'test-topic';
|
|
37
36
|
const data = uint8ArrayFromString('test-data');
|
|
38
37
|
const [peerA, peerB] = daemons;
|
|
39
|
-
const
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
40
39
|
const subscriber = async () => {
|
|
41
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
42
41
|
expect(message).to.exist();
|
|
43
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
44
43
|
};
|
|
45
44
|
const publisher = async () => {
|
|
46
|
-
|
|
47
|
-
await pWaitFor(async () => {
|
|
48
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic);
|
|
49
|
-
return peers.map(p => p.toString()).includes(identifyB.peerId.toString());
|
|
50
|
-
});
|
|
45
|
+
await waitForBothSubscribed(topic, peerA, peerB);
|
|
51
46
|
await peerA.client.pubsub.publish(topic, data);
|
|
52
47
|
};
|
|
53
48
|
return await Promise.all([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floodsub.js","sourceRoot":"","sources":["../../../src/pubsub/floodsub.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"floodsub.js","sourceRoot":"","sources":["../../../src/pubsub/floodsub.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAU,aAAa,CAAE,OAAsB;IACnD,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE1C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;YAC7B,gBAAgB,CACd,OAAO,EACP,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EACvD,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,CACxD,CAAA;SACF;KACF;AACH,CAAC;AAED,SAAS,gBAAgB,CAAE,OAAsB,EAAE,QAAsB,EAAE,QAAsB;IAC/F,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,IAAI,OAAiB,CAAA;QAErB,gBAAgB;QAChB,MAAM,CAAC,KAAK;YACV,IAAI,CAAC,OAAO,CAAC,EAAE,GA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AAA;gBAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAChE,CAAC,CAAA;YAED,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;gBAC1C,MAAM,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;gBAChD,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAChD,CAAC,CAAA;YAED,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC;gBACvB,UAAU,EAAE;gBACZ,SAAS,EAAE;aACZ,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossipsub.d.ts","sourceRoot":"","sources":["../../../src/pubsub/gossipsub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"gossipsub.d.ts","sourceRoot":"","sources":["../../../src/pubsub/gossipsub.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;AAKhF,wBAAgB,cAAc,CAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAY5D"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { expect } from 'aegir/chai';
|
|
3
3
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
4
4
|
import first from 'it-first';
|
|
5
|
-
import
|
|
5
|
+
import { waitForBothSubscribed } from './utils.js';
|
|
6
6
|
export function gossipsubTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -14,7 +14,6 @@ export function gossipsubTests(factory) {
|
|
|
14
14
|
function runGossipsubTests(factory, optionsA, optionsB) {
|
|
15
15
|
describe('pubsub.gossipsub', () => {
|
|
16
16
|
let daemons;
|
|
17
|
-
let identify1;
|
|
18
17
|
// Start Daemons
|
|
19
18
|
before(async function () {
|
|
20
19
|
this.timeout(20 * 1000);
|
|
@@ -22,8 +21,9 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
22
21
|
factory.spawn(optionsA),
|
|
23
22
|
factory.spawn(optionsB)
|
|
24
23
|
]);
|
|
25
|
-
|
|
26
|
-
await
|
|
24
|
+
const [peerA, peerB] = daemons;
|
|
25
|
+
const identifyB = await peerB.client.identify();
|
|
26
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
27
27
|
});
|
|
28
28
|
// Stop daemons
|
|
29
29
|
after(async function () {
|
|
@@ -34,19 +34,16 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
34
34
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
35
35
|
const topic = 'test-topic';
|
|
36
36
|
const data = uint8ArrayFromString('test-data');
|
|
37
|
-
const
|
|
37
|
+
const [peerA, peerB] = daemons;
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
38
39
|
const subscriber = async () => {
|
|
39
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
40
41
|
expect(message).to.exist();
|
|
41
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
42
43
|
};
|
|
43
44
|
const publisher = async () => {
|
|
44
|
-
|
|
45
|
-
await
|
|
46
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic);
|
|
47
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString());
|
|
48
|
-
});
|
|
49
|
-
await daemons[0].client.pubsub.publish(topic, data);
|
|
45
|
+
await waitForBothSubscribed(topic, peerA, peerB);
|
|
46
|
+
await peerA.client.pubsub.publish(topic, data);
|
|
50
47
|
};
|
|
51
48
|
return await Promise.all([
|
|
52
49
|
subscriber(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossipsub.js","sourceRoot":"","sources":["../../../src/pubsub/gossipsub.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"gossipsub.js","sourceRoot":"","sources":["../../../src/pubsub/gossipsub.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAU,cAAc,CAAE,OAAsB;IACpD,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE1C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;YAC7B,iBAAiB,CACf,OAAO,EACP,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,EACxD,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,CACzD,CAAA;SACF;KACF;AACH,CAAC;AAED,SAAS,iBAAiB,CAAE,OAAsB,EAAE,QAAsB,EAAE,QAAsB;IAChG,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,IAAI,OAAiB,CAAA;QAErB,gBAAgB;QAChB,MAAM,CAAC,KAAK;YACV,IAAI,CAAC,OAAO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C,KAAK,EAAE,CAAA;gBAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAChE,CAAC,CAAA;YAED,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;gBAC1C,MAAM,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;gBAChD,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAChD,CAAC,CAAA;YAED,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC;gBACvB,UAAU,EAAE;gBACZ,SAAS,EAAE;aACZ,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybrid.d.ts","sourceRoot":"","sources":["../../../src/pubsub/hybrid.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"hybrid.d.ts","sourceRoot":"","sources":["../../../src/pubsub/hybrid.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,aAAa,EAA0B,MAAM,aAAa,CAAA;AAKhF,wBAAgB,WAAW,CAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAYzD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { expect } from 'aegir/chai';
|
|
3
3
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
4
4
|
import first from 'it-first';
|
|
5
|
-
import
|
|
5
|
+
import { waitForBothSubscribed } from './utils.js';
|
|
6
6
|
export function hybridTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -14,7 +14,6 @@ export function hybridTests(factory) {
|
|
|
14
14
|
function runHybridTests(factory, optionsA, optionsB) {
|
|
15
15
|
describe('pubsub.hybrid', () => {
|
|
16
16
|
let daemons;
|
|
17
|
-
let identify1;
|
|
18
17
|
// Start Daemons
|
|
19
18
|
before(async function () {
|
|
20
19
|
this.timeout(20 * 1000);
|
|
@@ -22,8 +21,9 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
22
21
|
factory.spawn(optionsA),
|
|
23
22
|
factory.spawn(optionsB)
|
|
24
23
|
]);
|
|
25
|
-
|
|
26
|
-
await
|
|
24
|
+
const [peerA, peerB] = daemons;
|
|
25
|
+
const identifyB = await peerB.client.identify();
|
|
26
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
27
27
|
});
|
|
28
28
|
// Stop daemons
|
|
29
29
|
after(async function () {
|
|
@@ -34,19 +34,16 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
34
34
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
35
35
|
const topic = 'test-topic';
|
|
36
36
|
const data = uint8ArrayFromString('test-data');
|
|
37
|
-
const
|
|
37
|
+
const [peerA, peerB] = daemons;
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
38
39
|
const subscriber = async () => {
|
|
39
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
40
41
|
expect(message).to.exist();
|
|
41
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
42
43
|
};
|
|
43
44
|
const publisher = async () => {
|
|
44
|
-
|
|
45
|
-
await
|
|
46
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic);
|
|
47
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString());
|
|
48
|
-
});
|
|
49
|
-
await daemons[0].client.pubsub.publish(topic, data);
|
|
45
|
+
await waitForBothSubscribed(topic, peerA, peerB);
|
|
46
|
+
await peerA.client.pubsub.publish(topic, data);
|
|
50
47
|
};
|
|
51
48
|
return await Promise.all([
|
|
52
49
|
subscriber(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybrid.js","sourceRoot":"","sources":["../../../src/pubsub/hybrid.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"hybrid.js","sourceRoot":"","sources":["../../../src/pubsub/hybrid.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAU,WAAW,CAAE,OAAsB;IACjD,MAAM,SAAS,GAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE1C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;YAC7B,cAAc,CACZ,OAAO,EACP,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,EACvD,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,CACzD,CAAA;SACF;KACF;AACH,CAAC;AAED,SAAS,cAAc,CAAE,OAAsB,EAAE,QAAsB,EAAE,QAAsB;IAC7F,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,IAAI,OAAiB,CAAA;QAErB,gBAAgB;QAChB,MAAM,CAAC,KAAK;YACV,IAAI,CAAC,OAAO,CAAC,EAA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AE,CAAA;gBAC1B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAChE,CAAC,CAAA;YAED,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;gBAC1C,MAAM,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;gBAChD,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAChD,CAAC,CAAA;YAED,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC;gBACvB,UAAU,EAAE;gBACZ,SAAS,EAAE;aACZ,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAEhC,wBAAsB,qBAAqB,CAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB/F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import pWaitFor from 'p-wait-for';
|
|
2
|
+
export async function waitForBothSubscribed(topic, a, b) {
|
|
3
|
+
await a.client.pubsub.subscribe(topic);
|
|
4
|
+
await b.client.pubsub.subscribe(topic);
|
|
5
|
+
const idA = await a.client.identify();
|
|
6
|
+
const idB = await b.client.identify();
|
|
7
|
+
// wait for subscription stream
|
|
8
|
+
await Promise.all([
|
|
9
|
+
await pWaitFor(async () => {
|
|
10
|
+
const peers = await a.client.pubsub.getSubscribers(topic);
|
|
11
|
+
return peers.map(p => p.toString()).includes(idB.peerId.toString());
|
|
12
|
+
}, {
|
|
13
|
+
interval: 500
|
|
14
|
+
}),
|
|
15
|
+
await pWaitFor(async () => {
|
|
16
|
+
const peers = await b.client.pubsub.getSubscribers(topic);
|
|
17
|
+
return peers.map(p => p.toString()).includes(idA.peerId.toString());
|
|
18
|
+
}, {
|
|
19
|
+
interval: 500
|
|
20
|
+
})
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AAGjC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAE,KAAa,EAAE,CAAS,EAAE,CAAS;IAC9E,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAEtC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IACrC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IAErC,+BAA+B;IAC/B,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE;YACxB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;YACzD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACrE,CAAC,EAAE;YACD,QAAQ,EAAE,GAAG;SACd,CAAC;QACF,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE;YACxB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;YACzD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACrE,CAAC,EAAE;YACD,QAAQ,EAAE,GAAG;SACd,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interop",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"release": "aegir release"
|
|
134
134
|
},
|
|
135
135
|
"dependencies": {
|
|
136
|
-
"@libp2p/daemon-client": "^
|
|
136
|
+
"@libp2p/daemon-client": "^5.0.0",
|
|
137
137
|
"@libp2p/interface-peer-id": "^2.0.1",
|
|
138
138
|
"@libp2p/interface-peer-info": "^1.0.7",
|
|
139
139
|
"@multiformats/multiaddr": "^11.4.0",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"it-first": "^2.0.0",
|
|
142
142
|
"it-handshake": "^4.1.2",
|
|
143
143
|
"it-length-prefixed": "^8.0.4",
|
|
144
|
-
"it-pb-stream": "^
|
|
144
|
+
"it-pb-stream": "^3.0.0",
|
|
145
145
|
"it-pipe": "^2.0.4",
|
|
146
146
|
"it-stream-types": "^1.0.5",
|
|
147
147
|
"multiformats": "^11.0.0",
|
package/src/pubsub/floodsub.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { expect } from 'aegir/chai'
|
|
|
4
4
|
import type { Daemon, DaemonFactory, NodeType, SpawnOptions } from '../index.js'
|
|
5
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
6
|
import first from 'it-first'
|
|
7
|
-
import
|
|
8
|
-
import type { IdentifyResult } from '@libp2p/daemon-client'
|
|
7
|
+
import { waitForBothSubscribed } from './utils.js'
|
|
9
8
|
|
|
10
9
|
export function floodsubTests (factory: DaemonFactory): void {
|
|
11
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -24,7 +23,6 @@ export function floodsubTests (factory: DaemonFactory): void {
|
|
|
24
23
|
function runFloodsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
|
|
25
24
|
describe('pubsub.floodSub', () => {
|
|
26
25
|
let daemons: Daemon[]
|
|
27
|
-
let identifyB: IdentifyResult
|
|
28
26
|
|
|
29
27
|
// Start Daemons
|
|
30
28
|
before(async function () {
|
|
@@ -36,7 +34,7 @@ function runFloodsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optio
|
|
|
36
34
|
])
|
|
37
35
|
|
|
38
36
|
const [peerA, peerB] = daemons
|
|
39
|
-
identifyB = await peerB.client.identify()
|
|
37
|
+
const identifyB = await peerB.client.identify()
|
|
40
38
|
await peerA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
41
39
|
})
|
|
42
40
|
|
|
@@ -54,21 +52,16 @@ function runFloodsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optio
|
|
|
54
52
|
const data = uint8ArrayFromString('test-data')
|
|
55
53
|
const [peerA, peerB] = daemons
|
|
56
54
|
|
|
57
|
-
const
|
|
55
|
+
const subscription = await peerB.client.pubsub.subscribe(topic)
|
|
58
56
|
const subscriber = async (): Promise<void> => {
|
|
59
|
-
const message = await first(
|
|
57
|
+
const message = await first(subscription.messages())
|
|
60
58
|
|
|
61
59
|
expect(message).to.exist()
|
|
62
60
|
expect(message).to.have.property('data').that.equalBytes(data)
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
const publisher = async (): Promise<void> => {
|
|
66
|
-
|
|
67
|
-
await pWaitFor(async () => {
|
|
68
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic)
|
|
69
|
-
return peers.map(p => p.toString()).includes(identifyB.peerId.toString())
|
|
70
|
-
})
|
|
71
|
-
|
|
64
|
+
await waitForBothSubscribed(topic, peerA, peerB)
|
|
72
65
|
await peerA.client.pubsub.publish(topic, data)
|
|
73
66
|
}
|
|
74
67
|
|
package/src/pubsub/gossipsub.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { expect } from 'aegir/chai'
|
|
|
4
4
|
import type { Daemon, DaemonFactory, NodeType, SpawnOptions } from '../index.js'
|
|
5
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
6
|
import first from 'it-first'
|
|
7
|
-
import
|
|
8
|
-
import type { IdentifyResult } from '@libp2p/daemon-client'
|
|
7
|
+
import { waitForBothSubscribed } from './utils.js'
|
|
9
8
|
|
|
10
9
|
export function gossipsubTests (factory: DaemonFactory): void {
|
|
11
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -24,7 +23,6 @@ export function gossipsubTests (factory: DaemonFactory): void {
|
|
|
24
23
|
function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
|
|
25
24
|
describe('pubsub.gossipsub', () => {
|
|
26
25
|
let daemons: Daemon[]
|
|
27
|
-
let identify1: IdentifyResult
|
|
28
26
|
|
|
29
27
|
// Start Daemons
|
|
30
28
|
before(async function () {
|
|
@@ -35,8 +33,9 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
35
33
|
factory.spawn(optionsB)
|
|
36
34
|
])
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
await
|
|
36
|
+
const [peerA, peerB] = daemons
|
|
37
|
+
const identifyB = await peerB.client.identify()
|
|
38
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
40
39
|
})
|
|
41
40
|
|
|
42
41
|
// Stop daemons
|
|
@@ -51,23 +50,19 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
51
50
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
52
51
|
const topic = 'test-topic'
|
|
53
52
|
const data = uint8ArrayFromString('test-data')
|
|
53
|
+
const [peerA, peerB] = daemons
|
|
54
54
|
|
|
55
|
-
const
|
|
55
|
+
const subscription = await peerB.client.pubsub.subscribe(topic)
|
|
56
56
|
const subscriber = async (): Promise<void> => {
|
|
57
|
-
const message = await first(
|
|
57
|
+
const message = await first(subscription.messages())
|
|
58
58
|
|
|
59
59
|
expect(message).to.exist()
|
|
60
60
|
expect(message).to.have.property('data').that.equalBytes(data)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const publisher = async (): Promise<void> => {
|
|
64
|
-
|
|
65
|
-
await
|
|
66
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic)
|
|
67
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString())
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
await daemons[0].client.pubsub.publish(topic, data)
|
|
64
|
+
await waitForBothSubscribed(topic, peerA, peerB)
|
|
65
|
+
await peerA.client.pubsub.publish(topic, data)
|
|
71
66
|
}
|
|
72
67
|
|
|
73
68
|
return await Promise.all([
|
package/src/pubsub/hybrid.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { expect } from 'aegir/chai'
|
|
|
4
4
|
import type { Daemon, DaemonFactory, NodeType, SpawnOptions } from '../index.js'
|
|
5
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
6
|
import first from 'it-first'
|
|
7
|
-
import
|
|
8
|
-
import type { IdentifyResult } from '@libp2p/daemon-client'
|
|
7
|
+
import { waitForBothSubscribed } from './utils.js'
|
|
9
8
|
|
|
10
9
|
export function hybridTests (factory: DaemonFactory): void {
|
|
11
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -24,7 +23,6 @@ export function hybridTests (factory: DaemonFactory): void {
|
|
|
24
23
|
function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
|
|
25
24
|
describe('pubsub.hybrid', () => {
|
|
26
25
|
let daemons: Daemon[]
|
|
27
|
-
let identify1: IdentifyResult
|
|
28
26
|
|
|
29
27
|
// Start Daemons
|
|
30
28
|
before(async function () {
|
|
@@ -35,8 +33,9 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
35
33
|
factory.spawn(optionsB)
|
|
36
34
|
])
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
await
|
|
36
|
+
const [peerA, peerB] = daemons
|
|
37
|
+
const identifyB = await peerB.client.identify()
|
|
38
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
40
39
|
})
|
|
41
40
|
|
|
42
41
|
// Stop daemons
|
|
@@ -51,22 +50,19 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
51
50
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
52
51
|
const topic = 'test-topic'
|
|
53
52
|
const data = uint8ArrayFromString('test-data')
|
|
53
|
+
const [peerA, peerB] = daemons
|
|
54
54
|
|
|
55
|
-
const
|
|
55
|
+
const subscription = await peerB.client.pubsub.subscribe(topic)
|
|
56
56
|
const subscriber = async (): Promise<void> => {
|
|
57
|
-
const message = await first(
|
|
57
|
+
const message = await first(subscription.messages())
|
|
58
58
|
|
|
59
59
|
expect(message).to.exist()
|
|
60
60
|
expect(message).to.have.property('data').that.equalBytes(data)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const publisher = async (): Promise<void> => {
|
|
64
|
-
|
|
65
|
-
await
|
|
66
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic)
|
|
67
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString())
|
|
68
|
-
})
|
|
69
|
-
await daemons[0].client.pubsub.publish(topic, data)
|
|
64
|
+
await waitForBothSubscribed(topic, peerA, peerB)
|
|
65
|
+
await peerA.client.pubsub.publish(topic, data)
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
return await Promise.all([
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pWaitFor from 'p-wait-for'
|
|
2
|
+
import type { Daemon } from '..'
|
|
3
|
+
|
|
4
|
+
export async function waitForBothSubscribed (topic: string, a: Daemon, b: Daemon): Promise<void> {
|
|
5
|
+
await a.client.pubsub.subscribe(topic)
|
|
6
|
+
await b.client.pubsub.subscribe(topic)
|
|
7
|
+
|
|
8
|
+
const idA = await a.client.identify()
|
|
9
|
+
const idB = await b.client.identify()
|
|
10
|
+
|
|
11
|
+
// wait for subscription stream
|
|
12
|
+
await Promise.all([
|
|
13
|
+
await pWaitFor(async () => {
|
|
14
|
+
const peers = await a.client.pubsub.getSubscribers(topic)
|
|
15
|
+
return peers.map(p => p.toString()).includes(idB.peerId.toString())
|
|
16
|
+
}, {
|
|
17
|
+
interval: 500
|
|
18
|
+
}),
|
|
19
|
+
await pWaitFor(async () => {
|
|
20
|
+
const peers = await b.client.pubsub.getSubscribers(topic)
|
|
21
|
+
return peers.map(p => p.toString()).includes(idA.peerId.toString())
|
|
22
|
+
}, {
|
|
23
|
+
interval: 500
|
|
24
|
+
})
|
|
25
|
+
])
|
|
26
|
+
}
|