From 4f46a69131d72f9860eaa0e9f5c4e0569947fc0c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 22 Feb 2025 20:56:53 -0600 Subject: [PATCH] I did a fucked up polymorphism --- packages/ditto/controllers/api/cashu.test.ts | 15 +++------------ packages/ditto/storages/DittoPgStore.ts | 6 +++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/ditto/controllers/api/cashu.test.ts b/packages/ditto/controllers/api/cashu.test.ts index 85803f18..75017b11 100644 --- a/packages/ditto/controllers/api/cashu.test.ts +++ b/packages/ditto/controllers/api/cashu.test.ts @@ -13,10 +13,7 @@ import { createTestDB } from '@/test.ts'; import cashuRoute from './cashu.ts'; import { walletSchema } from '@/schema.ts'; -Deno.test('PUT /wallet must be successful', { - sanitizeOps: false, - sanitizeResources: false, -}, async () => { +Deno.test('PUT /wallet must be successful', async () => { await using test = await createTestRoute(); const { route, signer, sk, relay } = test; @@ -101,10 +98,7 @@ Deno.test('PUT /wallet must NOT be successful: wrong request body/schema', async assertObjectMatch(body, { error: 'Bad schema' }); }); -Deno.test('PUT /wallet must NOT be successful: wallet already exists', { - sanitizeOps: false, - sanitizeResources: false, -}, async () => { +Deno.test('PUT /wallet must NOT be successful: wallet already exists', async () => { await using test = await createTestRoute(); const { route, sk, relay } = test; @@ -127,10 +121,7 @@ Deno.test('PUT /wallet must NOT be successful: wallet already exists', { assertEquals(body2, { error: 'You already have a wallet 😏' }); }); -Deno.test('GET /wallet must be successful', { - sanitizeOps: false, - sanitizeResources: false, -}, async () => { +Deno.test('GET /wallet must be successful', async () => { await using test = await createTestRoute(); const { route, sk, relay, signer } = test; diff --git a/packages/ditto/storages/DittoPgStore.ts b/packages/ditto/storages/DittoPgStore.ts index bf6babb5..619495c0 100644 --- a/packages/ditto/storages/DittoPgStore.ts +++ b/packages/ditto/storages/DittoPgStore.ts @@ -164,9 +164,9 @@ export class DittoPgStore extends NPostgres { opts: { signal?: AbortSignal; timeout?: number } = {}, ): Promise { try { - await this.transaction(async (store, kysely) => { - await updateStats({ event, store, kysely }); - await super.event(event, opts); + await super.transaction(async (store, kysely) => { + await updateStats({ event, store, kysely: kysely as unknown as Kysely }); + await store.event(event, opts); }); } catch (e) { // If the failure is only because of updateStats (which runs first), insert the event anyway.