I did a fucked up polymorphism

This commit is contained in:
Alex Gleason 2025-02-22 20:56:53 -06:00
parent f893a81464
commit 4f46a69131
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 6 additions and 15 deletions

View file

@ -13,10 +13,7 @@ import { createTestDB } from '@/test.ts';
import cashuRoute from './cashu.ts'; import cashuRoute from './cashu.ts';
import { walletSchema } from '@/schema.ts'; import { walletSchema } from '@/schema.ts';
Deno.test('PUT /wallet must be successful', { Deno.test('PUT /wallet must be successful', async () => {
sanitizeOps: false,
sanitizeResources: false,
}, async () => {
await using test = await createTestRoute(); await using test = await createTestRoute();
const { route, signer, sk, relay } = test; 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' }); assertObjectMatch(body, { error: 'Bad schema' });
}); });
Deno.test('PUT /wallet must NOT be successful: wallet already exists', { Deno.test('PUT /wallet must NOT be successful: wallet already exists', async () => {
sanitizeOps: false,
sanitizeResources: false,
}, async () => {
await using test = await createTestRoute(); await using test = await createTestRoute();
const { route, sk, relay } = test; 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 😏' }); assertEquals(body2, { error: 'You already have a wallet 😏' });
}); });
Deno.test('GET /wallet must be successful', { Deno.test('GET /wallet must be successful', async () => {
sanitizeOps: false,
sanitizeResources: false,
}, async () => {
await using test = await createTestRoute(); await using test = await createTestRoute();
const { route, sk, relay, signer } = test; const { route, sk, relay, signer } = test;

View file

@ -164,9 +164,9 @@ export class DittoPgStore extends NPostgres {
opts: { signal?: AbortSignal; timeout?: number } = {}, opts: { signal?: AbortSignal; timeout?: number } = {},
): Promise<undefined> { ): Promise<undefined> {
try { try {
await this.transaction(async (store, kysely) => { await super.transaction(async (store, kysely) => {
await updateStats({ event, store, kysely }); await updateStats({ event, store, kysely: kysely as unknown as Kysely<DittoTables> });
await super.event(event, opts); await store.event(event, opts);
}); });
} catch (e) { } catch (e) {
// If the failure is only because of updateStats (which runs first), insert the event anyway. // If the failure is only because of updateStats (which runs first), insert the event anyway.