chore: use nwaku:v0.27.0 and adjust tests for it (#1975)

* use nwaku:v0.27.0 and adjust tests for it

* fix sharding tests
This commit is contained in:
fbarbu15 2024-04-24 22:30:55 +03:00 committed by GitHub
parent 80a9525157
commit 7ee02faf48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 28 additions and 266 deletions

View File

@ -72,14 +72,14 @@ jobs:
uses: ./.github/workflows/test-node.yml
secrets: inherit
with:
nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.26.0' }}
nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.27.0' }}
test_type: node
allure_reports: true
node_optional:
uses: ./.github/workflows/test-node.yml
with:
nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.26.0' }}
nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.27.0' }}
test_type: node-optional
node_with_nwaku_master:

View File

@ -27,7 +27,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.26.0";
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.27.0";
const isGoWaku = DOCKER_IMAGE_NAME.includes("go-waku");

View File

@ -3,7 +3,7 @@ import { promisify } from "util";
const execAsync = promisify(exec);
const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.26.0";
const WAKUNODE_IMAGE = process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.27.0";
async function main() {
try {

View File

@ -1,9 +1,5 @@
import { Logger } from "@waku/utils";
import { DOCKER_IMAGE_NAME } from "../lib/service_node";
const log = new Logger("test:utils");
// Utility to add test conditions based on nwaku/go-waku versions
export function isNwakuAtLeast(requiredVersion: string): boolean {
const versionRegex = /(?:v)?(\d+\.\d+(?:\.\d+)?)/;
@ -19,16 +15,3 @@ export function isNwakuAtLeast(requiredVersion: string): boolean {
return true;
}
}
// Utility to resolve autosharding cluster ID
export function resolveAutoshardingCluster(clusterId: number): number {
if (isNwakuAtLeast("0.27.0")) {
log.info(`Using clusterID ${clusterId} for autosharding`);
return clusterId;
} else {
// for versions older than 0.27.0 the autosharding cluster was hardcoded to 1
// https://github.com/waku-org/nwaku/pull/2505
log.warn("Falling back to clusterID 1 for autosharding");
return 1;
}
}

View File

@ -19,10 +19,8 @@ import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
isNwakuAtLeast,
makeLogFileName,
MessageCollector,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../../src/index.js";
@ -188,7 +186,7 @@ describe("Waku Filter V2: Multiple PubsubTopics", function () {
describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
// Set the timeout for all tests in this suite. Can be overwritten at test level
this.timeout(30000);
const clusterId = resolveAutoshardingCluster(3);
const clusterId = 3;
let waku: LightNode;
let nwaku: ServiceNode;
let nwaku2: ServiceNode;
@ -232,12 +230,6 @@ describe("Waku Filter V2 (Autosharding): Multiple PubsubTopics", function () {
shard: contentTopicToShardIndex(customContentTopic2)
});
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this.ctx,

View File

@ -20,7 +20,6 @@ import {
beforeEachCustom,
delay,
generateTestData,
isNwakuAtLeast,
makeLogFileName,
MessageCollector,
ServiceNode,
@ -223,53 +222,8 @@ 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;
}
this.timeout(50000);
const topicCount = 100;
const td = generateTestData(topicCount);
await subscription.subscribe(td.decoders, messageCollector.callback);
@ -300,43 +254,7 @@ describe("Waku Filter V2: Subscribe: Single Service Node", function () {
});
it("Error when try to subscribe to more than 101 topics (new limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.25.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.25.0
it("Error when try to subscribe to more than 31 topics (old limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.25.0")) {
// skipping for new versions where the new limit is 100
this.skip();
} else {
topicCount = 31;
}
const topicCount = 101;
const td = generateTestData(topicCount);
try {

View File

@ -19,7 +19,6 @@ import {
beforeEachCustom,
delay,
generateTestData,
isNwakuAtLeast,
ServiceNodesFleet,
TEST_STRING
} from "../../src/index.js";
@ -271,58 +270,8 @@ const runTests = (strictCheckNodes: boolean): void => {
});
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,
serviceNodes.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 serviceNodes.messageCollector.waitForMessages(topicCount)
).to.eq(true);
td.contentTopics.forEach((topic, index) => {
serviceNodes.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;
}
this.timeout(50000);
const topicCount = 100;
const td = generateTestData(topicCount);
await subscription.subscribe(
@ -358,46 +307,7 @@ const runTests = (strictCheckNodes: boolean): void => {
});
it("Error when try to subscribe to more than 101 topics (new limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.25.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,
serviceNodes.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.25.0
it("Error when try to subscribe to more than 31 topics (old limit)", async function () {
let topicCount: number;
if (isNwakuAtLeast("0.25.0")) {
// skipping for new versions where the new limit is 100
this.skip();
} else {
topicCount = 31;
}
const topicCount = 101;
const td = generateTestData(topicCount);
try {

View File

@ -21,9 +21,7 @@ import {
afterEachCustom,
beforeEachCustom,
delay,
isNwakuAtLeast,
makeLogFileName,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../src/index.js";
@ -33,13 +31,7 @@ describe("getConnectedPeersForProtocolAndShard", function () {
let serviceNode1: ServiceNode;
let serviceNode2: ServiceNode;
const contentTopic = "/test/2/waku-light-push/utf8";
const autoshardingClusterId = resolveAutoshardingCluster(6);
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
const autoshardingClusterId = 6;
beforeEachCustom(this, async () => {
serviceNode1 = new ServiceNode(makeLogFileName(this.ctx) + "1");

View File

@ -19,10 +19,8 @@ import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
isNwakuAtLeast,
makeLogFileName,
MessageCollector,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../../src/index.js";
@ -179,7 +177,7 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
let nwaku2: ServiceNode;
let messageCollector: MessageCollector;
const clusterId = resolveAutoshardingCluster(4);
const clusterId = 4;
const customContentTopic1 = "/waku/2/content/test.js";
const customContentTopic2 = "/myapp/1/latest/proto";
const autoshardingPubsubTopic1 = contentTopicToPubsubTopic(
@ -205,12 +203,6 @@ describe("Waku Light Push (Autosharding): Multiple PubsubTopics", function () {
let nimPeerId: PeerId;
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
beforeEachCustom(this, async () => {
[nwaku, waku] = await runNodes(
this.ctx,

View File

@ -75,12 +75,12 @@ describe("Metadata Protocol", function () {
it("same cluster, different shard: nodes connect", async function () {
const shardInfo1: ShardInfo = {
clusterId: 0,
clusterId: 2,
shards: [1]
};
const shardInfo2: ShardInfo = {
clusterId: 0,
clusterId: 2,
shards: [2]
};

View File

@ -26,7 +26,6 @@ import {
NOISE_KEY_1,
NOISE_KEY_2,
NOISE_KEY_3,
resolveAutoshardingCluster,
tearDownNodes
} from "../../src/index.js";
import { TestDecoder } from "../filter/utils.js";
@ -318,7 +317,7 @@ describe("Waku Relay, multiple pubsub topics", function () {
describe("Waku Relay (Autosharding), multiple pubsub topics", function () {
this.timeout(15000);
const clusterId = resolveAutoshardingCluster(7);
const clusterId = 7;
let waku1: RelayNode;
let waku2: RelayNode;
let waku3: RelayNode;

View File

@ -19,18 +19,13 @@ import {
} from "@waku/utils";
import { expect } from "chai";
import {
makeLogFileName,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../src";
import { makeLogFileName, ServiceNode, tearDownNodes } from "../../src";
// skipped: https://github.com/waku-org/js-waku/issues/1914
describe.skip("SDK: Creating by Content Topic", function () {
const ContentTopic = "/myapp/1/latest/proto";
const testMessage = "Test123";
const clusterId = resolveAutoshardingCluster(2);
const clusterId = 2;
let nwaku: ServiceNode;
let waku: LightNode;
let waku2: LightNode;

View File

@ -14,10 +14,8 @@ import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
isNwakuAtLeast,
makeLogFileName,
MessageCollector,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../src/index.js";
@ -27,17 +25,11 @@ const ContentTopic2 = "/myapp/1/latest/proto";
describe("Autosharding: Running Nodes", function () {
this.timeout(50000);
const clusterId = resolveAutoshardingCluster(10);
const clusterId = 10;
let waku: LightNode;
let nwaku: ServiceNode;
let messageCollector: MessageCollector;
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
messageCollector = new MessageCollector(nwaku);
@ -49,7 +41,6 @@ describe("Autosharding: Running Nodes", function () {
describe("Different clusters and topics", function () {
// js-waku allows autosharding for cluster IDs different than 1
// we have 2 dedicated tests for this case
it("Cluster ID 0 - Default/Global Cluster", async function () {
const clusterId = 0;
const pubsubTopics = [contentTopicToPubsubTopic(ContentTopic, clusterId)];
@ -61,6 +52,8 @@ describe("Autosharding: Running Nodes", function () {
pubsubTopic: pubsubTopics
});
await nwaku.ensureSubscriptions(pubsubTopics);
waku = await createLightNode({
shardInfo: {
clusterId: clusterId,
@ -90,7 +83,7 @@ describe("Autosharding: Running Nodes", function () {
).to.eq(true);
});
it("Non Autosharding Cluster", async function () {
it("Non TWN Cluster", async function () {
const clusterId = 5;
const pubsubTopics = [contentTopicToPubsubTopic(ContentTopic, clusterId)];
await nwaku.start({
@ -101,6 +94,8 @@ describe("Autosharding: Running Nodes", function () {
pubsubTopic: pubsubTopics
});
await nwaku.ensureSubscriptions(pubsubTopics);
waku = await createLightNode({
shardInfo: {
clusterId: clusterId,

View File

@ -20,9 +20,7 @@ import {
afterEachCustom,
beforeEachCustom,
delay,
isNwakuAtLeast,
makeLogFileName,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../src/index.js";
@ -208,13 +206,7 @@ describe("Static Sharding: Peer Management", function () {
describe("Autosharding: Peer Management", function () {
const ContentTopic = "/myapp/1/latest/proto";
const clusterId = resolveAutoshardingCluster(8);
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
const clusterId = 8;
describe("Peer Exchange", function () {
let waku: LightNode;

View File

@ -69,6 +69,8 @@ describe("Static Sharding: Running Nodes", function () {
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
});
await nwaku.ensureSubscriptions(shardInfoToPubsubTopics(shardInfo));
waku = await createLightNode({
shardInfo: shardInfo
});

View File

@ -11,10 +11,8 @@ import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
isNwakuAtLeast,
makeLogFileName,
NOISE_KEY_1,
resolveAutoshardingCluster,
ServiceNode,
tearDownNodes
} from "../../src/index.js";
@ -190,7 +188,7 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
const customContentTopic1 = "/waku/2/content/utf8";
const customContentTopic2 = "/myapp/1/latest/proto";
const clusterId = resolveAutoshardingCluster(5);
const clusterId = 5;
const autoshardingPubsubTopic1 = contentTopicToPubsubTopic(
customContentTopic1,
clusterId
@ -216,12 +214,6 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
contentTopics: [customContentTopic1, customContentTopic2]
};
before(async () => {
if (!isNwakuAtLeast("0.27.0")) {
this.ctx.skip();
}
});
beforeEachCustom(this, async () => {
nwaku = new ServiceNode(makeLogFileName(this.ctx));
await nwaku.start({