@libp2p/interop 7.0.0 → 7.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.
- package/dist/src/connect.js +15 -16
- package/dist/src/connect.js.map +1 -1
- package/dist/src/dht/content-fetching.js +11 -12
- package/dist/src/dht/content-fetching.js.map +1 -1
- package/dist/src/dht/content-routing.js +17 -13
- package/dist/src/dht/content-routing.js.map +1 -1
- package/dist/src/dht/peer-routing.js +14 -14
- package/dist/src/dht/peer-routing.js.map +1 -1
- package/dist/src/pubsub/floodsub.js +13 -16
- package/dist/src/pubsub/floodsub.js.map +1 -1
- package/dist/src/pubsub/gossipsub.js +13 -16
- package/dist/src/pubsub/gossipsub.js.map +1 -1
- package/dist/src/pubsub/hybrid.js +13 -16
- 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 +15 -18
- package/dist/src/pubsub/utils.js.map +1 -1
- package/dist/src/relay/index.js +8 -2
- package/dist/src/relay/index.js.map +1 -1
- package/dist/src/streams/echo.js +12 -13
- package/dist/src/streams/echo.js.map +1 -1
- package/package.json +3 -2
- package/src/connect.ts +17 -18
- package/src/dht/content-fetching.ts +13 -14
- package/src/dht/content-routing.ts +20 -18
- package/src/dht/peer-routing.ts +16 -16
- package/src/pubsub/floodsub.ts +15 -18
- package/src/pubsub/gossipsub.ts +15 -18
- package/src/pubsub/hybrid.ts +15 -18
- package/src/pubsub/utils.ts +17 -20
- package/src/relay/index.ts +9 -2
- package/src/streams/echo.ts +14 -15
- package/dist/index.min.js +0 -569
package/src/streams/echo.ts
CHANGED
|
@@ -24,21 +24,20 @@ export function echoStreamTests (factory: DaemonFactory, muxer: Muxer): void {
|
|
|
24
24
|
|
|
25
25
|
function runEchoStreamTests (factory: DaemonFactory, muxer: Muxer, optionsA: SpawnOptions, optionsB: SpawnOptions): void {
|
|
26
26
|
describe(`echo streams - ${muxer}`, () => {
|
|
27
|
-
let
|
|
27
|
+
let daemonA: Daemon
|
|
28
|
+
let daemonB: Daemon
|
|
28
29
|
|
|
29
30
|
// Start Daemons
|
|
30
31
|
before(async function () {
|
|
31
32
|
this.timeout(20 * 1000)
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
factory.spawn(optionsB)
|
|
36
|
-
])
|
|
34
|
+
daemonA = await factory.spawn(optionsA)
|
|
35
|
+
daemonB = await factory.spawn(optionsB)
|
|
37
36
|
|
|
38
37
|
// connect them
|
|
39
|
-
const identify0 = await
|
|
38
|
+
const identify0 = await daemonA.client.identify()
|
|
40
39
|
|
|
41
|
-
await
|
|
40
|
+
await daemonB.client.connect(identify0.peerId, identify0.addrs)
|
|
42
41
|
|
|
43
42
|
// jsDaemon1 will take some time to get the peers
|
|
44
43
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
@@ -46,21 +45,21 @@ function runEchoStreamTests (factory: DaemonFactory, muxer: Muxer, optionsA: Spa
|
|
|
46
45
|
|
|
47
46
|
// Stop daemons
|
|
48
47
|
after(async function () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
await Promise.all(
|
|
49
|
+
[daemonA, daemonB]
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.map(async d => { await d.stop() })
|
|
52
|
+
)
|
|
54
53
|
})
|
|
55
54
|
|
|
56
55
|
it(`${optionsA.type} sender to ${optionsB.type} listener`, async function () {
|
|
57
56
|
this.timeout(10 * 1000)
|
|
58
57
|
|
|
59
|
-
const receivingIdentity = await
|
|
58
|
+
const receivingIdentity = await daemonB.client.identify()
|
|
60
59
|
const protocol = '/echo/1.0.0'
|
|
61
60
|
const input = [uint8ArrayFromString('hello world')]
|
|
62
61
|
|
|
63
|
-
await
|
|
62
|
+
await daemonB.client.registerStreamHandler(protocol, async (stream) => {
|
|
64
63
|
await pipe(
|
|
65
64
|
stream,
|
|
66
65
|
async function * (source) {
|
|
@@ -72,7 +71,7 @@ function runEchoStreamTests (factory: DaemonFactory, muxer: Muxer, optionsA: Spa
|
|
|
72
71
|
)
|
|
73
72
|
})
|
|
74
73
|
|
|
75
|
-
const stream = await
|
|
74
|
+
const stream = await daemonA.client.openStream(receivingIdentity.peerId, protocol)
|
|
76
75
|
|
|
77
76
|
// without this the socket can close before we receive a response
|
|
78
77
|
const responseReceived = defer()
|