@libp2p/interface-compliance-tests 1.1.20 → 1.1.23
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/connection/connection.js +1 -1
- package/dist/src/connection/connection.js.map +1 -1
- package/dist/src/connection-encrypter/index.js +1 -1
- package/dist/src/connection-encrypter/index.js.map +1 -1
- package/dist/src/mocks/upgrader.js +1 -1
- package/dist/src/mocks/upgrader.js.map +1 -1
- package/dist/src/peer-discovery/index.js +1 -1
- package/dist/src/peer-discovery/index.js.map +1 -1
- package/dist/src/pubsub/api.d.ts.map +1 -1
- package/dist/src/pubsub/api.js +11 -9
- package/dist/src/pubsub/api.js.map +1 -1
- package/dist/src/pubsub/connection-handlers.d.ts.map +1 -1
- package/dist/src/pubsub/connection-handlers.js +42 -28
- package/dist/src/pubsub/connection-handlers.js.map +1 -1
- package/dist/src/pubsub/emit-self.d.ts.map +1 -1
- package/dist/src/pubsub/emit-self.js +13 -8
- package/dist/src/pubsub/emit-self.js.map +1 -1
- package/dist/src/pubsub/messages.d.ts.map +1 -1
- package/dist/src/pubsub/messages.js +6 -5
- package/dist/src/pubsub/messages.js.map +1 -1
- package/dist/src/pubsub/multiple-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/multiple-nodes.js +96 -40
- package/dist/src/pubsub/multiple-nodes.js.map +1 -1
- package/dist/src/pubsub/two-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/two-nodes.js +35 -50
- package/dist/src/pubsub/two-nodes.js.map +1 -1
- package/dist/src/pubsub/utils.js +1 -1
- package/dist/src/pubsub/utils.js.map +1 -1
- package/dist/src/record/index.js +1 -1
- package/dist/src/record/index.js.map +1 -1
- package/dist/src/stream-muxer/base-test.js +1 -1
- package/dist/src/stream-muxer/base-test.js.map +1 -1
- package/dist/src/stream-muxer/close-test.js +1 -1
- package/dist/src/stream-muxer/close-test.js.map +1 -1
- package/dist/src/stream-muxer/spawner.js +1 -1
- package/dist/src/stream-muxer/spawner.js.map +1 -1
- package/dist/src/topology/topology.js +1 -1
- package/dist/src/topology/topology.js.map +1 -1
- package/dist/src/transport/dial-test.js +1 -1
- package/dist/src/transport/dial-test.js.map +1 -1
- package/dist/src/transport/filter-test.js +1 -1
- package/dist/src/transport/filter-test.js.map +1 -1
- package/dist/src/transport/listen-test.js +1 -1
- package/dist/src/transport/listen-test.js.map +1 -1
- package/package.json +14 -15
- package/src/connection/connection.ts +1 -1
- package/src/connection-encrypter/index.ts +1 -1
- package/src/mocks/upgrader.ts +1 -1
- package/src/peer-discovery/index.ts +1 -1
- package/src/pubsub/api.ts +11 -9
- package/src/pubsub/connection-handlers.ts +44 -29
- package/src/pubsub/emit-self.ts +13 -8
- package/src/pubsub/messages.ts +6 -5
- package/src/pubsub/multiple-nodes.ts +97 -42
- package/src/pubsub/two-nodes.ts +38 -56
- package/src/pubsub/utils.ts +1 -1
- package/src/record/index.ts +1 -1
- package/src/stream-muxer/base-test.ts +1 -1
- package/src/stream-muxer/close-test.ts +1 -1
- package/src/stream-muxer/spawner.ts +1 -1
- package/src/topology/topology.ts +1 -1
- package/src/transport/dial-test.ts +1 -1
- package/src/transport/filter-test.ts +1 -1
- package/src/transport/listen-test.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint max-nested-callbacks: ["error", 6] */
|
|
2
|
-
import { expect } from 'aegir/
|
|
2
|
+
import { expect } from 'aegir/chai'
|
|
3
3
|
import sinon from 'sinon'
|
|
4
4
|
import pDefer from 'p-defer'
|
|
5
5
|
import pWaitFor from 'p-wait-for'
|
|
@@ -7,7 +7,6 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
|
7
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
8
8
|
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
9
9
|
import { connectPeers, mockRegistrar } from '../mocks/registrar.js'
|
|
10
|
-
import { CustomEvent } from '@libp2p/interfaces'
|
|
11
10
|
import { waitForSubscriptionUpdate } from './utils.js'
|
|
12
11
|
import type { TestSetup } from '../index.js'
|
|
13
12
|
import type { Message } from '@libp2p/interfaces/pubsub'
|
|
@@ -149,7 +148,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
149
148
|
psC.subscribe(topic)
|
|
150
149
|
expect(psC.getTopics()).to.deep.equal([topic])
|
|
151
150
|
|
|
152
|
-
psB.addEventListener('
|
|
151
|
+
psB.addEventListener('subscription-change', () => {
|
|
153
152
|
expect(psA.getPeers().length).to.equal(1)
|
|
154
153
|
expect(psB.getPeers().length).to.equal(2)
|
|
155
154
|
expect(psB.getSubscribers(topic).map(p => p.toString())).to.deep.equal([peerIdC.toString()])
|
|
@@ -172,9 +171,21 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
172
171
|
|
|
173
172
|
let counter = 0
|
|
174
173
|
|
|
175
|
-
psA.addEventListener(
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
psA.addEventListener('message', (evt) => {
|
|
175
|
+
if (evt.detail.topic === topic) {
|
|
176
|
+
incMsg(evt)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
psB.addEventListener('message', (evt) => {
|
|
180
|
+
if (evt.detail.topic === topic) {
|
|
181
|
+
incMsg(evt)
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
psC.addEventListener('message', (evt) => {
|
|
185
|
+
if (evt.detail.topic === topic) {
|
|
186
|
+
incMsg(evt)
|
|
187
|
+
}
|
|
188
|
+
})
|
|
178
189
|
|
|
179
190
|
await Promise.all([
|
|
180
191
|
waitForSubscriptionUpdate(psA, psB),
|
|
@@ -182,7 +193,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
182
193
|
waitForSubscriptionUpdate(psC, psB)
|
|
183
194
|
])
|
|
184
195
|
|
|
185
|
-
|
|
196
|
+
psA.publish(topic, uint8ArrayFromString('hey'))
|
|
186
197
|
|
|
187
198
|
function incMsg (evt: CustomEvent<Message>) {
|
|
188
199
|
const msg = evt.detail
|
|
@@ -192,9 +203,21 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
192
203
|
|
|
193
204
|
function check () {
|
|
194
205
|
if (++counter === 3) {
|
|
195
|
-
psA.removeEventListener(
|
|
196
|
-
|
|
197
|
-
|
|
206
|
+
psA.removeEventListener('message', (evt) => {
|
|
207
|
+
if (evt.detail.topic === topic) {
|
|
208
|
+
incMsg(evt)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
psB.removeEventListener('message', (evt) => {
|
|
212
|
+
if (evt.detail.topic === topic) {
|
|
213
|
+
incMsg(evt)
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
psC.removeEventListener('message', (evt) => {
|
|
217
|
+
if (evt.detail.topic === topic) {
|
|
218
|
+
incMsg(evt)
|
|
219
|
+
}
|
|
220
|
+
})
|
|
198
221
|
defer.resolve()
|
|
199
222
|
}
|
|
200
223
|
}
|
|
@@ -216,34 +239,33 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
216
239
|
const defer = pDefer()
|
|
217
240
|
let counter = 0
|
|
218
241
|
|
|
242
|
+
psA.addEventListener('message', (evt) => {
|
|
243
|
+
if (evt.detail.topic === topic) {
|
|
244
|
+
incMsg(evt)
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
psB.addEventListener('message', (evt) => {
|
|
248
|
+
if (evt.detail.topic === topic) {
|
|
249
|
+
incMsg(evt)
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
psC.addEventListener('message', (evt) => {
|
|
253
|
+
if (evt.detail.topic === topic) {
|
|
254
|
+
incMsg(evt)
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
|
|
219
258
|
psA.subscribe(topic)
|
|
220
259
|
psB.subscribe(topic)
|
|
221
260
|
psC.subscribe(topic)
|
|
222
261
|
|
|
223
|
-
// await subscription change
|
|
224
|
-
await Promise.all([
|
|
225
|
-
new Promise(resolve => psA.addEventListener('pubsub:subscription-change', () => resolve(null), {
|
|
226
|
-
once: true
|
|
227
|
-
})),
|
|
228
|
-
new Promise(resolve => psB.addEventListener('pubsub:subscription-change', () => resolve(null), {
|
|
229
|
-
once: true
|
|
230
|
-
})),
|
|
231
|
-
new Promise(resolve => psC.addEventListener('pubsub:subscription-change', () => resolve(null), {
|
|
232
|
-
once: true
|
|
233
|
-
}))
|
|
234
|
-
])
|
|
235
|
-
|
|
236
|
-
psA.addEventListener(topic, incMsg)
|
|
237
|
-
psB.addEventListener(topic, incMsg)
|
|
238
|
-
psC.addEventListener(topic, incMsg)
|
|
239
|
-
|
|
240
262
|
await Promise.all([
|
|
241
263
|
waitForSubscriptionUpdate(psA, psB),
|
|
242
264
|
waitForSubscriptionUpdate(psB, psA),
|
|
243
265
|
waitForSubscriptionUpdate(psC, psB)
|
|
244
266
|
])
|
|
245
267
|
|
|
246
|
-
|
|
268
|
+
psB.publish(topic, uint8ArrayFromString('hey'))
|
|
247
269
|
|
|
248
270
|
function incMsg (evt: CustomEvent<Message>) {
|
|
249
271
|
const msg = evt.detail
|
|
@@ -253,9 +275,21 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
253
275
|
|
|
254
276
|
function check () {
|
|
255
277
|
if (++counter === 3) {
|
|
256
|
-
psA.removeEventListener(
|
|
257
|
-
|
|
258
|
-
|
|
278
|
+
psA.removeEventListener('message', (evt) => {
|
|
279
|
+
if (evt.detail.topic === topic) {
|
|
280
|
+
incMsg(evt)
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
psB.removeEventListener('message', (evt) => {
|
|
284
|
+
if (evt.detail.topic === topic) {
|
|
285
|
+
incMsg(evt)
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
psC.removeEventListener('message', (evt) => {
|
|
289
|
+
if (evt.detail.topic === topic) {
|
|
290
|
+
incMsg(evt)
|
|
291
|
+
}
|
|
292
|
+
})
|
|
259
293
|
defer.resolve()
|
|
260
294
|
}
|
|
261
295
|
}
|
|
@@ -415,17 +449,38 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
415
449
|
it('publishes from c', async function () {
|
|
416
450
|
const defer = pDefer()
|
|
417
451
|
let counter = 0
|
|
452
|
+
const topic = 'Z'
|
|
418
453
|
|
|
419
|
-
psA.subscribe(
|
|
420
|
-
psA.addEventListener('
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
454
|
+
psA.subscribe(topic)
|
|
455
|
+
psA.addEventListener('message', (evt) => {
|
|
456
|
+
if (evt.detail.topic === topic) {
|
|
457
|
+
incMsg(evt)
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
psB.subscribe(topic)
|
|
461
|
+
psB.addEventListener('message', (evt) => {
|
|
462
|
+
if (evt.detail.topic === topic) {
|
|
463
|
+
incMsg(evt)
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
psC.subscribe(topic)
|
|
467
|
+
psC.addEventListener('message', (evt) => {
|
|
468
|
+
if (evt.detail.topic === topic) {
|
|
469
|
+
incMsg(evt)
|
|
470
|
+
}
|
|
471
|
+
})
|
|
472
|
+
psD.subscribe(topic)
|
|
473
|
+
psD.addEventListener('message', (evt) => {
|
|
474
|
+
if (evt.detail.topic === topic) {
|
|
475
|
+
incMsg(evt)
|
|
476
|
+
}
|
|
477
|
+
})
|
|
478
|
+
psE.subscribe(topic)
|
|
479
|
+
psE.addEventListener('message', (evt) => {
|
|
480
|
+
if (evt.detail.topic === topic) {
|
|
481
|
+
incMsg(evt)
|
|
482
|
+
}
|
|
483
|
+
})
|
|
429
484
|
|
|
430
485
|
await Promise.all([
|
|
431
486
|
waitForSubscriptionUpdate(psA, psB),
|
|
@@ -435,7 +490,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
435
490
|
waitForSubscriptionUpdate(psE, psD)
|
|
436
491
|
])
|
|
437
492
|
|
|
438
|
-
|
|
493
|
+
psC.publish('Z', uint8ArrayFromString('hey from c'))
|
|
439
494
|
|
|
440
495
|
function incMsg (evt: CustomEvent<Message>) {
|
|
441
496
|
const msg = evt.detail
|
package/src/pubsub/two-nodes.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint max-nested-callbacks: ["error", 6] */
|
|
2
|
-
import { expect } from 'aegir/
|
|
2
|
+
import { expect } from 'aegir/chai'
|
|
3
3
|
import sinon from 'sinon'
|
|
4
4
|
import pDefer from 'p-defer'
|
|
5
5
|
import pWaitFor from 'p-wait-for'
|
|
@@ -7,7 +7,6 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
|
7
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
8
8
|
import { connectPeers, mockRegistrar } from '../mocks/registrar.js'
|
|
9
9
|
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
10
|
-
import { CustomEvent } from '@libp2p/interfaces'
|
|
11
10
|
import { waitForSubscriptionUpdate } from './utils.js'
|
|
12
11
|
import type { TestSetup } from '../index.js'
|
|
13
12
|
import type { Message } from '@libp2p/interfaces/pubsub'
|
|
@@ -89,7 +88,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
89
88
|
it('Subscribe to a topic in nodeA', async () => {
|
|
90
89
|
const defer = pDefer()
|
|
91
90
|
|
|
92
|
-
psB.addEventListener('
|
|
91
|
+
psB.addEventListener('subscription-change', (evt) => {
|
|
93
92
|
const { peerId: changedPeerId, subscriptions: changedSubs } = evt.detail
|
|
94
93
|
expect(psA.getTopics()).to.deep.equal([topic])
|
|
95
94
|
expect(psB.getPeers()).to.have.lengthOf(1)
|
|
@@ -110,25 +109,26 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
110
109
|
it('Publish to a topic in nodeA', async () => {
|
|
111
110
|
const defer = pDefer()
|
|
112
111
|
|
|
113
|
-
psA.addEventListener(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
psA.addEventListener('message', (evt) => {
|
|
113
|
+
if (evt.detail.topic === topic) {
|
|
114
|
+
const msg = evt.detail
|
|
115
|
+
expect(uint8ArrayToString(msg.data)).to.equal('hey')
|
|
116
|
+
psB.removeEventListener('message', shouldNotHappen)
|
|
117
|
+
defer.resolve()
|
|
118
|
+
}
|
|
118
119
|
}, {
|
|
119
120
|
once: true
|
|
120
121
|
})
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
123
|
+
psA.subscribe(topic)
|
|
124
|
+
psB.subscribe(topic)
|
|
125
125
|
|
|
126
126
|
await Promise.all([
|
|
127
127
|
waitForSubscriptionUpdate(psA, psB),
|
|
128
128
|
waitForSubscriptionUpdate(psB, psA)
|
|
129
129
|
])
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
psA.publish(topic, uint8ArrayFromString('hey'))
|
|
132
132
|
|
|
133
133
|
return await defer.promise
|
|
134
134
|
})
|
|
@@ -136,16 +136,24 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
136
136
|
it('Publish to a topic in nodeB', async () => {
|
|
137
137
|
const defer = pDefer()
|
|
138
138
|
|
|
139
|
-
psA.addEventListener(
|
|
139
|
+
psA.addEventListener('message', (evt) => {
|
|
140
|
+
if (evt.detail.topic !== topic) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
140
144
|
const msg = evt.detail
|
|
141
|
-
psA.addEventListener(
|
|
145
|
+
psA.addEventListener('message', (evt) => {
|
|
146
|
+
if (evt.detail.topic === topic) {
|
|
147
|
+
shouldNotHappen()
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
142
150
|
once: true
|
|
143
151
|
})
|
|
144
152
|
expect(uint8ArrayToString(msg.data)).to.equal('banana')
|
|
145
153
|
|
|
146
154
|
setTimeout(() => {
|
|
147
|
-
psA.removeEventListener(
|
|
148
|
-
psB.removeEventListener(
|
|
155
|
+
psA.removeEventListener('message')
|
|
156
|
+
psB.removeEventListener('message')
|
|
149
157
|
|
|
150
158
|
defer.resolve()
|
|
151
159
|
}, 100)
|
|
@@ -153,16 +161,17 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
153
161
|
once: true
|
|
154
162
|
})
|
|
155
163
|
|
|
156
|
-
psB.addEventListener(
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
psB.addEventListener('message', shouldNotHappen)
|
|
165
|
+
|
|
166
|
+
psA.subscribe(topic)
|
|
167
|
+
psB.subscribe(topic)
|
|
159
168
|
|
|
160
169
|
await Promise.all([
|
|
161
170
|
waitForSubscriptionUpdate(psA, psB),
|
|
162
171
|
waitForSubscriptionUpdate(psB, psA)
|
|
163
172
|
])
|
|
164
173
|
|
|
165
|
-
|
|
174
|
+
psB.publish(topic, uint8ArrayFromString('banana'))
|
|
166
175
|
|
|
167
176
|
return await defer.promise
|
|
168
177
|
})
|
|
@@ -171,10 +180,8 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
171
180
|
const defer = pDefer()
|
|
172
181
|
let counter = 0
|
|
173
182
|
|
|
174
|
-
psB.addEventListener(
|
|
175
|
-
|
|
176
|
-
})
|
|
177
|
-
psA.addEventListener(topic, receivedMsg)
|
|
183
|
+
psB.addEventListener('message', shouldNotHappen)
|
|
184
|
+
psA.addEventListener('message', receivedMsg)
|
|
178
185
|
|
|
179
186
|
function receivedMsg (evt: CustomEvent<Message>) {
|
|
180
187
|
const msg = evt.detail
|
|
@@ -184,19 +191,22 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
184
191
|
expect(msg.topic).to.be.equal(topic)
|
|
185
192
|
|
|
186
193
|
if (++counter === 10) {
|
|
187
|
-
psA.removeEventListener(
|
|
188
|
-
psB.removeEventListener(
|
|
194
|
+
psA.removeEventListener('message', receivedMsg)
|
|
195
|
+
psB.removeEventListener('message', shouldNotHappen)
|
|
189
196
|
|
|
190
197
|
defer.resolve()
|
|
191
198
|
}
|
|
192
199
|
}
|
|
193
200
|
|
|
201
|
+
psA.subscribe(topic)
|
|
202
|
+
psB.subscribe(topic)
|
|
203
|
+
|
|
194
204
|
await Promise.all([
|
|
195
205
|
waitForSubscriptionUpdate(psA, psB),
|
|
196
206
|
waitForSubscriptionUpdate(psB, psA)
|
|
197
207
|
])
|
|
198
208
|
|
|
199
|
-
Array.from({ length: 10 }, (_, i) => psB.
|
|
209
|
+
Array.from({ length: 10 }, (_, i) => psB.publish(topic, uint8ArrayFromString('banana')))
|
|
200
210
|
|
|
201
211
|
return await defer.promise
|
|
202
212
|
})
|
|
@@ -205,7 +215,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
205
215
|
const defer = pDefer()
|
|
206
216
|
let callCount = 0
|
|
207
217
|
|
|
208
|
-
psB.addEventListener('
|
|
218
|
+
psB.addEventListener('subscription-change', (evt) => {
|
|
209
219
|
callCount++
|
|
210
220
|
|
|
211
221
|
if (callCount === 1) {
|
|
@@ -239,33 +249,5 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
|
239
249
|
|
|
240
250
|
return await defer.promise
|
|
241
251
|
})
|
|
242
|
-
|
|
243
|
-
it.skip('Publish to a topic:Z in nodeA nodeB', async () => {
|
|
244
|
-
const defer = pDefer()
|
|
245
|
-
const topic = 'Z'
|
|
246
|
-
|
|
247
|
-
psA.addEventListener(topic, shouldNotHappen, {
|
|
248
|
-
once: true
|
|
249
|
-
})
|
|
250
|
-
psB.addEventListener(topic, shouldNotHappen, {
|
|
251
|
-
once: true
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
await Promise.all([
|
|
255
|
-
waitForSubscriptionUpdate(psA, psB),
|
|
256
|
-
waitForSubscriptionUpdate(psB, psA)
|
|
257
|
-
])
|
|
258
|
-
|
|
259
|
-
setTimeout(() => {
|
|
260
|
-
psA.removeEventListener(topic, shouldNotHappen)
|
|
261
|
-
psB.removeEventListener(topic, shouldNotHappen)
|
|
262
|
-
defer.resolve()
|
|
263
|
-
}, 100)
|
|
264
|
-
|
|
265
|
-
void psB.dispatchEvent(new CustomEvent<Uint8Array>(topic, { detail: uint8ArrayFromString('banana') }))
|
|
266
|
-
void psA.dispatchEvent(new CustomEvent<Uint8Array>(topic, { detail: uint8ArrayFromString('banana') }))
|
|
267
|
-
|
|
268
|
-
return await defer.promise
|
|
269
|
-
})
|
|
270
252
|
})
|
|
271
253
|
}
|
package/src/pubsub/utils.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { PubSubBaseProtocol } from '@libp2p/pubsub'
|
|
|
5
5
|
|
|
6
6
|
export async function waitForSubscriptionUpdate (a: PubSubBaseProtocol, b: PubSubBaseProtocol) {
|
|
7
7
|
await pWaitFor(async () => {
|
|
8
|
-
const event = await pEvent<'
|
|
8
|
+
const event = await pEvent<'subscription-change', CustomEvent<SubscriptionChangeData>>(a, 'subscription-change')
|
|
9
9
|
|
|
10
10
|
return event.detail.peerId.equals(b.components.getPeerId())
|
|
11
11
|
})
|
package/src/record/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { duplexPair } from 'it-pair/duplex'
|
|
|
4
4
|
import { abortableSource } from 'abortable-iterator'
|
|
5
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
6
6
|
import drain from 'it-drain'
|
|
7
|
-
import { expect } from 'aegir/
|
|
7
|
+
import { expect } from 'aegir/chai'
|
|
8
8
|
import delay from 'delay'
|
|
9
9
|
import type { TestSetup } from '../index.js'
|
|
10
10
|
import type { StreamMuxerFactory } from '@libp2p/interfaces/stream-muxer'
|
package/src/topology/topology.ts
CHANGED