Skip to content

Commit

Permalink
Merge branch 'master' of github.com:waku-org/js-waku into feat/redund…
Browse files Browse the repository at this point in the history
…ant-sdk
  • Loading branch information
danisharora099 committed Jan 24, 2024
2 parents bb99724 + 3e7b95e commit 86642a0
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 84 deletions.
161 changes: 82 additions & 79 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"dependencies": {
"@chainsafe/libp2p-noise": "^14.1.0",
"@libp2p/identify": "^1.0.10",
"@libp2p/identify": "^1.0.11",
"@libp2p/mplex": "^10.0.12",
"@libp2p/ping": "^1.0.9",
"@libp2p/websockets": "^8.0.11",
Expand Down
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 @@ -224,11 +224,14 @@ describe("Waku Filter V2: Subscribe: Single Service Node", 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 @@ -259,10 +262,82 @@ describe("Waku Filter V2: Subscribe: Single Service Node", 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 86642a0

Please sign in to comment.