mirror of https://github.com/status-im/js-waku.git
chore: split 100 topics tests in old and new behaviour (#1803)
* chore: split 100 topics tests in old and new behavioud * add remove test TODO
This commit is contained in:
parent
09295c76a2
commit
3e7b95e604
|
@ -220,11 +220,14 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Subscribe to 100 topics at once and receives messages", async function () {
|
it("Subscribe to 100 topics (new limit) at once and receives messages", async function () {
|
||||||
let topicCount = 30;
|
let topicCount: number;
|
||||||
if (isNwakuAtLeast("0.24.0")) {
|
if (isNwakuAtLeast("0.24.0")) {
|
||||||
this.timeout(50000);
|
this.timeout(50000);
|
||||||
topicCount = 100;
|
topicCount = 100;
|
||||||
|
} else {
|
||||||
|
// skipping for old versions where the limit is 30
|
||||||
|
this.skip();
|
||||||
}
|
}
|
||||||
const td = generateTestData(topicCount);
|
const td = generateTestData(topicCount);
|
||||||
|
|
||||||
|
@ -255,10 +258,82 @@ describe("Waku Filter V2: Subscribe", function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Error when try to subscribe to more than 101 topics", async function () {
|
//TODO: remove test when WAKUNODE_IMAGE is 0.24.0
|
||||||
let topicCount = 31;
|
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")) {
|
if (isNwakuAtLeast("0.24.0")) {
|
||||||
topicCount = 101;
|
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);
|
const td = generateTestData(topicCount);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue