Skip to content

Commit

Permalink
doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pablof7z committed Jan 12, 2025
1 parent 108a1b4 commit 99fe7af
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ndk/src/events/nip19.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion ndk/src/relay/connectivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
3 changes: 2 additions & 1 deletion ndk/src/relay/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions ndk/src/relay/pool/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion ndk/src/relay/subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down
15 changes: 1 addition & 14 deletions ndk/src/subscription/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 99fe7af

Please sign in to comment.