bug: empty relay list fallback
This commit is contained in:
parent
5b3edc0f59
commit
a7fa996e84
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Snort nostr system package",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
@ -62,8 +62,8 @@ export function splitByWriteRelays(cache: RelayCache, filter: ReqFilter): Array<
|
||||
};
|
||||
});
|
||||
|
||||
const missing = allRelays.filter(a => a.relays === undefined);
|
||||
const hasRelays = allRelays.filter(a => a.relays !== undefined);
|
||||
const missing = allRelays.filter(a => a.relays === undefined || a.relays.length === 0);
|
||||
const hasRelays = allRelays.filter(a => a.relays !== undefined && a.relays.length > 0);
|
||||
const relayUserMap = hasRelays.reduce((acc, v) => {
|
||||
for (const r of unwrap(v.relays)) {
|
||||
if (!acc.has(r.url)) {
|
||||
|
31
packages/system/tests/GossipModel.test.ts
Normal file
31
packages/system/tests/GossipModel.test.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { splitAllByWriteRelays } from "../src/GossipModel"
|
||||
|
||||
describe("GossipModel", () => {
|
||||
it("should not output empty", () => {
|
||||
const Relays = {
|
||||
get: (pk?: string) => {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
const a = [{
|
||||
"until": 1686651693,
|
||||
"limit": 200,
|
||||
"kinds": [
|
||||
1,
|
||||
6,
|
||||
6969
|
||||
],
|
||||
"authors": [
|
||||
"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"
|
||||
]
|
||||
}];
|
||||
|
||||
const output = splitAllByWriteRelays(Relays, a);
|
||||
expect(output).toEqual([
|
||||
{
|
||||
relay: "",
|
||||
filters: a
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user