diff --git a/ndk/src/events/nip19.test.ts b/ndk/src/events/nip19.test.ts index 31d22678..fa58128e 100644 --- a/ndk/src/events/nip19.test.ts +++ b/ndk/src/events/nip19.test.ts @@ -32,7 +32,7 @@ describe("NDKEvent", () => { pubkey: "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", tags: [["d", "1234"]], } as NostrEvent); - event.relay = new NDKRelay("wss://relay.f7z.io/"); + event.relay = new NDKRelay("wss://relay.f7z.io/", undefined, ndk); const a = event.encode(); expect(a).toBe( @@ -47,7 +47,7 @@ describe("NDKEvent", () => { pubkey: "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", tags: [["e", "1234"]], } as NostrEvent); - event.relay = new NDKRelay("wss://relay.f7z.io/"); + event.relay = new NDKRelay("wss://relay.f7z.io/", undefined, ndk); const a = event.encode(); expect(a).toBe( diff --git a/ndk/src/relay/connectivity.test.ts b/ndk/src/relay/connectivity.test.ts index b672713a..bba862c0 100644 --- a/ndk/src/relay/connectivity.test.ts +++ b/ndk/src/relay/connectivity.test.ts @@ -12,7 +12,7 @@ describe("NDKRelayConnectivity", () => { beforeEach(() => { ndk = new NDK(); - relay = new NDKRelay("wss://test.relay"); + relay = new NDKRelay("wss://test.relay", undefined, ndk); connectivity = new NDKRelayConnectivity(relay, ndk); }); diff --git a/ndk/src/relay/index.test.ts b/ndk/src/relay/index.test.ts index fdd9664b..b9e96397 100644 --- a/ndk/src/relay/index.test.ts +++ b/ndk/src/relay/index.test.ts @@ -3,7 +3,8 @@ import { NDK } from "../ndk/index.js"; import { NDKRelayStatus } from "./index.js"; const ndk = new NDK(); -const relay = new NDKRelay("ws://localhost/"); +const relayUrl = "ws://localhost/"; +const relay = new NDKRelay(relayUrl, undefined, ndk); ndk.addExplicitRelay(relay, undefined, false); // function mockConnect(relay: NDKRelay) { diff --git a/ndk/src/relay/pool/index.test.ts b/ndk/src/relay/pool/index.test.ts index 6d47daae..19f64a49 100644 --- a/ndk/src/relay/pool/index.test.ts +++ b/ndk/src/relay/pool/index.test.ts @@ -5,12 +5,13 @@ import { NDKRelaySet } from "../sets/index.js"; describe("NDKPool", () => { it("refuses connecting to blacklisted relays", async () => { - const blacklistedRelay = new NDKRelay("wss://url1"); + const blacklistedRelayUrl = "wss://url1"; const ndk = new NDK({ - blacklistRelayUrls: [blacklistedRelay.url], + blacklistRelayUrls: [blacklistedRelayUrl], }); const { pool } = ndk; - pool.addRelay(blacklistedRelay); + const relay = new NDKRelay(blacklistedRelayUrl, undefined, ndk); + pool.addRelay(relay); expect(pool.relays.size).toEqual(0); }); diff --git a/ndk/src/relay/subscription.test.ts b/ndk/src/relay/subscription.test.ts index 113efc52..1b329a2b 100644 --- a/ndk/src/relay/subscription.test.ts +++ b/ndk/src/relay/subscription.test.ts @@ -49,7 +49,7 @@ describe("NDKRelaySubscription", () => { let ndkRelaySubscription: NDKRelaySubscription; beforeEach(() => { - ndkRelaySubscription = new NDKRelaySubscription(relay); + ndkRelaySubscription = new NDKRelaySubscription(relay, null, ndk.subManager); ndkRelaySubscription.debug = debug("test"); }); diff --git a/ndk/src/subscription/index.ts b/ndk/src/subscription/index.ts index 2540c18a..76e03049 100644 --- a/ndk/src/subscription/index.ts +++ b/ndk/src/subscription/index.ts @@ -481,7 +481,7 @@ export class NDKSubscription extends EventEmitter<{ } } - if (this.ndk.cacheAdapter) { + if (this.ndk.cacheAdapter && !this.opts.dontSaveToCache) { this.ndk.cacheAdapter.setEvent(ndkEvent, this.filters, relay); } } @@ -512,19 +512,6 @@ export class NDKSubscription extends EventEmitter<{ } } - if (!fromCache && !optimisticPublish && relay) { - this.trackPerRelay(event, relay); - - if (this.ndk.cacheAdapter && !this.opts.dontSaveToCache) { - this.ndk.cacheAdapter.setEvent(event, this.filters, relay); - } - - this.eventFirstSeen.set(event.id, Date.now()); - } else { - this.eventFirstSeen.set(event.id, 0); - } - - this.emit("event", event, relay, this); this.lastEventReceivedAt = Date.now(); }