Skip to content

Commit

Permalink
chore: split 100 topics tests in old and new behaviour (#1803)
Browse files Browse the repository at this point in the history
* chore: split 100 topics tests in old and new behavioud

* add remove test TODO
  • Loading branch information
fbarbu15 authored Jan 22, 2024
1 parent 09295c7 commit 3e7b95e
Showing 1 changed file with 79 additions and 4 deletions.
83 changes: 79 additions & 4 deletions packages/tests/tests/filter/single_node/subscribe.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,14 @@ describe("Waku Filter V2: Subscribe", function () {
});
});

it("Subscribe to 100 topics at once and receives messages", async function () {
let topicCount = 30;
it("Subscribe to 100 topics (new limit) at once and receives messages", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.24.0")) {
this.timeout(50000);
topicCount = 100;
} else {
// skipping for old versions where the limit is 30
this.skip();
}
const td = generateTestData(topicCount);

Expand Down Expand Up @@ -255,10 +258,82 @@ describe("Waku Filter V2: Subscribe", function () {
}
});

it("Error when try to subscribe to more than 101 topics", async function () {
let topicCount = 31;
//TODO: remove test when WAKUNODE_IMAGE is 0.24.0
it("Subscribe to 30 topics (old limit) at once and receives messages", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.24.0")) {
// skipping for new versions where the new limit is 100
this.skip();
} else {
topicCount = 30;
}

const td = generateTestData(topicCount);

await subscription.subscribe(td.decoders, messageCollector.callback);

// Send a unique message on each topic.
for (let i = 0; i < topicCount; i++) {
await waku.lightPush.send(td.encoders[i], {
payload: utf8ToBytes(`Message for Topic ${i + 1}`)
});
}

// Open issue here: https://github.com/waku-org/js-waku/issues/1790
// That's why we use the try catch block
try {
// Verify that each message was received on the corresponding topic.
expect(await messageCollector.waitForMessages(topicCount)).to.eq(true);
td.contentTopics.forEach((topic, index) => {
messageCollector.verifyReceivedMessage(index, {
expectedContentTopic: topic,
expectedMessageText: `Message for Topic ${index + 1}`
});
});
} catch (error) {
console.warn(
"This test still fails because of https://github.com/waku-org/js-waku/issues/1790"
);
}
});

it("Error when try to subscribe to more than 101 topics (new limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.24.0")) {
topicCount = 101;
} else {
// skipping for old versions where the limit is 30
this.skip();
}
const td = generateTestData(topicCount);

try {
await subscription.subscribe(td.decoders, messageCollector.callback);
throw new Error(
`Subscribe to ${topicCount} topics was successful but was expected to fail with a specific error.`
);
} catch (err) {
if (
err instanceof Error &&
err.message.includes(
`exceeds maximum content topics: ${topicCount - 1}`
)
) {
return;
} else {
throw err;
}
}
});

//TODO: remove test when WAKUNODE_IMAGE is 0.24.0
it("Error when try to subscribe to more than 31 topics (old limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.24.0")) {
// skipping for new versions where the new limit is 100
this.skip();
} else {
topicCount = 31;
}
const td = generateTestData(topicCount);

Expand Down

0 comments on commit 3e7b95e

Please sign in to comment.