@@ -220,11 +220,14 @@ describe("Waku Filter V2: Subscribe", function () {
220
220
} ) ;
221
221
} ) ;
222
222
223
- it ( "Subscribe to 100 topics at once and receives messages" , async function ( ) {
224
- let topicCount = 30 ;
223
+ it ( "Subscribe to 100 topics (new limit) at once and receives messages" , async function ( ) {
224
+ let topicCount : number ;
225
225
if ( isNwakuAtLeast ( "0.24.0" ) ) {
226
226
this . timeout ( 50000 ) ;
227
227
topicCount = 100 ;
228
+ } else {
229
+ // skipping for old versions where the limit is 30
230
+ this . skip ( ) ;
228
231
}
229
232
const td = generateTestData ( topicCount ) ;
230
233
@@ -255,10 +258,82 @@ describe("Waku Filter V2: Subscribe", function () {
255
258
}
256
259
} ) ;
257
260
258
- it ( "Error when try to subscribe to more than 101 topics" , async function ( ) {
259
- let topicCount = 31 ;
261
+ //TODO: remove test when WAKUNODE_IMAGE is 0.24.0
262
+ it ( "Subscribe to 30 topics (old limit) at once and receives messages" , async function ( ) {
263
+ let topicCount : number ;
264
+ if ( isNwakuAtLeast ( "0.24.0" ) ) {
265
+ // skipping for new versions where the new limit is 100
266
+ this . skip ( ) ;
267
+ } else {
268
+ topicCount = 30 ;
269
+ }
270
+
271
+ const td = generateTestData ( topicCount ) ;
272
+
273
+ await subscription . subscribe ( td . decoders , messageCollector . callback ) ;
274
+
275
+ // Send a unique message on each topic.
276
+ for ( let i = 0 ; i < topicCount ; i ++ ) {
277
+ await waku . lightPush . send ( td . encoders [ i ] , {
278
+ payload : utf8ToBytes ( `Message for Topic ${ i + 1 } ` )
279
+ } ) ;
280
+ }
281
+
282
+ // Open issue here: https://github.com/waku-org/js-waku/issues/1790
283
+ // That's why we use the try catch block
284
+ try {
285
+ // Verify that each message was received on the corresponding topic.
286
+ expect ( await messageCollector . waitForMessages ( topicCount ) ) . to . eq ( true ) ;
287
+ td . contentTopics . forEach ( ( topic , index ) => {
288
+ messageCollector . verifyReceivedMessage ( index , {
289
+ expectedContentTopic : topic ,
290
+ expectedMessageText : `Message for Topic ${ index + 1 } `
291
+ } ) ;
292
+ } ) ;
293
+ } catch ( error ) {
294
+ console . warn (
295
+ "This test still fails because of https://github.com/waku-org/js-waku/issues/1790"
296
+ ) ;
297
+ }
298
+ } ) ;
299
+
300
+ it ( "Error when try to subscribe to more than 101 topics (new limit)" , async function ( ) {
301
+ let topicCount : number ;
260
302
if ( isNwakuAtLeast ( "0.24.0" ) ) {
261
303
topicCount = 101 ;
304
+ } else {
305
+ // skipping for old versions where the limit is 30
306
+ this . skip ( ) ;
307
+ }
308
+ const td = generateTestData ( topicCount ) ;
309
+
310
+ try {
311
+ await subscription . subscribe ( td . decoders , messageCollector . callback ) ;
312
+ throw new Error (
313
+ `Subscribe to ${ topicCount } topics was successful but was expected to fail with a specific error.`
314
+ ) ;
315
+ } catch ( err ) {
316
+ if (
317
+ err instanceof Error &&
318
+ err . message . includes (
319
+ `exceeds maximum content topics: ${ topicCount - 1 } `
320
+ )
321
+ ) {
322
+ return ;
323
+ } else {
324
+ throw err ;
325
+ }
326
+ }
327
+ } ) ;
328
+
329
+ //TODO: remove test when WAKUNODE_IMAGE is 0.24.0
330
+ it ( "Error when try to subscribe to more than 31 topics (old limit)" , async function ( ) {
331
+ let topicCount : number ;
332
+ if ( isNwakuAtLeast ( "0.24.0" ) ) {
333
+ // skipping for new versions where the new limit is 100
334
+ this . skip ( ) ;
335
+ } else {
336
+ topicCount = 31 ;
262
337
}
263
338
const td = generateTestData ( topicCount ) ;
264
339
0 commit comments