@libp2p/interop 6.0.3 → 7.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.
- package/dist/index.min.js +5 -5
- package/dist/src/pubsub/floodsub.js +4 -4
- package/dist/src/pubsub/floodsub.js.map +1 -1
- package/dist/src/pubsub/gossipsub.js +9 -7
- package/dist/src/pubsub/gossipsub.js.map +1 -1
- package/dist/src/pubsub/hybrid.js +9 -7
- package/dist/src/pubsub/hybrid.js.map +1 -1
- package/dist/src/pubsub/utils.d.ts +6 -2
- package/dist/src/pubsub/utils.d.ts.map +1 -1
- package/dist/src/pubsub/utils.js +14 -16
- package/dist/src/pubsub/utils.js.map +1 -1
- package/package.json +4 -3
- package/src/pubsub/floodsub.ts +4 -4
- package/src/pubsub/gossipsub.ts +9 -7
- package/src/pubsub/hybrid.ts +9 -7
- package/src/pubsub/utils.ts +16 -17
|
@@ -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 { waitForSubscribed } from './utils.js';
|
|
6
6
|
export function floodsubTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -35,14 +35,14 @@ function runFloodsubTests(factory, optionsA, optionsB) {
|
|
|
35
35
|
const topic = 'test-topic';
|
|
36
36
|
const data = uint8ArrayFromString('test-data');
|
|
37
37
|
const [peerA, peerB] = daemons;
|
|
38
|
-
const
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
39
39
|
const subscriber = async () => {
|
|
40
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
41
41
|
expect(message).to.exist();
|
|
42
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
43
43
|
};
|
|
44
44
|
const publisher = async () => {
|
|
45
|
-
await
|
|
45
|
+
await waitForSubscribed(topic, peerA, peerB);
|
|
46
46
|
await peerA.client.pubsub.publish(topic, data);
|
|
47
47
|
};
|
|
48
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,EAAE,
|
|
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,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,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,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,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAA;gBAEpD,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,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;gBAC5C,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"}
|
|
@@ -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 { waitForSubscribed } from './utils.js';
|
|
6
6
|
export function gossipsubTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -21,8 +21,9 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
21
21
|
factory.spawn(optionsA),
|
|
22
22
|
factory.spawn(optionsB)
|
|
23
23
|
]);
|
|
24
|
-
const
|
|
25
|
-
await
|
|
24
|
+
const [peerA, peerB] = daemons;
|
|
25
|
+
const identifyB = await peerB.client.identify();
|
|
26
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
26
27
|
});
|
|
27
28
|
// Stop daemons
|
|
28
29
|
after(async function () {
|
|
@@ -33,15 +34,16 @@ function runGossipsubTests(factory, optionsA, optionsB) {
|
|
|
33
34
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
34
35
|
const topic = 'test-topic';
|
|
35
36
|
const data = uint8ArrayFromString('test-data');
|
|
36
|
-
const
|
|
37
|
+
const [peerA, peerB] = daemons;
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
37
39
|
const subscriber = async () => {
|
|
38
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
39
41
|
expect(message).to.exist();
|
|
40
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
41
43
|
};
|
|
42
44
|
const publisher = async () => {
|
|
43
|
-
await
|
|
44
|
-
await
|
|
45
|
+
await waitForSubscribed(topic, peerA, peerB);
|
|
46
|
+
await peerA.client.pubsub.publish(topic, data);
|
|
45
47
|
};
|
|
46
48
|
return await Promise.all([
|
|
47
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,EAAE,
|
|
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,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAA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rayFromString } from 'uint8arrays/from-string';
|
|
4
4
|
import first from 'it-first';
|
|
5
|
-
import {
|
|
5
|
+
import { waitForSubscribed } from './utils.js';
|
|
6
6
|
export function hybridTests(factory) {
|
|
7
7
|
const nodeTypes = ['js', 'go'];
|
|
8
8
|
for (const typeA of nodeTypes) {
|
|
@@ -21,8 +21,9 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
21
21
|
factory.spawn(optionsA),
|
|
22
22
|
factory.spawn(optionsB)
|
|
23
23
|
]);
|
|
24
|
-
const
|
|
25
|
-
await
|
|
24
|
+
const [peerA, peerB] = daemons;
|
|
25
|
+
const identifyB = await peerB.client.identify();
|
|
26
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs);
|
|
26
27
|
});
|
|
27
28
|
// Stop daemons
|
|
28
29
|
after(async function () {
|
|
@@ -33,15 +34,16 @@ function runHybridTests(factory, optionsA, optionsB) {
|
|
|
33
34
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
34
35
|
const topic = 'test-topic';
|
|
35
36
|
const data = uint8ArrayFromString('test-data');
|
|
36
|
-
const
|
|
37
|
+
const [peerA, peerB] = daemons;
|
|
38
|
+
const subscription = await peerB.client.pubsub.subscribe(topic);
|
|
37
39
|
const subscriber = async () => {
|
|
38
|
-
const message = await first(
|
|
40
|
+
const message = await first(subscription.messages());
|
|
39
41
|
expect(message).to.exist();
|
|
40
42
|
expect(message).to.have.property('data').that.equalBytes(data);
|
|
41
43
|
};
|
|
42
44
|
const publisher = async () => {
|
|
43
|
-
await
|
|
44
|
-
await
|
|
45
|
+
await waitForSubscribed(topic, peerA, peerB);
|
|
46
|
+
await peerA.client.pubsub.publish(topic, data);
|
|
45
47
|
};
|
|
46
48
|
return await Promise.all([
|
|
47
49
|
subscriber(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybrid.js","sourceRoot":"","sources":["../../../src/pubsub/hybrid.ts"],"names":[],"mappings":"AAAA,sBAAsB;A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ChE,CAAC,CAAA;YAED,MAAM,SAAS,GAAG,KAAK,IAAmB,EAAE;gBAC1C,MAAM,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;gBAC5C,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,3 +1,7 @@
|
|
|
1
|
-
import type { Daemon } from '
|
|
2
|
-
|
|
1
|
+
import type { Daemon } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wait for daemon a to see daemon b in it's subscriber list
|
|
4
|
+
* for the passed topic
|
|
5
|
+
*/
|
|
6
|
+
export declare function waitForSubscribed(topic: string, a: Daemon, b: Daemon): Promise<void>;
|
|
3
7
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC;;;GAGG;AACH,wBAAsB,iBAAiB,CAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3F"}
|
package/dist/src/pubsub/utils.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import pWaitFor from 'p-wait-for';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import delay from 'delay';
|
|
3
|
+
/**
|
|
4
|
+
* Wait for daemon a to see daemon b in it's subscriber list
|
|
5
|
+
* for the passed topic
|
|
6
|
+
*/
|
|
7
|
+
export async function waitForSubscribed(topic, a, b) {
|
|
4
8
|
const idB = await b.client.identify();
|
|
5
9
|
// wait for subscription stream
|
|
6
|
-
await
|
|
7
|
-
await
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
]);
|
|
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
|
+
// wait for the gossipsub heartbeat to rebalance the mesh
|
|
17
|
+
await delay(2000);
|
|
20
18
|
}
|
|
21
19
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/pubsub/utils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAE,KAAa,EAAE,CAAS,EAAE,CAAS;IAC1E,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IAErC,+BAA+B;IAC/B,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QACzD,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;IACrE,CAAC,EAAE;QACD,QAAQ,EAAE,GAAG;KACd,CAAC,CAAA;IAEF,yDAAyD;IACzD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interop",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
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,15 +133,16 @@
|
|
|
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",
|
|
140
|
+
"delay": "^5.0.0",
|
|
140
141
|
"it-all": "^2.0.0",
|
|
141
142
|
"it-first": "^2.0.0",
|
|
142
143
|
"it-handshake": "^4.1.2",
|
|
143
144
|
"it-length-prefixed": "^8.0.4",
|
|
144
|
-
"it-pb-stream": "^
|
|
145
|
+
"it-pb-stream": "^3.0.0",
|
|
145
146
|
"it-pipe": "^2.0.4",
|
|
146
147
|
"it-stream-types": "^1.0.5",
|
|
147
148
|
"multiformats": "^11.0.0",
|
package/src/pubsub/floodsub.ts
CHANGED
|
@@ -4,7 +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 {
|
|
7
|
+
import { waitForSubscribed } from './utils.js'
|
|
8
8
|
|
|
9
9
|
export function floodsubTests (factory: DaemonFactory): void {
|
|
10
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -52,16 +52,16 @@ function runFloodsubTests (factory: DaemonFactory, optionsA: SpawnOptions, optio
|
|
|
52
52
|
const data = uint8ArrayFromString('test-data')
|
|
53
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
|
-
await
|
|
64
|
+
await waitForSubscribed(topic, peerA, peerB)
|
|
65
65
|
await peerA.client.pubsub.publish(topic, data)
|
|
66
66
|
}
|
|
67
67
|
|
package/src/pubsub/gossipsub.ts
CHANGED
|
@@ -4,7 +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 {
|
|
7
|
+
import { waitForSubscribed } from './utils.js'
|
|
8
8
|
|
|
9
9
|
export function gossipsubTests (factory: DaemonFactory): void {
|
|
10
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -33,8 +33,9 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
33
33
|
factory.spawn(optionsB)
|
|
34
34
|
])
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
await
|
|
36
|
+
const [peerA, peerB] = daemons
|
|
37
|
+
const identifyB = await peerB.client.identify()
|
|
38
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
// Stop daemons
|
|
@@ -49,18 +50,19 @@ function runGossipsubTests (factory: DaemonFactory, optionsA: SpawnOptions, opti
|
|
|
49
50
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
50
51
|
const topic = 'test-topic'
|
|
51
52
|
const data = uint8ArrayFromString('test-data')
|
|
53
|
+
const [peerA, peerB] = daemons
|
|
52
54
|
|
|
53
|
-
const
|
|
55
|
+
const subscription = await peerB.client.pubsub.subscribe(topic)
|
|
54
56
|
const subscriber = async (): Promise<void> => {
|
|
55
|
-
const message = await first(
|
|
57
|
+
const message = await first(subscription.messages())
|
|
56
58
|
|
|
57
59
|
expect(message).to.exist()
|
|
58
60
|
expect(message).to.have.property('data').that.equalBytes(data)
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
const publisher = async (): Promise<void> => {
|
|
62
|
-
await
|
|
63
|
-
await
|
|
64
|
+
await waitForSubscribed(topic, peerA, peerB)
|
|
65
|
+
await peerA.client.pubsub.publish(topic, data)
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
return await Promise.all([
|
package/src/pubsub/hybrid.ts
CHANGED
|
@@ -4,7 +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 {
|
|
7
|
+
import { waitForSubscribed } from './utils.js'
|
|
8
8
|
|
|
9
9
|
export function hybridTests (factory: DaemonFactory): void {
|
|
10
10
|
const nodeTypes: NodeType[] = ['js', 'go']
|
|
@@ -33,8 +33,9 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
33
33
|
factory.spawn(optionsB)
|
|
34
34
|
])
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
await
|
|
36
|
+
const [peerA, peerB] = daemons
|
|
37
|
+
const identifyB = await peerB.client.identify()
|
|
38
|
+
await peerA.client.connect(identifyB.peerId, identifyB.addrs)
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
// Stop daemons
|
|
@@ -49,18 +50,19 @@ function runHybridTests (factory: DaemonFactory, optionsA: SpawnOptions, options
|
|
|
49
50
|
it(`${optionsA.type} peer to ${optionsB.type} peer`, async function () {
|
|
50
51
|
const topic = 'test-topic'
|
|
51
52
|
const data = uint8ArrayFromString('test-data')
|
|
53
|
+
const [peerA, peerB] = daemons
|
|
52
54
|
|
|
53
|
-
const
|
|
55
|
+
const subscription = await peerB.client.pubsub.subscribe(topic)
|
|
54
56
|
const subscriber = async (): Promise<void> => {
|
|
55
|
-
const message = await first(
|
|
57
|
+
const message = await first(subscription.messages())
|
|
56
58
|
|
|
57
59
|
expect(message).to.exist()
|
|
58
60
|
expect(message).to.have.property('data').that.equalBytes(data)
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
const publisher = async (): Promise<void> => {
|
|
62
|
-
await
|
|
63
|
-
await
|
|
64
|
+
await waitForSubscribed(topic, peerA, peerB)
|
|
65
|
+
await peerA.client.pubsub.publish(topic, data)
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
return await Promise.all([
|
package/src/pubsub/utils.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import pWaitFor from 'p-wait-for'
|
|
2
|
-
import
|
|
2
|
+
import delay from 'delay'
|
|
3
|
+
import type { Daemon } from '../index.js'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Wait for daemon a to see daemon b in it's subscriber list
|
|
7
|
+
* for the passed topic
|
|
8
|
+
*/
|
|
9
|
+
export async function waitForSubscribed (topic: string, a: Daemon, b: Daemon): Promise<void> {
|
|
6
10
|
const idB = await b.client.identify()
|
|
7
11
|
|
|
8
12
|
// wait for subscription stream
|
|
9
|
-
await
|
|
10
|
-
await
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return peers.map(p => p.toString()).includes(idA.peerId.toString())
|
|
19
|
-
}, {
|
|
20
|
-
interval: 500
|
|
21
|
-
})
|
|
22
|
-
])
|
|
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
|
+
|
|
20
|
+
// wait for the gossipsub heartbeat to rebalance the mesh
|
|
21
|
+
await delay(2000)
|
|
23
22
|
}
|