Improvements to enablePing() & tests (#506)

https://github.com/nbd-wtf/nostr-tools/pull/506
This commit is contained in:
Chris McCormick
2025-09-29 21:41:40 +08:00
committed by GitHub
parent c9ff51e278
commit 226d7d07e2
4 changed files with 93 additions and 17 deletions

View File

@@ -26,6 +26,7 @@ export class MockRelay {
public url: string
public secretKeys: Uint8Array[]
public preloadedEvents: Event[]
public unresponsive: boolean = false
constructor(url?: string | undefined) {
serial++
@@ -48,6 +49,7 @@ export class MockRelay {
let subs: { [subId: string]: { conn: any; filters: Filter[] } } = {}
conn.on('message', (message: string) => {
if (this.unresponsive) return
const data = JSON.parse(message)
switch (data[0]) {