- commit
- ad32f9843594c08f72376a02dc66b6f7bd77eb49
- parent
- f919153bb9862cc760b7a86e503a316168b27c55
- author
- Dami <dami.etoile@gmail.com>
| M | test/ | 9 | +++++++-- |
@@ -3,7 +3,7 @@ import { deliveryTick, queueDelivery } from "../../src/delivery.ts";
33 import type { Relay } from "../../src/relay.ts";44 import { describe, expect, it } from "vitest";55 import { generateSecretKey } from "nostr-tools/pure";6-import { ev, pk, rpc, alarm } from "../helpers/relay.ts";6+import { ev, pk, rpc, alarm, sleep } from "../helpers/relay.ts";77 import { WS } from "../helpers/ws.ts";88 99 describe("NIP-65 automatic delivery", () => {@@ -39,7 +39,12 @@ describe("NIP-65 automatic delivery", () => {
3939 expect((await sourceSocket.ok(list)).ok).toBe(true);4040 const note = ev(owner, 1, "routed");4141 expect((await sourceSocket.ok(note)).ok).toBe(true);42- await alarm("auto-source");42+ for (let attempt = 0; attempt < 40; attempt++) {43+ await alarm("auto-source");44+ const status = await runInDurableObject(env.RELAY.getByName("auto-source"), (relay: Relay) => relay.sql.exec<{ status: string }>(`SELECT status FROM delivery_queue WHERE event_id=?`, note.id).toArray()[0]?.status ?? "");45+ if (status !== "pending") break;46+ await sleep(25);47+ }4348 expect((await targetSocket.req({ ids: [note.id] })).map((e) => e.id)).toEqual([note.id]);4449 const status = await rpc(source, owner, "deliverystatus");4550 expect(status.result).toEqual(expect.arrayContaining([expect.objectContaining({ event_id: note.id, target: "wss://" + target, status: "accepted" })]));