mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-05-17 10:10:00 +00:00
chore: add delays for nwaku setup
This commit is contained in:
parent
98179ce129
commit
7615f8fa84
@ -434,7 +434,7 @@ interface RpcInfoResponse {
|
|||||||
|
|
||||||
export async function verifyServiceNodesConnected(
|
export async function verifyServiceNodesConnected(
|
||||||
nodes: ServiceNode[]
|
nodes: ServiceNode[]
|
||||||
): Promise<void> {
|
): Promise<boolean> {
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
const peers = await node.peers();
|
const peers = await node.peers();
|
||||||
log.info(`Service node ${node.containerName} peers:`, peers.length);
|
log.info(`Service node ${node.containerName} peers:`, peers.length);
|
||||||
@ -442,9 +442,9 @@ export async function verifyServiceNodesConnected(
|
|||||||
|
|
||||||
if (nodes.length > 1 && peers.length === 0) {
|
if (nodes.length > 1 && peers.length === 0) {
|
||||||
log.error(`Service node ${node.containerName} has no peers connected`);
|
log.error(`Service node ${node.containerName} has no peers connected`);
|
||||||
throw new Error(
|
return false;
|
||||||
`Service node ${node.containerName} has no peers connected`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
Protocols
|
Protocols
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
import { createLightNode } from "@waku/sdk";
|
import { createLightNode } from "@waku/sdk";
|
||||||
import { derivePubsubTopicsFromNetworkConfig } from "@waku/utils";
|
import { delay, derivePubsubTopicsFromNetworkConfig } from "@waku/utils";
|
||||||
import { Context } from "mocha";
|
import { Context } from "mocha";
|
||||||
import pRetry from "p-retry";
|
import pRetry from "p-retry";
|
||||||
|
|
||||||
@ -37,7 +37,10 @@ export async function runMultipleNodes(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (numServiceNodes > 1) {
|
if (numServiceNodes > 1) {
|
||||||
await verifyServiceNodesConnected(serviceNodes.nodes);
|
const success = await verifyServiceNodesConnected(serviceNodes.nodes);
|
||||||
|
if (!success) {
|
||||||
|
throw new Error("Failed to verify that service nodes are connected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wakuOptions: CreateNodeOptions = {
|
const wakuOptions: CreateNodeOptions = {
|
||||||
@ -55,12 +58,21 @@ export async function runMultipleNodes(
|
|||||||
throw new Error("Failed to initialize waku");
|
throw new Error("Failed to initialize waku");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: reinvestigate the need for these delays with nwaku:0.35.0: https://github.com/waku-org/js-waku/issues/2264
|
||||||
|
await delay(2000);
|
||||||
|
|
||||||
for (const node of serviceNodes.nodes) {
|
for (const node of serviceNodes.nodes) {
|
||||||
await waku.dial(await node.getMultiaddrWithId());
|
await waku.dial(await node.getMultiaddrWithId());
|
||||||
await waku.waitForPeers([Protocols.Filter, Protocols.LightPush]);
|
await waku.waitForPeers([Protocols.Filter, Protocols.LightPush]);
|
||||||
await node.ensureSubscriptions(
|
const success = await node.ensureSubscriptions(
|
||||||
derivePubsubTopicsFromNetworkConfig(networkConfig)
|
derivePubsubTopicsFromNetworkConfig(networkConfig)
|
||||||
);
|
);
|
||||||
|
if (!success) {
|
||||||
|
throw new Error("Failed to ensure subscriptions");
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: reinvestigate the need for these delays with nwaku:0.35.0: https://github.com/waku-org/js-waku/issues/2264
|
||||||
|
await delay(2000);
|
||||||
|
|
||||||
await node.waitForLog(waku.libp2p.peerId.toString(), 100);
|
await node.waitForLog(waku.libp2p.peerId.toString(), 100);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import {
|
|||||||
const ContentTopic = "/waku/2/content/test.js";
|
const ContentTopic = "/waku/2/content/test.js";
|
||||||
|
|
||||||
describe("Static Sharding: Running Nodes", function () {
|
describe("Static Sharding: Running Nodes", function () {
|
||||||
this.timeout(15_000);
|
this.timeout(60_000);
|
||||||
let waku: LightNode;
|
let waku: LightNode;
|
||||||
let serviceNodes: ServiceNodesFleet;
|
let serviceNodes: ServiceNodesFleet;
|
||||||
|
|
||||||
@ -42,7 +42,8 @@ describe("Static Sharding: Running Nodes", function () {
|
|||||||
store: true,
|
store: true,
|
||||||
lightpush: true,
|
lightpush: true,
|
||||||
relay: true,
|
relay: true,
|
||||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
pubsubTopic: shardInfoToPubsubTopics(shardInfo),
|
||||||
|
clusterId: singleShardInfo.clusterId
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
2,
|
2,
|
||||||
@ -80,7 +81,8 @@ describe("Static Sharding: Running Nodes", function () {
|
|||||||
store: true,
|
store: true,
|
||||||
lightpush: true,
|
lightpush: true,
|
||||||
relay: true,
|
relay: true,
|
||||||
pubsubTopic: shardInfoToPubsubTopics(shardInfo)
|
pubsubTopic: shardInfoToPubsubTopics(shardInfo),
|
||||||
|
clusterId: singleShardInfo.clusterId
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
2,
|
2,
|
||||||
|
|||||||
@ -175,8 +175,6 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEachCustom(this, async () => {
|
beforeEachCustom(this, async () => {
|
||||||
console.log("running nodes");
|
|
||||||
|
|
||||||
[serviceNodes, waku] = await runMultipleNodes(
|
[serviceNodes, waku] = await runMultipleNodes(
|
||||||
this.ctx,
|
this.ctx,
|
||||||
contentTopicInfoBothShards,
|
contentTopicInfoBothShards,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user