diff --git a/packages/tests/src/lib/service_node.ts b/packages/tests/src/lib/service_node.ts index baa905762a..52ec598cbd 100644 --- a/packages/tests/src/lib/service_node.ts +++ b/packages/tests/src/lib/service_node.ts @@ -434,7 +434,7 @@ interface RpcInfoResponse { export async function verifyServiceNodesConnected( nodes: ServiceNode[] -): Promise { +): Promise { for (const node of nodes) { const peers = await node.peers(); log.info(`Service node ${node.containerName} peers:`, peers.length); @@ -442,9 +442,9 @@ export async function verifyServiceNodesConnected( if (nodes.length > 1 && peers.length === 0) { log.error(`Service node ${node.containerName} has no peers connected`); - throw new Error( - `Service node ${node.containerName} has no peers connected` - ); + return false; } } + + return true; } diff --git a/packages/tests/src/utils/nodes.ts b/packages/tests/src/utils/nodes.ts index 623c3d54a2..b5f3512094 100644 --- a/packages/tests/src/utils/nodes.ts +++ b/packages/tests/src/utils/nodes.ts @@ -7,7 +7,7 @@ import { Protocols } from "@waku/interfaces"; import { createLightNode } from "@waku/sdk"; -import { derivePubsubTopicsFromNetworkConfig } from "@waku/utils"; +import { delay, derivePubsubTopicsFromNetworkConfig } from "@waku/utils"; import { Context } from "mocha"; import pRetry from "p-retry"; @@ -37,7 +37,10 @@ export async function runMultipleNodes( ); 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 = { @@ -55,12 +58,21 @@ export async function runMultipleNodes( 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) { await waku.dial(await node.getMultiaddrWithId()); await waku.waitForPeers([Protocols.Filter, Protocols.LightPush]); - await node.ensureSubscriptions( + const success = await node.ensureSubscriptions( 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); } diff --git a/packages/tests/tests/sharding/static_sharding.spec.ts b/packages/tests/tests/sharding/static_sharding.spec.ts index 066c0c6324..61db888be5 100644 --- a/packages/tests/tests/sharding/static_sharding.spec.ts +++ b/packages/tests/tests/sharding/static_sharding.spec.ts @@ -22,7 +22,7 @@ import { const ContentTopic = "/waku/2/content/test.js"; describe("Static Sharding: Running Nodes", function () { - this.timeout(15_000); + this.timeout(60_000); let waku: LightNode; let serviceNodes: ServiceNodesFleet; @@ -42,7 +42,8 @@ describe("Static Sharding: Running Nodes", function () { store: true, lightpush: true, relay: true, - pubsubTopic: shardInfoToPubsubTopics(shardInfo) + pubsubTopic: shardInfoToPubsubTopics(shardInfo), + clusterId: singleShardInfo.clusterId }, false, 2, @@ -80,7 +81,8 @@ describe("Static Sharding: Running Nodes", function () { store: true, lightpush: true, relay: true, - pubsubTopic: shardInfoToPubsubTopics(shardInfo) + pubsubTopic: shardInfoToPubsubTopics(shardInfo), + clusterId: singleShardInfo.clusterId }, false, 2, diff --git a/packages/tests/tests/store/multiple_pubsub.spec.ts b/packages/tests/tests/store/multiple_pubsub.spec.ts index ab80d161f2..fb4303a25e 100644 --- a/packages/tests/tests/store/multiple_pubsub.spec.ts +++ b/packages/tests/tests/store/multiple_pubsub.spec.ts @@ -175,8 +175,6 @@ describe("Waku Store (Autosharding), custom pubsub topic", function () { }; beforeEachCustom(this, async () => { - console.log("running nodes"); - [serviceNodes, waku] = await runMultipleNodes( this.ctx, contentTopicInfoBothShards,