Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/core/src/reviews/aggregate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ const D_A = "5fe928ae0970844f3c5253d2e85a88788486edcbd96c070334a4a2d0d0154a77";
const D_B = "0".repeat(63) + "1";

function makeReview(over: Partial<ReviewRow> & { d?: string } = {}): ReviewRow {
const pubkey = over.pubkey ?? `pk${Math.random().toString(36).slice(2, 10)}${"0".repeat(50)}`;
const d = over.d ?? D_A;
const kind = 38000 as const;
// `k` defaults to Cashu (38172) — tests in this file don't differentiate
// Cashu vs Fedimint; parse-level `k` handling is covered in parse.test.ts.
// `a` is derived from kind/pubkey/d per NIP-87's `<kind>:<pubkey>:<d>`.
const k = over.k ?? 38172;
return {
pubkey: `pk${Math.random().toString(36).slice(2, 10)}${"0".repeat(50)}`,
kind: 38000,
d: over.d ?? D_A,
pubkey,
kind,
d,
eventId: `${"0".repeat(58)}${Math.random().toString(36).slice(2, 8)}`,
createdAt: 1_700_000_000,
k,
a: `${kind}:${pubkey}:${d}`,
content: "",
rawTags: [],
rating: 5,
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/reviews/rank.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ function dForIndex(n: number): string {
}

function makeReview(over: Partial<ReviewRow> & { pubkey: string; d: string }): ReviewRow {
const kind = 38000 as const;
// `k` defaults to Cashu (38172); rank.test only exercises sort order,
// which is `k`-agnostic. `a` is derived per NIP-87 `<kind>:<pubkey>:<d>`.
const k = over.k ?? 38172;
return {
kind: 38000,
kind,
eventId: `${"0".repeat(58)}${over.pubkey.slice(-6)}`,
createdAt: 1_700_000_000,
k,
a: `${kind}:${over.pubkey}:${over.d}`,
content: "",
rawTags: [],
rating: 5,
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/reviews/upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ const EID_LOW = `${"0".repeat(60)}aaaa`;
const EID_HIGH = `${"0".repeat(60)}ffff`;

function makeReview(over: Partial<ReviewRow> = {}): ReviewRow {
const pubkey = over.pubkey ?? `pk${"0".repeat(60)}1`;
const d = over.d ?? D_VALID;
const kind = 38000 as const;
// `k` defaults to Cashu (38172); one test below overrides to 38173 for the
// Fedimint path. `a` is derived per NIP-87 `<kind>:<pubkey>:<d>`.
const k = over.k ?? 38172;
return {
pubkey: `pk${"0".repeat(60)}1`,
kind: 38000,
d: D_VALID,
pubkey,
kind,
d,
eventId: EID_LOW,
createdAt: 1_700_000_000,
k,
a: `${kind}:${pubkey}:${d}`,
content: "",
rawTags: [],
rating: 5,
Expand Down
Loading