Danish Arora a3fb1d7a5b
Revert "chore: upgrade nwaku to 0.34.0 and update tests suite for compatibili…" (#2273)
This reverts commit 26ab836900d907b0ca185e6ad5fb6b3b548350fb.
2025-02-21 23:06:45 +01:00

50 lines
1.2 KiB
TypeScript

import { IWaku } from "@waku/interfaces";
import { Logger } from "@waku/utils";
import pRetry from "p-retry";
import { ServiceNode } from "../lib/service_node.js";
const log = new Logger("test:teardown");
export async function tearDownNodes(
nwakuNodes: ServiceNode | ServiceNode[],
wakuNodes: IWaku | IWaku[]
): Promise<void> {
const nNodes = Array.isArray(nwakuNodes) ? nwakuNodes : [nwakuNodes];
const wNodes = Array.isArray(wakuNodes) ? wakuNodes : [wakuNodes];
const stopNwakuNodes = nNodes.map(async (nwaku) => {
if (nwaku) {
await pRetry(
async () => {
try {
await nwaku.stop();
} catch (error) {
log.error("Nwaku failed to stop:", error);
throw error;
}
},
{ retries: 3 }
);
}
});
const stopWakuNodes = wNodes.map(async (waku) => {
if (waku) {
await pRetry(
async () => {
try {
await waku.stop();
} catch (error) {
log.error("Waku failed to stop:", error);
throw error;
}
},
{ retries: 3 }
);
}
});
await Promise.all([...stopNwakuNodes, ...stopWakuNodes]);
}