1import { describe, it, expect } from "vitest";2import { newEvent, newKey, pub, now, sockets } from "./helpers.ts";34const connect = sockets();56describe("NIP-09 deletion", () => {7 it("lets only the author delete, keeps deleted ids out, ignores strangers", async () => {8 const sk = newKey();9 const other = newKey();10 const alice = await connect();11 const stranger = await connect();12 const carol = await connect();13 const note = newEvent(sk, 1, "regret", [], now() - 100);14 await alice.publish(note);1516 await stranger.publish(newEvent(other, 5, "", [["e", note.id]]));17 expect((await carol.req({ ids: [note.id] })).events.length).toBe(1);1819 await alice.publish(newEvent(sk, 5, "", [["e", note.id], ["k", "1"]]));20 expect((await carol.req({ ids: [note.id] })).events.length).toBe(0);21 alice.send("EVENT", note);22 expect(await alice.expectOK(note.id, false)).toMatch(/^blocked:/);23 });2425 it("deletes addressable versions up to the request time via a tags", async () => {26 const sk = newKey();27 const c = await connect();28 const t0 = now() - 100;29 await c.publish(newEvent(sk, 30023, "v1", [["d", "x"]], t0));30 await c.publish(newEvent(sk, 5, "", [["a", `30023:${pub(sk)}:x`]], t0 + 1));31 expect((await c.req({ kinds: [30023], authors: [pub(sk)], "#d": ["x"] })).events.length).toBe(0);32 });33});