mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-06-05 19:39:29 +00:00
small optimization
This commit is contained in:
parent
cd265ba1ae
commit
f8f20db85c
@ -17,6 +17,10 @@ import {
|
|||||||
} from "../../tests/src/index.js";
|
} from "../../tests/src/index.js";
|
||||||
|
|
||||||
const ContentTopic = "/waku/2/content/test.high-throughput.js";
|
const ContentTopic = "/waku/2/content/test.high-throughput.js";
|
||||||
|
const NetworkConfig = { clusterId: 0, numShardsInCluster: 8 };
|
||||||
|
const RoutingInfo = createRoutingInfo(NetworkConfig, {
|
||||||
|
contentTopic: ContentTopic
|
||||||
|
});
|
||||||
|
|
||||||
describe("High Throughput Messaging", function () {
|
describe("High Throughput Messaging", function () {
|
||||||
const testDurationMs = 20 * 60 * 1000; // 20 minutes
|
const testDurationMs = 20 * 60 * 1000; // 20 minutes
|
||||||
@ -35,8 +39,6 @@ describe("High Throughput Messaging", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("Send/Receive thousands of messages quickly", async function () {
|
it("Send/Receive thousands of messages quickly", async function () {
|
||||||
const networkConfig = { clusterId: 0, numShardsInCluster: 8 };
|
|
||||||
|
|
||||||
const testStart = new Date();
|
const testStart = new Date();
|
||||||
const testEnd = Date.now() + testDurationMs;
|
const testEnd = Date.now() + testDurationMs;
|
||||||
|
|
||||||
@ -53,8 +55,8 @@ describe("High Throughput Messaging", function () {
|
|||||||
store: true,
|
store: true,
|
||||||
filter: true,
|
filter: true,
|
||||||
relay: true,
|
relay: true,
|
||||||
clusterId: networkConfig.clusterId,
|
clusterId: NetworkConfig.clusterId,
|
||||||
numShardsInNetwork: networkConfig.numShardsInCluster,
|
numShardsInNetwork: NetworkConfig.numShardsInCluster,
|
||||||
contentTopic: [ContentTopic]
|
contentTopic: [ContentTopic]
|
||||||
},
|
},
|
||||||
{ retries: 3 }
|
{ retries: 3 }
|
||||||
@ -65,20 +67,17 @@ describe("High Throughput Messaging", function () {
|
|||||||
await nwaku.ensureSubscriptions([
|
await nwaku.ensureSubscriptions([
|
||||||
contentTopicToPubsubTopic(
|
contentTopicToPubsubTopic(
|
||||||
ContentTopic,
|
ContentTopic,
|
||||||
networkConfig.clusterId,
|
NetworkConfig.clusterId,
|
||||||
networkConfig.numShardsInCluster
|
NetworkConfig.numShardsInCluster
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
waku = await createLightNode({ networkConfig });
|
waku = await createLightNode({ networkConfig: NetworkConfig });
|
||||||
await waku.start();
|
await waku.start();
|
||||||
await waku.dial(await nwaku.getMultiaddrWithId());
|
await waku.dial(await nwaku.getMultiaddrWithId());
|
||||||
await waku.waitForPeers([Protocols.Filter]);
|
await waku.waitForPeers([Protocols.Filter]);
|
||||||
|
|
||||||
const routingInfo = createRoutingInfo(networkConfig, {
|
const decoder = createDecoder(ContentTopic, RoutingInfo);
|
||||||
contentTopic: ContentTopic
|
|
||||||
});
|
|
||||||
const decoder = createDecoder(ContentTopic, routingInfo);
|
|
||||||
const hasSubscribed = await waku.filter.subscribe(
|
const hasSubscribed = await waku.filter.subscribe(
|
||||||
[decoder],
|
[decoder],
|
||||||
messageCollector.callback
|
messageCollector.callback
|
||||||
@ -101,7 +100,7 @@ describe("High Throughput Messaging", function () {
|
|||||||
contentTopic: ContentTopic,
|
contentTopic: ContentTopic,
|
||||||
payload: utf8ToBytes(message)
|
payload: utf8ToBytes(message)
|
||||||
}),
|
}),
|
||||||
routingInfo
|
RoutingInfo
|
||||||
);
|
);
|
||||||
sent = true;
|
sent = true;
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ describe("High Throughput Messaging", function () {
|
|||||||
messageCollector.verifyReceivedMessage(0, {
|
messageCollector.verifyReceivedMessage(0, {
|
||||||
expectedMessageText: message,
|
expectedMessageText: message,
|
||||||
expectedContentTopic: ContentTopic,
|
expectedContentTopic: ContentTopic,
|
||||||
expectedPubsubTopic: routingInfo.pubsubTopic
|
expectedPubsubTopic: RoutingInfo.pubsubTopic
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user