mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix firehose
This commit is contained in:
parent
6b3f5ac8a6
commit
026568ea71
2 changed files with 12 additions and 5 deletions
|
|
@ -6,7 +6,8 @@ import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
|
||||||
import { DittoPool } from './DittoPool.ts';
|
import { DittoPool } from './DittoPool.ts';
|
||||||
|
|
||||||
Deno.test('DittoPool.reqRouter', async (t) => {
|
Deno.test('DittoPool.reqRouter', async (t) => {
|
||||||
const conf = new DittoConf(new Map([['DITTO_NSEC', nip19.nsecEncode(generateSecretKey())]]));
|
const nsec = generateSecretKey();
|
||||||
|
const conf = new DittoConf(new Map([['DITTO_NSEC', nip19.nsecEncode(nsec)]]));
|
||||||
const relay = new MockRelay();
|
const relay = new MockRelay();
|
||||||
|
|
||||||
const pool = new DittoPool({ conf, relay });
|
const pool = new DittoPool({ conf, relay });
|
||||||
|
|
@ -58,6 +59,16 @@ Deno.test('DittoPool.reqRouter', async (t) => {
|
||||||
|
|
||||||
assertEquals(reqRoutes, expected);
|
assertEquals(reqRoutes, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await t.step('no authors with fallback', async () => {
|
||||||
|
const fallback = genEvent({ kind: 10002, tags: [['r', ditto]] }, nsec);
|
||||||
|
await relay.event(fallback);
|
||||||
|
|
||||||
|
const reqRoutes = await pool.reqRouter([{ kinds: [1] }]);
|
||||||
|
const expected = new Map([[ditto, [{ kinds: [1] }]]]);
|
||||||
|
|
||||||
|
assertEquals(reqRoutes, expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function generateKeypair(): { pk: string; sk: Uint8Array } {
|
function generateKeypair(): { pk: string; sk: Uint8Array } {
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,6 @@ export class DittoPool extends NPool<NRelay1> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!authors.size) {
|
|
||||||
return routes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const pubkey = await conf.signer.getPublicKey();
|
const pubkey = await conf.signer.getPublicKey();
|
||||||
const map = new Map<string, NostrEvent>();
|
const map = new Map<string, NostrEvent>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue