mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-04 06:43:12 +00:00
chore: add logs to debug lightpush
This commit is contained in:
parent
3793e6f5c0
commit
ab85322efe
@ -68,6 +68,12 @@ export async function runMultipleNodes(
|
|||||||
|
|
||||||
await waitForConnections(numServiceNodes, waku);
|
await waitForConnections(numServiceNodes, waku);
|
||||||
|
|
||||||
|
for (let i = 0; i < serviceNodes.nodes.length; i++) {
|
||||||
|
const node = serviceNodes.nodes[i];
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("DEBUG(node-setup): nwaku has peers", await node.peers());
|
||||||
|
}
|
||||||
|
|
||||||
return [serviceNodes, waku];
|
return [serviceNodes, waku];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { createEncoder } from "@waku/core";
|
import { createEncoder } from "@waku/core";
|
||||||
import { IRateLimitProof, LightNode, ProtocolError } from "@waku/interfaces";
|
import { IRateLimitProof, LightNode, ProtocolError } from "@waku/interfaces";
|
||||||
import { utf8ToBytes } from "@waku/sdk";
|
import { utf8ToBytes } from "@waku/sdk";
|
||||||
|
import { delay } from "@waku/utils";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -24,13 +25,14 @@ import {
|
|||||||
|
|
||||||
const runTests = (strictNodeCheck: boolean): void => {
|
const runTests = (strictNodeCheck: boolean): void => {
|
||||||
const numServiceNodes = 2;
|
const numServiceNodes = 2;
|
||||||
describe(`Waku Light Push: Multiple Nodes: Strict Check: ${strictNodeCheck}`, function () {
|
describe.only(`Waku Light Push: Multiple Nodes: Strict Check: ${strictNodeCheck}`, function () {
|
||||||
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
// Set the timeout for all tests in this suite. Can be overwritten at test level
|
||||||
this.timeout(15000);
|
this.timeout(15000);
|
||||||
let waku: LightNode;
|
let waku: LightNode;
|
||||||
let serviceNodes: ServiceNodesFleet;
|
let serviceNodes: ServiceNodesFleet;
|
||||||
|
|
||||||
beforeEachCustom(this, async () => {
|
beforeEachCustom(this, async () => {
|
||||||
|
console.log("DEBUG(test-case): initiating new test case");
|
||||||
[serviceNodes, waku] = await runMultipleNodes(
|
[serviceNodes, waku] = await runMultipleNodes(
|
||||||
this.ctx,
|
this.ctx,
|
||||||
TestShardInfo,
|
TestShardInfo,
|
||||||
@ -65,31 +67,56 @@ const runTests = (strictNodeCheck: boolean): void => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Push 30 different messages", async function () {
|
for (let i = 0; i < 10; i++) {
|
||||||
const generateMessageText = (index: number): string => `M${index}`;
|
it.only("Push 30 different messages" + " #" + i, async function () {
|
||||||
|
const generateMessageText = (index: number): string => `M${index}`;
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
const pushResponse = await waku.lightPush.send(TestEncoder, {
|
const pushResponse = await waku.lightPush.send(TestEncoder, {
|
||||||
payload: utf8ToBytes(generateMessageText(i))
|
payload: utf8ToBytes(generateMessageText(i))
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(pushResponse.successes.length).to.eq(numServiceNodes);
|
await delay(100);
|
||||||
}
|
|
||||||
|
|
||||||
expect(
|
console.log(
|
||||||
await serviceNodes.messageCollector.waitForMessages(30, {
|
"DEBUG(test-case): pushed to ",
|
||||||
pubsubTopic: TestPubsubTopic
|
"failures:",
|
||||||
})
|
pushResponse.failures.toString(),
|
||||||
).to.eq(true);
|
" successes: ",
|
||||||
|
pushResponse.successes.toString(),
|
||||||
|
" expected successes:",
|
||||||
|
numServiceNodes
|
||||||
|
);
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
if (pushResponse.failures.length) {
|
||||||
serviceNodes.messageCollector.verifyReceivedMessage(i, {
|
for (let i = 0; i < serviceNodes.nodes.length; i++) {
|
||||||
expectedMessageText: generateMessageText(i),
|
const node = serviceNodes.nodes[i];
|
||||||
expectedContentTopic: TestContentTopic,
|
console.log(
|
||||||
expectedPubsubTopic: TestPubsubTopic
|
"DEBUG(test-cause): nwaku has peers",
|
||||||
});
|
await node.peers()
|
||||||
}
|
);
|
||||||
});
|
console.log("DEBUG(test-cause): nwaku logs", node["logPath"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(pushResponse.successes.length).to.eq(numServiceNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await serviceNodes.messageCollector.waitForMessages(30, {
|
||||||
|
pubsubTopic: TestPubsubTopic
|
||||||
|
})
|
||||||
|
).to.eq(true);
|
||||||
|
|
||||||
|
for (let i = 0; i < 30; i++) {
|
||||||
|
serviceNodes.messageCollector.verifyReceivedMessage(i, {
|
||||||
|
expectedMessageText: generateMessageText(i),
|
||||||
|
expectedContentTopic: TestContentTopic,
|
||||||
|
expectedPubsubTopic: TestPubsubTopic
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
it("Throws when trying to push message with empty payload", async function () {
|
it("Throws when trying to push message with empty payload", async function () {
|
||||||
const pushResponse = await waku.lightPush.send(TestEncoder, {
|
const pushResponse = await waku.lightPush.send(TestEncoder, {
|
||||||
@ -282,4 +309,6 @@ const runTests = (strictNodeCheck: boolean): void => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
[true].map(runTests);
|
for (let i = 0; i < 5; i++) {
|
||||||
|
[true, false].map(runTests);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user