@libp2p/interop 6.0.2 → 6.0.3
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 +3 -8
- 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 +3 -8
- 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 +3 -8
- 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 +21 -0
- package/dist/src/pubsub/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/pubsub/floodsub.ts +3 -10
- package/src/pubsub/gossipsub.ts +3 -10
- package/src/pubsub/hybrid.ts +3 -9
- package/src/pubsub/utils.ts +23 -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
|
|
@@ -43,11 +42,7 @@ function runFloodsubTests(factory, optionsA, optionsB) {
|
|
|
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,yBAAy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;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,7 +21,7 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
22
21
|
factory.spawn(optionsA),
|
|
23
22
|
factory.spawn(optionsB)
|
|
24
23
|
]);
|
|
25
|
-
identify1 = await daemons[1].client.identify();
|
|
24
|
+
const identify1 = await daemons[1].client.identify();
|
|
26
25
|
await daemons[0].client.connect(identify1.peerId, identify1.addrs);
|
|
27
26
|
});
|
|
28
27
|
// Stop daemons
|
|
@@ -41,11 +40,7 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
41
40
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
42
41
|
};
|
|
43
42
|
const publisher = async () => {
|
|
44
|
-
|
|
45
|
-
await pWaitFor(async () => {
|
|
46
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic);
|
|
47
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString());
|
|
48
|
-
});
|
|
43
|
+
await waitForBothSubscribed(topic, daemons[0], daemons[1]);
|
|
49
44
|
await daemons[0].client.pubsub.publish(topic, data);
|
|
50
45
|
};
|
|
51
46
|
return await Promise.all([
|
|
@@ -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,cA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,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,7 +21,7 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
22
21
|
factory.spawn(optionsA),
|
|
23
22
|
factory.spawn(optionsB)
|
|
24
23
|
]);
|
|
25
|
-
identify1 = await daemons[1].client.identify();
|
|
24
|
+
const identify1 = await daemons[1].client.identify();
|
|
26
25
|
await daemons[0].client.connect(identify1.peerId, identify1.addrs);
|
|
27
26
|
});
|
|
28
27
|
// Stop daemons
|
|
@@ -41,11 +40,7 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
41
40
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
42
41
|
};
|
|
43
42
|
const publisher = async () => {
|
|
44
|
-
|
|
45
|
-
await pWaitFor(async () => {
|
|
46
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic);
|
|
47
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString());
|
|
48
|
-
});
|
|
43
|
+
await waitForBothSubscribed(topic, daemons[0], daemons[1]);
|
|
49
44
|
await daemons[0].client.pubsub.publish(topic, data);
|
|
50
45
|
};
|
|
51
46
|
return await Promise.all([
|
|
@@ -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,Q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AC,CAAA;gBAE9C,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,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,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC1D,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACrD,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,CAmB/F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pWaitFor from 'p-wait-for';
|
|
2
|
+
export async function waitForBothSubscribed(topic, a, b) {
|
|
3
|
+
const idA = await a.client.identify();
|
|
4
|
+
const idB = await b.client.identify();
|
|
5
|
+
// wait for subscription stream
|
|
6
|
+
await Promise.all([
|
|
7
|
+
await pWaitFor(async () => {
|
|
8
|
+
const peers = await a.client.pubsub.getSubscribers(topic);
|
|
9
|
+
return peers.map(p => p.toString()).includes(idB.peerId.toString());
|
|
10
|
+
}, {
|
|
11
|
+
interval: 500
|
|
12
|
+
}),
|
|
13
|
+
await pWaitFor(async () => {
|
|
14
|
+
const peers = await b.client.pubsub.getSubscribers(topic);
|
|
15
|
+
return peers.map(p => p.toString()).includes(idA.peerId.toString());
|
|
16
|
+
}, {
|
|
17
|
+
interval: 500
|
|
18
|
+
})
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
//# 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,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
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
|
|
|
@@ -63,12 +61,7 @@ function runFloodsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optio
|
|
|
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,7 +33,7 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
35
33
|
factory.spawn(optionsB)
|
|
36
34
|
])
|
|
37
35
|
|
|
38
|
-
identify1 = await daemons[1].client.identify()
|
|
36
|
+
const identify1 = await daemons[1].client.identify()
|
|
39
37
|
await daemons[0].client.connect(identify1.peerId, identify1.addrs)
|
|
40
38
|
})
|
|
41
39
|
|
|
@@ -61,12 +59,7 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
const publisher = async (): Promise<void> => {
|
|
64
|
-
|
|
65
|
-
await pWaitFor(async () => {
|
|
66
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic)
|
|
67
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString())
|
|
68
|
-
})
|
|
69
|
-
|
|
62
|
+
await waitForBothSubscribed(topic, daemons[0], daemons[1])
|
|
70
63
|
await daemons[0].client.pubsub.publish(topic, data)
|
|
71
64
|
}
|
|
72
65
|
|
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,7 +33,7 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
35
33
|
factory.spawn(optionsB)
|
|
36
34
|
])
|
|
37
35
|
|
|
38
|
-
identify1 = await daemons[1].client.identify()
|
|
36
|
+
const identify1 = await daemons[1].client.identify()
|
|
39
37
|
await daemons[0].client.connect(identify1.peerId, identify1.addrs)
|
|
40
38
|
})
|
|
41
39
|
|
|
@@ -61,11 +59,7 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
const publisher = async (): Promise<void> => {
|
|
64
|
-
|
|
65
|
-
await pWaitFor(async () => {
|
|
66
|
-
const peers = await daemons[0].client.pubsub.getSubscribers(topic)
|
|
67
|
-
return peers.map(p => p.toString()).includes(identify1.peerId.toString())
|
|
68
|
-
})
|
|
62
|
+
await waitForBothSubscribed(topic, daemons[0], daemons[1])
|
|
69
63
|
await daemons[0].client.pubsub.publish(topic, data)
|
|
70
64
|
}
|
|
71
65
|
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
const idA = await a.client.identify()
|
|
6
|
+
const idB = await b.client.identify()
|
|
7
|
+
|
|
8
|
+
// wait for subscription stream
|
|
9
|
+
await Promise.all([
|
|
10
|
+
await pWaitFor(async () => {
|
|
11
|
+
const peers = await a.client.pubsub.getSubscribers(topic)
|
|
12
|
+
return peers.map(p => p.toString()).includes(idB.peerId.toString())
|
|
13
|
+
}, {
|
|
14
|
+
interval: 500
|
|
15
|
+
}),
|
|
16
|
+
await pWaitFor(async () => {
|
|
17
|
+
const peers = await b.client.pubsub.getSubscribers(topic)
|
|
18
|
+
return peers.map(p => p.toString()).includes(idA.peerId.toString())
|
|
19
|
+
}, {
|
|
20
|
+
interval: 500
|
|
21
|
+
})
|
|
22
|
+
])
|
|
23
|
+
}
|