Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: split 100 topics tests in old and new behaviour #1803

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a todo to remove old tests?
Are there any other tests that might need to be changed/removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TODO
No, only those tests are affected afaik

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
Loading