fix: remove more uses of any

This commit is contained in:
Arseniy Klempner 2025-10-06 21:48:01 -07:00
parent a21856533f
commit fa1d25f5d1
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
5 changed files with 24 additions and 20 deletions

View File

@ -48,7 +48,7 @@ router.post(
"/lightpush/v3/message",
createEndpointHandler({
methodName: "pushMessageV3",
validateInput: (body: any): [string, string, string] => {
validateInput: (body): [string, string, string] => {
const validatedRequest = validators.requireLightpushV3(body);
return [

View File

@ -3,9 +3,9 @@ import axios from "axios";
import { StartedTestContainer } from "testcontainers";
import {
createLightNode,
waitForRemotePeer,
LightNode,
Protocols,
IDecodedMessage,
} from "@waku/sdk";
import { DEFAULT_CLUSTER_ID, DEFAULT_NUM_SHARDS } from "@waku/interfaces";
import { startBrowserTestsContainer, stopContainer } from "./utils/container-helpers.js";
@ -44,7 +44,7 @@ test.afterAll(async () => {
test("cross-network message delivery: SDK light node receives server lightpush", async () => {
test.setTimeout(TEST_CONFIG.DEFAULT_TEST_TIMEOUT);
const contentTopic = TEST_CONFIG.DEFAULT_CONTENT_TOPIC;
const contentTopic = TEST_CONFIG.DEFAULT_CONTENT_TOPIC;
const testMessage = TEST_CONFIG.DEFAULT_TEST_MESSAGE;
wakuNode = await createLightNode({
@ -65,13 +65,12 @@ test("cross-network message delivery: SDK light node receives server lightpush",
await wakuNode.start();
await waitForRemotePeer(
wakuNode,
await wakuNode.waitForPeers(
[Protocols.Filter, Protocols.LightPush],
30000,
);
const messages: any[] = [];
const messages: IDecodedMessage[] = [];
const decoder = wakuNode.createDecoder({ contentTopic });
if (

View File

@ -1,6 +1,6 @@
import { test, expect } from "@playwright/test";
import axios from "axios";
import { spawn } from "child_process";
import { spawn, ChildProcess } from "child_process";
import { fileURLToPath } from "url";
import { dirname, join } from "path";
@ -10,7 +10,7 @@ const __dirname = dirname(__filename);
test.describe.configure({ mode: "serial" });
test.describe("Server Tests", () => {
let serverProcess: any;
let serverProcess: ChildProcess;
let baseUrl = "http://localhost:3000";
test.beforeAll(async () => {
@ -75,7 +75,7 @@ test.describe("Server Tests", () => {
expect(infoRes.status).toBe(200);
expect(infoRes.data.peerId).toBeDefined();
expect(infoRes.data.multiaddrs).toBeDefined();
} catch (error: any) {
} catch (error) {
expect(error.response?.status).toBe(400);
}
});

View File

@ -56,7 +56,7 @@ export async function startBrowserTestsContainer(
// Wait for server readiness with retry logic (following waku/tests patterns)
const serverReady = await waitForServerReady(baseUrl, maxAttempts, timeout);
if (!serverReady) {
await logFinalContainerState(container);
throw new Error("Container failed to become ready");
@ -73,8 +73,8 @@ export async function startBrowserTestsContainer(
* Follows retry patterns from @waku/tests ServiceNode.
*/
async function waitForServerReady(
baseUrl: string,
maxAttempts: number,
baseUrl: string,
maxAttempts: number,
timeout: number
): Promise<boolean> {
for (let i = 0; i < maxAttempts; i++) {
@ -84,7 +84,7 @@ async function waitForServerReady(
log.info(`Server is ready after ${i + 1} attempts`);
return true;
}
} catch (error: any) {
} catch (error) {
if (i % 10 === 0) {
log.info(`Attempt ${i + 1}/${maxAttempts} failed:`, error.code || error.message);
}
@ -125,4 +125,4 @@ export async function stopContainer(container: StartedTestContainer): Promise<vo
message
);
}
}
}

View File

@ -13,12 +13,17 @@ import {
StaticSharding,
ShardInfo,
CreateLibp2pOptions,
IEncoder,
ILightPush,
SDKProtocolResult,
Failure,
} from "@waku/interfaces";
import { bootstrap } from "@libp2p/bootstrap";
import { EnrDecoder, TransportProtocol } from "@waku/enr";
import type { Multiaddr } from "@multiformats/multiaddr";
import type { ITestBrowser } from "../types/global.js";
import { Logger, StaticShardingRoutingInfo } from "@waku/utils";
import type { PeerId } from "@libp2p/interface";
const log = new Logger("waku-headless");
@ -31,11 +36,11 @@ export interface SerializableSDKProtocolResult {
myPeerId?: string;
}
function makeSerializable(result: any): SerializableSDKProtocolResult {
function makeSerializable(result: SDKProtocolResult): SerializableSDKProtocolResult {
return {
...result,
successes: result.successes.map((peerId: any) => peerId.toString()),
failures: result.failures.map((failure: any) => ({
successes: result.successes.map((peerId: PeerId) => peerId.toString()),
failures: result.failures.map((failure: Failure) => ({
error: failure.error || failure.toString(),
peerId: failure.peerId ? failure.peerId.toString() : undefined,
})),
@ -150,10 +155,10 @@ export class WakuHeadless {
}
private async send(
lightPush: any,
encoder: any,
lightPush: ILightPush,
encoder: IEncoder,
payload: Uint8Array,
) {
): Promise<SDKProtocolResult> {
return lightPush.send(encoder, {
payload,
timestamp: new Date(),