Skip to content

Commit

Permalink
chore: run 100 topics test
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Feb 19, 2024
1 parent 199f6ab commit 237fb36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 67 deletions.
2 changes: 1 addition & 1 deletion packages/tests/src/lib/service_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const WAKU_SERVICE_NODE_PARAMS =
const NODE_READY_LOG_LINE = "Node setup complete";

export const DOCKER_IMAGE_NAME =
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.24.0";
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.25.0";

const isGoWaku = DOCKER_IMAGE_NAME.includes("go-waku");

Expand Down
2 changes: 1 addition & 1 deletion packages/tests/src/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { promisify } from "util";

const execAsync = promisify(exec);

const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.24.0";
const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.25.0";

async function main() {
try {
Expand Down
86 changes: 21 additions & 65 deletions packages/tests/tests/filter/single_node/subscribe.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,81 +222,37 @@ describe("Waku Filter V2: Subscribe: Single Service Node", function () {
});
});

it("Subscribe to 100 topics (new limit) at once and receives messages", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.25.0")) {
this.timeout(50000);
topicCount = 100;
} else {
// skipping for old versions where the limit is 30
this.skip();
}
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"
);
}
});

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

const td = generateTestData(topicCount);

console.log("subscribing");
await subscription.subscribe(td.decoders, messageCollector.callback);
console.log("subscribed");

// 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}`)
});
console.log("sending msg, ", i);
try {
await waku.lightPush.send(td.encoders[i], {
payload: utf8ToBytes(`Message for Topic ${i + 1}`)
});
} catch (error) {
console.error("error on send ", i + 1, error);
}
if (i % 10 === 0) await delay(2000);
}

// 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}`
});
// 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 () {
Expand Down

0 comments on commit 237fb36

Please sign in to comment.