@@ -9,24 +9,23 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory'
9
9
import { connectPeers , mockRegistrar } from '../mocks/registrar.js'
10
10
import { waitForSubscriptionUpdate } from './utils.js'
11
11
import type { TestSetup } from '../index.js'
12
- import type { Message } from '@libp2p/interfaces/pubsub'
12
+ import type { Message , PubSub } from '@libp2p/interfaces/pubsub'
13
13
import type { PubSubArgs } from './index.js'
14
14
import type { PeerId } from '@libp2p/interfaces/peer-id'
15
15
import type { Registrar } from '@libp2p/interfaces/registrar'
16
- import type { PubSubBaseProtocol } from '@libp2p/pubsub'
17
16
import { Components } from '@libp2p/interfaces/components'
18
17
import { start , stop } from '../index.js'
19
18
20
- export default ( common : TestSetup < PubSubBaseProtocol , PubSubArgs > ) => {
19
+ export default ( common : TestSetup < PubSub , PubSubArgs > ) => {
21
20
describe ( 'pubsub with multiple nodes' , function ( ) {
22
21
describe ( 'every peer subscribes to the topic' , ( ) => {
23
22
describe ( 'line' , ( ) => {
24
23
// line
25
24
// ◉────◉────◉
26
25
// a b c
27
- let psA : PubSubBaseProtocol
28
- let psB : PubSubBaseProtocol
29
- let psC : PubSubBaseProtocol
26
+ let psA : PubSub
27
+ let psB : PubSub
28
+ let psC : PubSub
30
29
let peerIdA : PeerId
31
30
let peerIdB : PeerId
32
31
let peerIdC : PeerId
@@ -115,7 +114,7 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
115
114
psA . subscribe ( topic )
116
115
expect ( psA . getTopics ( ) ) . to . deep . equal ( [ topic ] )
117
116
118
- await waitForSubscriptionUpdate ( psB , psA )
117
+ await waitForSubscriptionUpdate ( psB , peerIdA )
119
118
120
119
expect ( psB . getPeers ( ) . length ) . to . equal ( 2 )
121
120
expect ( psB . getSubscribers ( topic ) . map ( p => p . toString ( ) ) ) . to . deep . equal ( [ peerIdA . toString ( ) ] )
@@ -130,8 +129,8 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
130
129
expect ( psB . getTopics ( ) ) . to . deep . equal ( [ topic ] )
131
130
132
131
await Promise . all ( [
133
- waitForSubscriptionUpdate ( psA , psB ) ,
134
- waitForSubscriptionUpdate ( psC , psB )
132
+ waitForSubscriptionUpdate ( psA , peerIdB ) ,
133
+ waitForSubscriptionUpdate ( psC , peerIdB )
135
134
] )
136
135
137
136
expect ( psA . getPeers ( ) . length ) . to . equal ( 1 )
@@ -188,9 +187,9 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
188
187
} )
189
188
190
189
await Promise . all ( [
191
- waitForSubscriptionUpdate ( psA , psB ) ,
192
- waitForSubscriptionUpdate ( psB , psA ) ,
193
- waitForSubscriptionUpdate ( psC , psB )
190
+ waitForSubscriptionUpdate ( psA , peerIdB ) ,
191
+ waitForSubscriptionUpdate ( psB , peerIdA ) ,
192
+ waitForSubscriptionUpdate ( psC , peerIdB )
194
193
] )
195
194
196
195
psA . publish ( topic , uint8ArrayFromString ( 'hey' ) )
@@ -260,9 +259,9 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
260
259
psC . subscribe ( topic )
261
260
262
261
await Promise . all ( [
263
- waitForSubscriptionUpdate ( psA , psB ) ,
264
- waitForSubscriptionUpdate ( psB , psA ) ,
265
- waitForSubscriptionUpdate ( psC , psB )
262
+ waitForSubscriptionUpdate ( psA , peerIdB ) ,
263
+ waitForSubscriptionUpdate ( psB , peerIdA ) ,
264
+ waitForSubscriptionUpdate ( psC , peerIdB )
266
265
] )
267
266
268
267
psB . publish ( topic , uint8ArrayFromString ( 'hey' ) )
@@ -307,11 +306,11 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
307
306
// │b d│
308
307
// ◉─┘ └─◉
309
308
// a
310
- let psA : PubSubBaseProtocol
311
- let psB : PubSubBaseProtocol
312
- let psC : PubSubBaseProtocol
313
- let psD : PubSubBaseProtocol
314
- let psE : PubSubBaseProtocol
309
+ let psA : PubSub
310
+ let psB : PubSub
311
+ let psC : PubSub
312
+ let psD : PubSub
313
+ let psE : PubSub
315
314
let peerIdA : PeerId
316
315
let peerIdB : PeerId
317
316
let peerIdC : PeerId
@@ -483,11 +482,11 @@ export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
483
482
} )
484
483
485
484
await Promise . all ( [
486
- waitForSubscriptionUpdate ( psA , psB ) ,
487
- waitForSubscriptionUpdate ( psB , psA ) ,
488
- waitForSubscriptionUpdate ( psC , psB ) ,
489
- waitForSubscriptionUpdate ( psD , psC ) ,
490
- waitForSubscriptionUpdate ( psE , psD )
485
+ waitForSubscriptionUpdate ( psA , peerIdB ) ,
486
+ waitForSubscriptionUpdate ( psB , peerIdA ) ,
487
+ waitForSubscriptionUpdate ( psC , peerIdB ) ,
488
+ waitForSubscriptionUpdate ( psD , peerIdC ) ,
489
+ waitForSubscriptionUpdate ( psE , peerIdD )
491
490
] )
492
491
493
492
psC . publish ( 'Z' , uint8ArrayFromString ( 'hey from c' ) )
0 commit comments