1import { describe, it, expect } from "vitest";2import { newEvent, newKey, pub, now, RELAY_URL, sockets } from "./helpers.ts";34const connect = sockets();56describe("NIP-62 vanish", () => {7 it("deletes everything from the pubkey up to the request, plus gift wraps to it, and blocks resurrection", async () => {8 const sk = newKey();9 const other = newKey();10 const c = await connect();11 const t0 = now() - 100;12 const note = newEvent(sk, 1, "regret", [], t0);13 const meta = newEvent(sk, 0, "{}", [], t0);14 const wrap = newEvent(other, 1059, "dm", [["p", pub(sk)]], t0);15 const keep = newEvent(other, 1, "unrelated", [], t0);16 for (const e of [note, meta, wrap, keep]) await c.publish(e);1718 let v = newEvent(sk, 62, "", [["relay", "wss://other.example"]], t0 + 1);19 c.send("EVENT", v);20 await c.expectOK(v.id, false);21 expect((await c.req({ authors: [pub(sk)] })).events.length).toBe(2);2223 v = newEvent(sk, 62, "bye", [["relay", RELAY_URL]], t0 + 1);24 await c.publish(v);25 expect((await c.req({ authors: [pub(sk)] })).events).toEqual([]);26 expect((await c.req({ ids: [keep.id] })).events.length).toBe(1);27 const rc = await connect();28 await rc.auth(sk);29 expect((await rc.req({ kinds: [1059], "#p": [pub(sk)] })).events).toEqual([]);3031 c.send("EVENT", note);32 expect(await c.expectOK(note.id, false)).toMatch(/^blocked:/);33 await c.publish(newEvent(sk, 1, "fresh start", [], t0 + 2));3435 v = newEvent(other, 62, "", [["relay", "ALL_RELAYS"]], t0 + 3);36 await c.publish(v);37 expect((await c.req({ authors: [pub(other)] })).events).toEqual([]);38 });39});