mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-23 02:13:14 +00:00
re-enable commented test
This commit is contained in:
parent
ec8ded9c6a
commit
b51d598581
@ -1,144 +1,153 @@
|
||||
// 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 { createRoutingInfo } from "@waku/utils";
|
||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||
import { expect } from "chai";
|
||||
|
||||
// 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], []);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
import {
|
||||
afterEachCustom,
|
||||
beforeEachCustom,
|
||||
makeLogFileName,
|
||||
MessageCollector,
|
||||
runMultipleNodes,
|
||||
ServiceNode,
|
||||
ServiceNodesFleet,
|
||||
tearDownNodes,
|
||||
teardownNodesWithRedundancy
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
TestClusterId,
|
||||
TestContentTopic,
|
||||
TestEncoder,
|
||||
TestNetworkConfig,
|
||||
TestRoutingInfo
|
||||
} from "./utils.js";
|
||||
|
||||
describe("Waku Light Push (Autosharding): Multiple Shards", function () {
|
||||
this.timeout(30000);
|
||||
const numServiceNodes = 2;
|
||||
|
||||
let waku: LightNode;
|
||||
let serviceNodes: ServiceNodesFleet;
|
||||
|
||||
const customContentTopic2 = "/test/2/waku-light-push/utf8";
|
||||
const customRoutingInfo2 = createRoutingInfo(TestNetworkConfig, {
|
||||
contentTopic: customContentTopic2
|
||||
});
|
||||
|
||||
const customEncoder2 = createEncoder({
|
||||
contentTopic: customContentTopic2,
|
||||
routingInfo: customRoutingInfo2
|
||||
});
|
||||
|
||||
beforeEachCustom(this, async () => {
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
TestRoutingInfo,
|
||||
{
|
||||
lightpush: true,
|
||||
filter: true,
|
||||
contentTopic: [TestEncoder.contentTopic, customEncoder2.contentTopic]
|
||||
},
|
||||
false,
|
||||
numServiceNodes,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
afterEachCustom(this, async () => {
|
||||
await teardownNodesWithRedundancy(serviceNodes, waku);
|
||||
});
|
||||
|
||||
it("Subscribe and receive messages on 2 different pubsubtopics", async function () {
|
||||
if (customRoutingInfo2.pubsubTopic === TestEncoder.pubsubTopic)
|
||||
throw "Invalid test, both encoder uses same shard";
|
||||
|
||||
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.waitForMessagesAutosharding(1, {
|
||||
contentTopic: TestEncoder.contentTopic
|
||||
})
|
||||
).to.eq(true);
|
||||
|
||||
expect(
|
||||
await messageCollector2.waitForMessagesAutosharding(1, {
|
||||
contentTopic: customEncoder2.contentTopic
|
||||
})
|
||||
).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,
|
||||
contentTopic: [TestContentTopic]
|
||||
});
|
||||
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, {
|
||||
contentTopic: TestEncoder.contentTopic
|
||||
});
|
||||
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], []);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user