mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-14 19:53:12 +00:00
chore: update sharding tests
This commit is contained in:
parent
d7d60f2c67
commit
87d09f0f41
@ -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.31.0";
|
||||
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.34.0";
|
||||
|
||||
const isGoWaku = DOCKER_IMAGE_NAME.includes("go-waku");
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import {
|
||||
|
||||
// These tests are expected to fail as service nodes now require at least one more connected node: https://github.com/waku-org/nwaku/pull/2951/files
|
||||
|
||||
describe.only("Waku Light Push: Single Node: Fails as expected", function () {
|
||||
describe("Waku Light Push: Single Node: Fails as expected", function () {
|
||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { LightNode, ProtocolError, Protocols } from "@waku/interfaces";
|
||||
import { LightNode, ProtocolError } from "@waku/interfaces";
|
||||
import { createEncoder, createLightNode, utf8ToBytes } from "@waku/sdk";
|
||||
import {
|
||||
contentTopicToPubsubTopic,
|
||||
@ -8,10 +8,8 @@ import { expect } from "chai";
|
||||
|
||||
import {
|
||||
afterEachCustom,
|
||||
beforeEachCustom,
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
ServiceNode,
|
||||
runMultipleNodes,
|
||||
ServiceNodesFleet,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
@ -22,41 +20,33 @@ describe("Autosharding: Running Nodes", function () {
|
||||
this.timeout(50000);
|
||||
const clusterId = 10;
|
||||
let waku: LightNode;
|
||||
let nwaku: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
beforeEachCustom(this, async () => {
|
||||
nwaku = new ServiceNode(makeLogFileName(this.ctx));
|
||||
messageCollector = new MessageCollector(nwaku);
|
||||
});
|
||||
let serviceNodes: ServiceNodesFleet;
|
||||
|
||||
afterEachCustom(this, async () => {
|
||||
await tearDownNodes(nwaku, waku);
|
||||
await tearDownNodes(serviceNodes.nodes, waku);
|
||||
});
|
||||
|
||||
describe("Different clusters and topics", function () {
|
||||
// js-waku allows autosharding for cluster IDs different than 1
|
||||
it("Cluster ID 0 - Default/Global Cluster", async function () {
|
||||
const clusterId = 0;
|
||||
const pubsubTopics = [contentTopicToPubsubTopic(ContentTopic, clusterId)];
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: pubsubTopics
|
||||
});
|
||||
|
||||
await nwaku.ensureSubscriptions(pubsubTopics);
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
{
|
||||
clusterId,
|
||||
contentTopics: [ContentTopic]
|
||||
}
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
},
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: pubsubTopics
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -70,9 +60,10 @@ describe("Autosharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
|
||||
console.log("good");
|
||||
expect(
|
||||
await messageCollector.waitForMessagesAutosharding(1, {
|
||||
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
|
||||
contentTopic: ContentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -81,24 +72,23 @@ describe("Autosharding: Running Nodes", function () {
|
||||
it("Non TWN Cluster", async function () {
|
||||
const clusterId = 5;
|
||||
const pubsubTopics = [contentTopicToPubsubTopic(ContentTopic, clusterId)];
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: pubsubTopics
|
||||
});
|
||||
|
||||
await nwaku.ensureSubscriptions(pubsubTopics);
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
{
|
||||
clusterId,
|
||||
contentTopics: [ContentTopic]
|
||||
}
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
},
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: pubsubTopics
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -112,9 +102,9 @@ describe("Autosharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
|
||||
expect(
|
||||
await messageCollector.waitForMessagesAutosharding(1, {
|
||||
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
|
||||
contentTopic: ContentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -138,24 +128,23 @@ describe("Autosharding: Running Nodes", function () {
|
||||
contentTopicToPubsubTopic(ContentTopic, clusterId)
|
||||
];
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic]
|
||||
});
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
{
|
||||
clusterId,
|
||||
contentTopics: [ContentTopic]
|
||||
}
|
||||
});
|
||||
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
},
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic]
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -169,9 +158,9 @@ describe("Autosharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
|
||||
expect(
|
||||
await messageCollector.waitForMessagesAutosharding(1, {
|
||||
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
|
||||
contentTopic: ContentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -201,24 +190,23 @@ describe("Autosharding: Running Nodes", function () {
|
||||
contentTopicToPubsubTopic(ContentTopic2, clusterId)
|
||||
];
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic, ContentTopic2]
|
||||
});
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
// For autosharding, we configure multiple pubsub topics by using two content topics that hash to different shards
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
{
|
||||
clusterId,
|
||||
contentTopics: [ContentTopic, ContentTopic2]
|
||||
}
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
},
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic, ContentTopic2]
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder1 = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -239,9 +227,9 @@ describe("Autosharding: Running Nodes", function () {
|
||||
const request1 = await waku.lightPush.send(encoder1, {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
expect(request1.successes.length).to.eq(1);
|
||||
expect(request1.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
|
||||
expect(
|
||||
await messageCollector.waitForMessagesAutosharding(1, {
|
||||
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
|
||||
contentTopic: ContentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -249,9 +237,9 @@ describe("Autosharding: Running Nodes", function () {
|
||||
const request2 = await waku.lightPush.send(encoder2, {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
expect(request2.successes.length).to.eq(1);
|
||||
expect(request2.successes.length).to.eq(2); // Expect 2 successes for 2 nodes
|
||||
expect(
|
||||
await messageCollector.waitForMessagesAutosharding(1, {
|
||||
await serviceNodes.messageCollector.waitForMessagesAutosharding(1, {
|
||||
contentTopic: ContentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -259,21 +247,24 @@ describe("Autosharding: Running Nodes", function () {
|
||||
|
||||
it("using a protocol with unconfigured pubsub topic should fail", async function () {
|
||||
const pubsubTopics = [contentTopicToPubsubTopic(ContentTopic, clusterId)];
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic]
|
||||
});
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
{
|
||||
clusterId,
|
||||
contentTopics: [ContentTopic]
|
||||
}
|
||||
});
|
||||
},
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: pubsubTopics,
|
||||
contentTopic: [ContentTopic]
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
// use a content topic that is not configured
|
||||
const encoder = createEncoder({
|
||||
@ -288,17 +279,17 @@ describe("Autosharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
if (successes.length > 0 || failures?.length === 0) {
|
||||
if (successes.length > 0 || !failures?.length) {
|
||||
throw new Error("The request should've thrown an error");
|
||||
}
|
||||
|
||||
const errors = failures?.map((failure) => failure.error);
|
||||
const errors = failures.map((failure) => failure.error);
|
||||
expect(errors).to.include(ProtocolError.TOPIC_NOT_CONFIGURED);
|
||||
});
|
||||
|
||||
it("start node with empty content topic", async function () {
|
||||
try {
|
||||
waku = await createLightNode({
|
||||
await createLightNode({
|
||||
networkConfig: {
|
||||
clusterId: clusterId,
|
||||
contentTopics: []
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import {
|
||||
LightNode,
|
||||
ProtocolError,
|
||||
Protocols,
|
||||
ShardInfo,
|
||||
SingleShardInfo
|
||||
} from "@waku/interfaces";
|
||||
@ -15,10 +14,8 @@ import { expect } from "chai";
|
||||
|
||||
import {
|
||||
afterEachCustom,
|
||||
beforeEachCustom,
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
ServiceNode,
|
||||
runMultipleNodes,
|
||||
ServiceNodesFleet,
|
||||
tearDownNodes
|
||||
} from "../../src/index.js";
|
||||
|
||||
@ -27,16 +24,10 @@ const ContentTopic = "/waku/2/content/test.js";
|
||||
describe("Static Sharding: Running Nodes", function () {
|
||||
this.timeout(15_000);
|
||||
let waku: LightNode;
|
||||
let nwaku: ServiceNode;
|
||||
let messageCollector: MessageCollector;
|
||||
|
||||
beforeEachCustom(this, async () => {
|
||||
nwaku = new ServiceNode(makeLogFileName(this.ctx));
|
||||
messageCollector = new MessageCollector(nwaku);
|
||||
});
|
||||
let serviceNodes: ServiceNodesFleet;
|
||||
|
||||
afterEachCustom(this, async () => {
|
||||
await tearDownNodes(nwaku, waku);
|
||||
await tearDownNodes(serviceNodes.nodes, waku);
|
||||
});
|
||||
|
||||
describe("Different clusters and shards", function () {
|
||||
@ -44,20 +35,19 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
const singleShardInfo = { clusterId: 0, shard: 0 };
|
||||
const shardInfo = singleShardInfosToShardInfo([singleShardInfo]);
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
});
|
||||
|
||||
await nwaku.ensureSubscriptions(shardInfoToPubsubTopics(shardInfo));
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: shardInfo
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
shardInfo,
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -71,33 +61,31 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2);
|
||||
expect(
|
||||
await messageCollector.waitForMessages(1, {
|
||||
await serviceNodes.messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)[0]
|
||||
})
|
||||
).to.eq(true);
|
||||
});
|
||||
|
||||
// dedicated test for Default Cluster ID 0
|
||||
it("Cluster ID 0 - Default/Global Cluster", async function () {
|
||||
const singleShardInfo = { clusterId: 0, shard: 1 };
|
||||
const shardInfo = singleShardInfosToShardInfo([singleShardInfo]);
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
});
|
||||
|
||||
await nwaku.ensureSubscriptions(shardInfoToPubsubTopics(shardInfo));
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: shardInfo
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
shardInfo,
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -108,9 +96,9 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2);
|
||||
expect(
|
||||
await messageCollector.waitForMessages(1, {
|
||||
await serviceNodes.messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)[0]
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -120,33 +108,29 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
for (let i = 0; i < numTest; i++) {
|
||||
// Random clusterId between 2 and 1000
|
||||
const clusterId = Math.floor(Math.random() * 999) + 2;
|
||||
|
||||
// Random shardId between 1 and 1000
|
||||
const shardId = Math.floor(Math.random() * 1000) + 1;
|
||||
|
||||
it(`random static sharding ${
|
||||
i + 1
|
||||
} - Cluster ID: ${clusterId}, Shard ID: ${shardId}`, async function () {
|
||||
afterEach(async () => {
|
||||
await tearDownNodes(nwaku, waku);
|
||||
});
|
||||
|
||||
const singleShardInfo = { clusterId: clusterId, shard: shardId };
|
||||
const shardInfo = singleShardInfosToShardInfo([singleShardInfo]);
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
});
|
||||
|
||||
waku = await createLightNode({
|
||||
networkConfig: shardInfo
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
shardInfo,
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -157,9 +141,9 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
expect(request.successes.length).to.eq(1);
|
||||
expect(request.successes.length).to.eq(2);
|
||||
expect(
|
||||
await messageCollector.waitForMessages(1, {
|
||||
await serviceNodes.messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)[0]
|
||||
})
|
||||
).to.eq(true);
|
||||
@ -169,12 +153,14 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
|
||||
describe("Others", function () {
|
||||
const clusterId = 2;
|
||||
let shardInfo: ShardInfo;
|
||||
|
||||
const shardInfoFirstShard: ShardInfo = {
|
||||
clusterId: clusterId,
|
||||
shards: [2]
|
||||
};
|
||||
const shardInfoSecondShard: ShardInfo = {
|
||||
clusterId: clusterId,
|
||||
shards: [3]
|
||||
};
|
||||
const shardInfoBothShards: ShardInfo = {
|
||||
clusterId: clusterId,
|
||||
shards: [2, 3]
|
||||
@ -188,31 +174,21 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
shard: 3
|
||||
};
|
||||
|
||||
beforeEachCustom(this, async () => {
|
||||
shardInfo = {
|
||||
clusterId: clusterId,
|
||||
shards: [2]
|
||||
};
|
||||
|
||||
await nwaku.start({
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
||||
});
|
||||
});
|
||||
|
||||
afterEachCustom(this, async () => {
|
||||
await tearDownNodes(nwaku, waku);
|
||||
});
|
||||
|
||||
it("configure the node with multiple pubsub topics", async function () {
|
||||
waku = await createLightNode({
|
||||
networkConfig: shardInfoBothShards
|
||||
});
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.LightPush]);
|
||||
it.only("configure the node with multiple pubsub topics", async function () {
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
shardInfoBothShards,
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfoBothShards)
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
const encoder1 = createEncoder({
|
||||
contentTopic: ContentTopic,
|
||||
@ -227,29 +203,40 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
const request1 = await waku.lightPush.send(encoder1, {
|
||||
payload: utf8ToBytes("Hello World2")
|
||||
});
|
||||
expect(request1.successes.length).to.eq(1);
|
||||
expect(request1.successes.length).to.eq(2);
|
||||
expect(
|
||||
await messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)[0]
|
||||
await serviceNodes.messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfoFirstShard)[0]
|
||||
})
|
||||
).to.eq(true);
|
||||
|
||||
const request2 = await waku.lightPush.send(encoder2, {
|
||||
payload: utf8ToBytes("Hello World3")
|
||||
});
|
||||
expect(request2.successes.length).to.eq(1);
|
||||
expect(request2.successes.length).to.eq(2);
|
||||
expect(
|
||||
await messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)[0]
|
||||
await serviceNodes.messageCollector.waitForMessages(1, {
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfoSecondShard)[0]
|
||||
})
|
||||
).to.eq(true);
|
||||
});
|
||||
|
||||
it("using a protocol with unconfigured pubsub topic should fail", async function () {
|
||||
this.timeout(15_000);
|
||||
waku = await createLightNode({
|
||||
networkConfig: shardInfoFirstShard
|
||||
});
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
shardInfoFirstShard,
|
||||
{
|
||||
store: true,
|
||||
lightpush: true,
|
||||
relay: true,
|
||||
clusterId: clusterId,
|
||||
pubsubTopic: shardInfoToPubsubTopics(shardInfoFirstShard)
|
||||
},
|
||||
false,
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
// use a pubsub topic that is not configured
|
||||
const encoder = createEncoder({
|
||||
@ -261,17 +248,17 @@ describe("Static Sharding: Running Nodes", function () {
|
||||
payload: utf8ToBytes("Hello World")
|
||||
});
|
||||
|
||||
if (successes.length > 0 || failures?.length === 0) {
|
||||
if (successes.length > 0 || !failures?.length) {
|
||||
throw new Error("The request should've thrown an error");
|
||||
}
|
||||
|
||||
const errors = failures?.map((failure) => failure.error);
|
||||
const errors = failures.map((failure) => failure.error);
|
||||
expect(errors).to.include(ProtocolError.TOPIC_NOT_CONFIGURED);
|
||||
});
|
||||
|
||||
it("start node with empty shard should fail", async function () {
|
||||
try {
|
||||
waku = await createLightNode({
|
||||
await createLightNode({
|
||||
networkConfig: { clusterId: clusterId, shards: [] }
|
||||
});
|
||||
throw new Error(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user