mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-05-06 02:09:30 +00:00
Concepts are being mixed up between the global network config (static vs auto sharding), that needs to be the same of all nodes in the network, individual node configuration (eg relay node subscribing to a given shard), and the routing characteristic of a specific message (eg pubsub topic, shard). This stops proper configuration of nwaku post 0.36.0 because we know need to be deliberate on whether nwaku nodes are running with auto or static sharding. It also included various back and forth conversions between shards, pubsub topics, etc. With this change, we tidy up the network configuration, and make it explicit whether it is static or auto sharded. We also introduce the concept of routing info, which is specific to a message, and tied to the overall network configuration. Routing info abstract pubsub topic, shard, and autosharding needs. Which should lead to easier tidy up of the pubsub concept at a later stage. # Conflicts: # packages/core/src/lib/connection_manager/connection_manager.ts # packages/core/src/lib/metadata/metadata.ts # packages/interfaces/src/metadata.ts # packages/interfaces/src/sharding.ts # packages/relay/src/create.ts # packages/sdk/src/filter/filter.ts # packages/sdk/src/filter/types.ts # packages/sdk/src/light_push/light_push.spec.ts # packages/tests/tests/sharding/auto_sharding.spec.ts # packages/tests/tests/sharding/static_sharding.spec.ts # Conflicts: # packages/sdk/src/store/store.ts
145 lines
4.6 KiB
TypeScript
145 lines
4.6 KiB
TypeScript
// TODO: This test is useless because the content topics all start
|
|
// with `/test/` meaning they are in the same shard
|
|
|
|
// import { createEncoder } from "@waku/core";
|
|
// import { LightNode, Protocols } from "@waku/interfaces";
|
|
// import { contentTopicToPubsubTopic } from "@waku/utils";
|
|
// import { utf8ToBytes } from "@waku/utils/bytes";
|
|
// import { expect } from "chai";
|
|
//
|
|
// import {
|
|
// afterEachCustom,
|
|
// beforeEachCustom,
|
|
// makeLogFileName,
|
|
// MessageCollector,
|
|
// runMultipleNodes,
|
|
// ServiceNode,
|
|
// ServiceNodesFleet,
|
|
// tearDownNodes,
|
|
// teardownNodesWithRedundancy
|
|
// } from "../../src/index.js";
|
|
//
|
|
// import { TestClusterId, TestEncoder } from "./utils.js";
|
|
//
|
|
// describe("Waku Light Push (Autosharding): Multiple Shards", function () {
|
|
// this.timeout(30000);
|
|
// const numServiceNodes = 2;
|
|
//
|
|
// let waku: LightNode;
|
|
// let serviceNodes: ServiceNodesFleet;
|
|
//
|
|
// const customEncoder2 = createEncoder({
|
|
// contentTopic: "/test/2/waku-light-push/utf8",
|
|
// pubsubTopic: contentTopicToPubsubTopic(
|
|
// "/test/2/waku-light-push/utf8",
|
|
// TestClusterId
|
|
// )
|
|
// });
|
|
//
|
|
// beforeEachCustom(this, async () => {
|
|
// [serviceNodes, waku] = await runMultipleNodes(
|
|
// this.ctx,
|
|
// {
|
|
// clusterId: TestClusterId,
|
|
// contentTopics: [TestEncoder.contentTopic, customEncoder2.contentTopic]
|
|
// },
|
|
// { lightpush: true, filter: true },
|
|
// false,
|
|
// numServiceNodes,
|
|
// false
|
|
// );
|
|
// });
|
|
//
|
|
// afterEachCustom(this, async () => {
|
|
// await teardownNodesWithRedundancy(serviceNodes, waku);
|
|
// });
|
|
//
|
|
// it("Subscribe and receive messages on 2 different pubsubtopics", async function () {
|
|
// const pushResponse1 = await waku.lightPush.send(TestEncoder, {
|
|
// payload: utf8ToBytes("M1")
|
|
// });
|
|
// const pushResponse2 = await waku.lightPush.send(customEncoder2, {
|
|
// payload: utf8ToBytes("M2")
|
|
// });
|
|
//
|
|
// expect(pushResponse1.successes.length).to.eq(numServiceNodes);
|
|
// expect(pushResponse2.successes.length).to.eq(numServiceNodes);
|
|
//
|
|
// const messageCollector1 = new MessageCollector(serviceNodes.nodes[0]);
|
|
// const messageCollector2 = new MessageCollector(serviceNodes.nodes[1]);
|
|
//
|
|
// expect(
|
|
// await messageCollector1.waitForMessages(1, {
|
|
// pubsubTopic: TestEncoder.pubsubTopic
|
|
// })
|
|
// ).to.eq(true);
|
|
//
|
|
// expect(
|
|
// await messageCollector2.waitForMessages(1, {
|
|
// pubsubTopic: customEncoder2.pubsubTopic
|
|
// })
|
|
// ).to.eq(true);
|
|
//
|
|
// messageCollector1.verifyReceivedMessage(0, {
|
|
// expectedMessageText: "M1",
|
|
// expectedContentTopic: TestEncoder.contentTopic,
|
|
// expectedPubsubTopic: TestEncoder.pubsubTopic
|
|
// });
|
|
//
|
|
// messageCollector2.verifyReceivedMessage(0, {
|
|
// expectedMessageText: "M2",
|
|
// expectedContentTopic: customEncoder2.contentTopic,
|
|
// expectedPubsubTopic: customEncoder2.pubsubTopic
|
|
// });
|
|
// });
|
|
//
|
|
// it("Light push messages to 2 nwaku nodes each with different pubsubtopics", async function () {
|
|
// // Set up and start a new nwaku node with Default PubsubTopic
|
|
// const nwaku2 = new ServiceNode(makeLogFileName(this) + "3");
|
|
//
|
|
// try {
|
|
// await nwaku2.start({
|
|
// filter: true,
|
|
// lightpush: true,
|
|
// relay: true,
|
|
// clusterId: TestClusterId,
|
|
// shard: [2]
|
|
// });
|
|
// await nwaku2.ensureSubscriptionsAutosharding([
|
|
// customEncoder2.pubsubTopic
|
|
// ]);
|
|
// await waku.dial(await nwaku2.getMultiaddrWithId());
|
|
// await waku.waitForPeers([Protocols.LightPush]);
|
|
//
|
|
// const messageCollector2 = new MessageCollector(nwaku2);
|
|
//
|
|
// await waku.lightPush.send(TestEncoder, {
|
|
// payload: utf8ToBytes("M1")
|
|
// });
|
|
// await waku.lightPush.send(customEncoder2, {
|
|
// payload: utf8ToBytes("M2")
|
|
// });
|
|
//
|
|
// await serviceNodes.messageCollector.waitForMessages(1, {
|
|
// pubsubTopic: TestEncoder.pubsubTopic
|
|
// });
|
|
// await messageCollector2.waitForMessagesAutosharding(1, {
|
|
// contentTopic: customEncoder2.contentTopic
|
|
// });
|
|
//
|
|
// serviceNodes.messageCollector.verifyReceivedMessage(0, {
|
|
// expectedMessageText: "M1",
|
|
// expectedContentTopic: TestEncoder.contentTopic,
|
|
// expectedPubsubTopic: TestEncoder.pubsubTopic
|
|
// });
|
|
// messageCollector2.verifyReceivedMessage(0, {
|
|
// expectedMessageText: "M2",
|
|
// expectedContentTopic: customEncoder2.contentTopic,
|
|
// expectedPubsubTopic: customEncoder2.pubsubTopic
|
|
// });
|
|
// } catch (e) {
|
|
// await tearDownNodes([nwaku2], []);
|
|
// }
|
|
// });
|
|
// });
|