mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-22 23:53:14 +00:00
fix: store tests to now use multiple nodes, delete uneeded test
This commit is contained in:
parent
04cd3571d1
commit
179e6b2530
@ -1,26 +1,24 @@
|
||||
import { createDecoder } from "@waku/core";
|
||||
import type { ContentTopicInfo, IMessage, LightNode } from "@waku/interfaces";
|
||||
import { createLightNode, Protocols } from "@waku/sdk";
|
||||
import {
|
||||
contentTopicToPubsubTopic,
|
||||
pubsubTopicToSingleShardInfo
|
||||
} from "@waku/utils";
|
||||
import type { AutoSharding, IMessage, LightNode } from "@waku/interfaces";
|
||||
import { Protocols } from "@waku/sdk";
|
||||
import { contentTopicToPubsubTopic } from "@waku/utils";
|
||||
import { expect } from "chai";
|
||||
|
||||
import {
|
||||
afterEachCustom,
|
||||
beforeEachCustom,
|
||||
makeLogFileName,
|
||||
NOISE_KEY_1,
|
||||
runMultipleNodes,
|
||||
ServiceNode,
|
||||
tearDownNodes
|
||||
ServiceNodesFleet,
|
||||
tearDownNodes,
|
||||
teardownNodesWithRedundancy
|
||||
} from "../../src/index.js";
|
||||
|
||||
import {
|
||||
processQueriedMessages,
|
||||
runStoreNodes,
|
||||
sendMessages,
|
||||
sendMessagesAutosharding,
|
||||
TestDecoder,
|
||||
TestDecoder2,
|
||||
TestShardInfo,
|
||||
@ -156,8 +154,7 @@ describe("Waku Store, custom pubsub topic", function () {
|
||||
describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
this.timeout(15000);
|
||||
let waku: LightNode;
|
||||
let nwaku: ServiceNode;
|
||||
let nwaku2: ServiceNode;
|
||||
let serviceNodes: ServiceNodesFleet;
|
||||
|
||||
const customContentTopic1 = "/waku/2/content/utf8";
|
||||
const customContentTopic2 = "/myapp/1/latest/proto";
|
||||
@ -170,29 +167,37 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
customContentTopic2,
|
||||
clusterId
|
||||
);
|
||||
const customDecoder1 = createDecoder(
|
||||
customContentTopic1,
|
||||
pubsubTopicToSingleShardInfo(autoshardingPubsubTopic1)
|
||||
);
|
||||
const customDecoder2 = createDecoder(
|
||||
customContentTopic2,
|
||||
pubsubTopicToSingleShardInfo(autoshardingPubsubTopic2)
|
||||
);
|
||||
const contentTopicInfoBothShards: ContentTopicInfo = {
|
||||
const customDecoder1 = createDecoder(customContentTopic1, { clusterId: 5 });
|
||||
const customDecoder2 = createDecoder(customContentTopic2, { clusterId: 5 });
|
||||
const contentTopicInfoBothShards: AutoSharding = {
|
||||
clusterId,
|
||||
contentTopics: [customContentTopic1, customContentTopic2]
|
||||
};
|
||||
|
||||
beforeEachCustom(this, async () => {
|
||||
[nwaku, waku] = await runStoreNodes(this.ctx, contentTopicInfoBothShards);
|
||||
console.log("running nodes");
|
||||
|
||||
[serviceNodes, waku] = await runMultipleNodes(
|
||||
this.ctx,
|
||||
contentTopicInfoBothShards,
|
||||
{ store: true }
|
||||
);
|
||||
});
|
||||
|
||||
afterEachCustom(this, async () => {
|
||||
await tearDownNodes([nwaku, nwaku2], waku);
|
||||
await teardownNodesWithRedundancy(serviceNodes, waku);
|
||||
});
|
||||
|
||||
it("Generator, custom pubsub topic", async function () {
|
||||
await sendMessagesAutosharding(nwaku, totalMsgs, customContentTopic1);
|
||||
for (let i = 0; i < totalMsgs; i++) {
|
||||
await serviceNodes.sendRelayMessage(
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([0]),
|
||||
contentTopic: customContentTopic1
|
||||
}),
|
||||
autoshardingPubsubTopic1
|
||||
);
|
||||
}
|
||||
|
||||
const messages = await processQueriedMessages(
|
||||
waku,
|
||||
@ -211,8 +216,22 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
this.timeout(10000);
|
||||
|
||||
const totalMsgs = 10;
|
||||
await sendMessagesAutosharding(nwaku, totalMsgs, customContentTopic1);
|
||||
await sendMessagesAutosharding(nwaku, totalMsgs, customContentTopic2);
|
||||
for (let i = 0; i < totalMsgs; i++) {
|
||||
await serviceNodes.sendRelayMessage(
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([i]),
|
||||
contentTopic: customContentTopic1
|
||||
}),
|
||||
autoshardingPubsubTopic1
|
||||
);
|
||||
await serviceNodes.sendRelayMessage(
|
||||
ServiceNode.toMessageRpcQuery({
|
||||
payload: new Uint8Array([i]),
|
||||
contentTopic: customContentTopic2
|
||||
}),
|
||||
autoshardingPubsubTopic2
|
||||
);
|
||||
}
|
||||
|
||||
const customMessages = await processQueriedMessages(
|
||||
waku,
|
||||
@ -236,54 +255,6 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
||||
});
|
||||
expect(result2).to.not.eq(-1);
|
||||
});
|
||||
|
||||
it("Generator, 2 nwaku nodes each with different pubsubtopics", async function () {
|
||||
this.timeout(10000);
|
||||
|
||||
// Set up and start a new nwaku node with Default Pubsubtopic
|
||||
nwaku2 = new ServiceNode(makeLogFileName(this) + "2");
|
||||
await nwaku2.start({
|
||||
store: true,
|
||||
pubsubTopic: [autoshardingPubsubTopic2],
|
||||
contentTopic: [customContentTopic2],
|
||||
relay: true,
|
||||
clusterId
|
||||
});
|
||||
await nwaku2.ensureSubscriptionsAutosharding([customContentTopic2]);
|
||||
|
||||
const totalMsgs = 10;
|
||||
await sendMessagesAutosharding(nwaku, totalMsgs, customContentTopic1);
|
||||
await sendMessagesAutosharding(nwaku2, totalMsgs, customContentTopic2);
|
||||
|
||||
waku = await createLightNode({
|
||||
staticNoiseKey: NOISE_KEY_1,
|
||||
networkConfig: contentTopicInfoBothShards
|
||||
});
|
||||
await waku.start();
|
||||
|
||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||
await waku.dial(await nwaku2.getMultiaddrWithId());
|
||||
await waku.waitForPeers([Protocols.Store]);
|
||||
|
||||
let customMessages: IMessage[] = [];
|
||||
let testMessages: IMessage[] = [];
|
||||
|
||||
while (
|
||||
customMessages.length != totalMsgs ||
|
||||
testMessages.length != totalMsgs
|
||||
) {
|
||||
customMessages = await processQueriedMessages(
|
||||
waku,
|
||||
[customDecoder1],
|
||||
autoshardingPubsubTopic1
|
||||
);
|
||||
testMessages = await processQueriedMessages(
|
||||
waku,
|
||||
[customDecoder2],
|
||||
autoshardingPubsubTopic2
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Waku Store (named sharding), custom pubsub topic", function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user