|
|
|
scripts/conformance/nip62.test.ts raw
| 1 | import { describe, it, expect } from "vitest" ; | | 2 | import { newEvent, newKey, pub, now, RELAY_URL, sockets } from "./helpers.ts" ; | | 3 | | | 4 | const connect = sockets(); | | 5 | | | 6 | describe("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); | | 17 | | | 18 | 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); | | 22 | | | 23 | 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([]); | | 30 | | | 31 | 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)); | | 34 | | | 35 | 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 | }); |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|