@@ -40,14 +40,16 @@ describe('gossip', () => {
4040 this . timeout ( 10e4 )
4141 const nodeA = nodes [ 0 ]
4242 const topic = 'Z'
43+
44+ const subscriptionPromises = nodes . map ( async ( n ) => await pEvent ( n . pubsub , 'subscription-change' ) )
4345 // add subscriptions to each node
4446 nodes . forEach ( ( n ) => n . pubsub . subscribe ( topic ) )
4547
4648 // every node connected to every other
4749 await connectAllPubSubNodes ( nodes )
4850
4951 // wait for subscriptions to be transmitted
50- await Promise . all ( nodes . map ( async ( n ) => await pEvent ( n . pubsub , 'subscription-change' ) ) )
52+ await Promise . all ( subscriptionPromises )
5153
5254 // await mesh rebalancing
5355 await Promise . all ( nodes . map ( async ( n ) => await pEvent ( n . pubsub , 'gossipsub:heartbeat' ) ) )
@@ -87,14 +89,15 @@ describe('gossip', () => {
8789
8890 const twoNodes = [ nodeA , nodeB ]
8991 const topic = 'Z'
92+ const subscriptionPromises = twoNodes . map ( async ( n ) => await pEvent ( n . pubsub , 'subscription-change' ) )
9093 // add subscriptions to each node
9194 twoNodes . forEach ( ( n ) => n . pubsub . subscribe ( topic ) )
9295
9396 // every node connected to every other
9497 await connectAllPubSubNodes ( twoNodes )
9598
9699 // wait for subscriptions to be transmitted
97- await Promise . all ( twoNodes . map ( async ( n ) => await pEvent ( n . pubsub , 'subscription-change' ) ) )
100+ await Promise . all ( subscriptionPromises )
98101
99102 // await mesh rebalancing
100103 await Promise . all ( twoNodes . map ( async ( n ) => await pEvent ( n . pubsub , 'gossipsub:heartbeat' ) ) )
0 commit comments