From 32f01e3e328db0006a55c6324625b49d60244b66 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Feb 2026 15:16:20 -0800 Subject: fix typescript issues --- test/forward.test.ts | 5 +++-- test/integration/ark-reconcile.test.ts | 21 +++++---------------- test/integration/bolt12.test.ts | 16 ++++------------ test/onchain.test.ts | 9 ++++----- 4 files changed, 16 insertions(+), 35 deletions(-) (limited to 'test') diff --git a/test/forward.test.ts b/test/forward.test.ts index cae988b7..4c538153 100644 --- a/test/forward.test.ts +++ b/test/forward.test.ts @@ -16,7 +16,8 @@ const mockLnDecode = ln.decode as any; const mockLnGetroutes = ln.getroutes as any; import { completePayment } from "$lib/payments"; -import routes from "$routes/payments"; +import _routes from "$routes/payments"; +const routes: any = _routes; // ===================================================================== // Helpers @@ -114,7 +115,7 @@ const makeRes = () => { send: (data: any) => { sent = data; }, - code: (code: number) => ({ + code: (_code: number) => ({ send: (data: any) => { sent = data; }, diff --git a/test/integration/ark-reconcile.test.ts b/test/integration/ark-reconcile.test.ts index 84825475..342d02a6 100644 --- a/test/integration/ark-reconcile.test.ts +++ b/test/integration/ark-reconcile.test.ts @@ -8,7 +8,7 @@ import { describe, test, expect, beforeAll } from "bun:test"; const APP = "http://localhost:3119"; -const api = async (path: string, token: string, opts: any = {}) => { +const api = async (path: string, token: string, opts: any = {}): Promise => { const res = await fetch(`${APP}${path}`, { headers: { "Content-Type": "application/json", @@ -17,28 +17,19 @@ const api = async (path: string, token: string, opts: any = {}) => { }, ...opts, }); - return res.json(); + return res.json() as any; }; -const register = async (username: string, password: string) => { +const register = async (username: string, password: string): Promise => { const res = await fetch(`${APP}/register`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ user: { username, password } }), }); if (!res.ok) throw new Error(`register failed: ${await res.text()}`); - return res.json(); + return res.json() as any; }; -const login = async (username: string, password: string) => { - const res = await fetch(`${APP}/login`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ username, password }), - }); - if (!res.ok) throw new Error(`login failed: ${await res.text()}`); - return res.json(); -}; const createInvoice = (token: string, invoice: any) => api("/invoice", token, { @@ -46,8 +37,6 @@ const createInvoice = (token: string, invoice: any) => body: JSON.stringify({ invoice }), }); -const getPayments = (token: string, aid?: string) => - api(`/payments${aid ? `?aid=${aid}` : ""}`, token); // ===================================================================== // Test state @@ -79,7 +68,7 @@ beforeAll(async () => { body: JSON.stringify({ type: "ark", name: "ark vault" }), }); if (res.ok) { - const account = await res.json(); + const account = await res.json() as any; arkAccountId = account.id; } else { // Fallback: use user's own ID as the account diff --git a/test/integration/bolt12.test.ts b/test/integration/bolt12.test.ts index 24aa53e0..b9f332cc 100644 --- a/test/integration/bolt12.test.ts +++ b/test/integration/bolt12.test.ts @@ -32,10 +32,6 @@ const clExec = async (container: string, ...args: string[]): Promise => { } }; -const mine = async (n: number) => { - const addr = await exec("docker exec bc bitcoin-cli -regtest -rpcwallet=coinos getnewaddress"); - await exec(`docker exec bc bitcoin-cli -regtest generatetoaddress ${n} ${addr}`); -}; const waitFor = async (fn: () => Promise, timeout = 30000): Promise => { const start = Date.now(); @@ -52,17 +48,17 @@ const waitFor = async (fn: () => Promise, timeout = 30000): Promise => throw new Error(`waitFor timed out: ${lastError?.message || "no result"}`); }; -const register = async (username: string, password: string) => { +const register = async (username: string, password: string): Promise => { const res = await fetch(`${APP}/register`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ user: { username, password } }), }); if (!res.ok) throw new Error(`register failed: ${await res.text()}`); - return res.json(); + return res.json() as any; }; -const api = async (path: string, token: string, opts: any = {}) => { +const api = async (path: string, token: string, opts: any = {}): Promise => { const res = await fetch(`${APP}${path}`, { headers: { "Content-Type": "application/json", @@ -71,7 +67,7 @@ const api = async (path: string, token: string, opts: any = {}) => { }, ...opts, }); - return res.json(); + return res.json() as any; }; const updateUser = (token: string, settings: any) => @@ -102,8 +98,6 @@ const getPayments = (token: string) => api("/payments", token); let funderToken: string; let withdrawerToken: string; -let funderUser: any; -let withdrawerUser: any; // ===================================================================== // Setup: register users, fund the funder via lightning @@ -128,11 +122,9 @@ beforeAll(async () => { // Register test users const funder = await register(funderName, "testpass123"); funderToken = funder.token; - funderUser = funder; const withdrawer = await register(withdrawerName, "testpass123"); withdrawerToken = withdrawer.token; - withdrawerUser = withdrawer; // Fund the funder: generate a lightning invoice and pay from clb const inv = await createInvoice(funderToken, { diff --git a/test/onchain.test.ts b/test/onchain.test.ts index e1ebe608..9850bba3 100644 --- a/test/onchain.test.ts +++ b/test/onchain.test.ts @@ -1,16 +1,15 @@ import { describe, test, expect, beforeEach } from "bun:test"; import { tbCredit, tbConfirm } from "$lib/tb"; -import { emit } from "$lib/sockets"; import { callWebhook } from "$lib/webhooks"; const mockTbCredit = tbCredit as any; const mockTbConfirm = tbConfirm as any; -const mockEmit = emit as any; const mockCallWebhook = callWebhook as any; -import { processWatchedTx, credit, catchUp } from "$lib/payments"; -import routes from "$routes/payments"; +import { processWatchedTx, catchUp } from "$lib/payments"; +import _routes from "$routes/payments"; +const routes: any = _routes; import { PaymentType } from "$lib/types"; // ===================================================================== @@ -105,7 +104,7 @@ const makeRes = () => { send: (data: any) => { sent = data; }, - code: (code: number) => ({ + code: (_code: number) => ({ send: (data: any) => { sent = data; }, -- cgit v1.2.3