diff options
| author | Adam Soltys <[email protected]> | 2026-02-24 13:18:42 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-24 13:18:42 -0800 |
| commit | ad7b09b43323d0ffc0a8ddabb43e4838a184c697 (patch) | |
| tree | fbf2a59f81771b2938f474c8e7b35a497d2960e4 /test/integration | |
| parent | 9e97e040617bfa0b40150c0eba298bf186bbeeaf (diff) | |
| download | coinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.tar.gz coinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.zip | |
formatting
Diffstat (limited to 'test/integration')
| -rw-r--r-- | test/integration/ark-reconcile.test.ts | 20 | ||||
| -rw-r--r-- | test/integration/bolt12.test.ts | 35 |
2 files changed, 13 insertions, 42 deletions
diff --git a/test/integration/ark-reconcile.test.ts b/test/integration/ark-reconcile.test.ts index 5e2061e6..84825475 100644 --- a/test/integration/ark-reconcile.test.ts +++ b/test/integration/ark-reconcile.test.ts @@ -126,9 +126,7 @@ describe("ark sync reconciliation", () => { method: "POST", body: JSON.stringify({ aid: arkAccountId, - transactions: [ - { arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }, - ], + transactions: [{ arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }], balance: 13000, }), }); @@ -138,9 +136,7 @@ describe("ark sync reconciliation", () => { method: "POST", body: JSON.stringify({ aid: arkAccountId, - transactions: [ - { arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }, - ], + transactions: [{ arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }], balance: 13000, }), }); @@ -192,9 +188,7 @@ describe("ark sync reconciliation", () => { method: "POST", body: JSON.stringify({ aid: arkAccountId, - transactions: [ - { arkTxid: hash, amount: 5000, settled: true, createdAt: Date.now() }, - ], + transactions: [{ arkTxid: hash, amount: 5000, settled: true, createdAt: Date.now() }], balance: 5000, }), }); @@ -204,9 +198,7 @@ describe("ark sync reconciliation", () => { // Sum is now 5000 (13000 - 13000 + 5000), matches balance=5000 // No reconciliation needed - expect( - result.payments.filter((p: any) => p.memo === "expired"), - ).toHaveLength(0); + expect(result.payments.filter((p: any) => p.memo === "expired")).toHaveLength(0); }); test("partial expiry creates correct debit", async () => { @@ -240,9 +232,7 @@ describe("ark sync reconciliation", () => { method: "POST", body: JSON.stringify({ aid: arkAccountId, - transactions: [ - { arkTxid: hash, amount: 2000, settled: true, createdAt: Date.now() }, - ], + transactions: [{ arkTxid: hash, amount: 2000, settled: true, createdAt: Date.now() }], balance: 4000, // previous 2000 + new 2000 }), }); diff --git a/test/integration/bolt12.test.ts b/test/integration/bolt12.test.ts index 06929c6c..24aa53e0 100644 --- a/test/integration/bolt12.test.ts +++ b/test/integration/bolt12.test.ts @@ -24,9 +24,7 @@ const exec = async (cmd: string): Promise<string> => { const clExec = async (container: string, ...args: string[]): Promise<any> => { const escaped = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" "); - const result = await exec( - `docker exec ${container} lightning-cli ${escaped}`, - ); + const result = await exec(`docker exec ${container} lightning-cli ${escaped}`); try { return JSON.parse(result); } catch { @@ -35,18 +33,11 @@ const clExec = async (container: string, ...args: string[]): Promise<any> => { }; 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 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 <T>( - fn: () => Promise<T>, - timeout = 30000, -): Promise<T> => { +const waitFor = async <T>(fn: () => Promise<T>, timeout = 30000): Promise<T> => { const start = Date.now(); let lastError: any; while (Date.now() - start < timeout) { @@ -185,11 +176,7 @@ describe("BOLT12 autowithdraw", () => { // Send 100k sats from funder to withdrawer (triggers autowithdraw) const sendAmount = 100_000; - const sendResult = await sendInternal( - funderToken, - withdrawerName, - sendAmount, - ); + const sendResult = await sendInternal(funderToken, withdrawerName, sendAmount); expect(sendResult.amount).toBe(-sendAmount); // Wait for autowithdraw to complete — withdrawer balance should drop near 0 @@ -210,9 +197,7 @@ describe("BOLT12 autowithdraw", () => { // Check payment records on withdrawer const payments = await getPayments(withdrawerToken); - const withdrawal = payments.payments?.find( - (p: any) => p.amount < 0 && p.type === "lightning", - ); + const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning"); expect(withdrawal).toBeTruthy(); expect(withdrawal.fee).toBeGreaterThanOrEqual(0); }, 30000); @@ -259,9 +244,7 @@ describe("BOLT12 autowithdraw", () => { // Check payment record has routing fee const payments = await getPayments(withdrawerToken); - const withdrawal = payments.payments?.find( - (p: any) => p.amount < 0 && p.type === "lightning", - ); + const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning"); expect(withdrawal).toBeTruthy(); // Multi-hop should have non-zero routing fee expect(withdrawal.fee).toBeGreaterThan(0); @@ -290,9 +273,7 @@ describe("BOLT12 autowithdraw", () => { // Get the withdrawal payment record const payments = await getPayments(withdrawerToken); - const withdrawal = payments.payments?.find( - (p: any) => p.amount < 0 && p.type === "lightning", - ); + const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning"); expect(withdrawal).toBeTruthy(); // For a direct peer, actual routing fee should be 0 or very small |
