[Testkit] Nostr identity + trust engine coverage (T25–T36) #55
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
The Nostr identity and trust engine is a core economic primitive but has zero testkit coverage. Adding T25–T36 exercises the full identity lifecycle: token exchange, trust tiers, session and job decorating with pubkey, reputation decay.
Done looks like
GET /api/identity/challengereturns{ challenge, expiresAt }POST /api/identity/verifywith invalid signature → 400POST /api/identity/verifywith valid signature →{ token, pubkey, tier }GET /api/identity/mewith valid token → identity object with trust fieldsGET /api/identity/mewith expired/invalid token → 401POST /api/jobswith valid Nostr token → job created withnostrPubkeyset; verify inGET /api/jobs/:idPOST /api/jobswith invalid Nostr token → 401POST /api/sessionswith valid Nostr token → session created withnostrPubkeysetGET /api/sessions/:idwith Nostr token →trust_tierfield present in responseGET /api/identity/meafter a successful job →jobs_completedincrementedPOST /api/identity/me/decayin test mode → verifytrust_scoredecrementedGET /api/identity/leaderboard→ returns array sorted by trust scoreTasks
artifacts/api-server/src/routes/testkit.tsbefore Summary blockPOST /api/identity/me/decaytest-only endpoint (disabled in production) that triggers one decay cycle for the identity in the requestRelevant files
artifacts/api-server/src/routes/testkit.tsartifacts/api-server/src/routes/identity.tsartifacts/api-server/src/lib/trust.tsPR created: http://143.198.27.163:3000/replit/timmy-tower/pulls/106
Changes:
TrustService.decayOnce()(trust.ts) — test-only method that subtracts oneDECAY_PER_DAYpoint immediately without the normal 30-day absence threshold.POST /api/identity/me/decay(identity.ts) — test-only endpoint (returns 404 in production). Authenticated withX-Nostr-Token, triggers one decay cycle and returnspreviousScore/newScore/newTier.GET /api/identity/leaderboard(identity.ts) — public endpoint returning top 20 identities sorted bytrustScoredesc withpubkey,trustScore,tier,interactionCount.T41–T45 (testkit.ts) — five new tests sharing a single inline node preamble (challenge→sign→verify→token):
nostrPubkeyin response matches identitynostrPubkeyin response matches identitytier,score,interactionCountall presentnewScore ≤ previousScore(graceful skip in prod)Note: T25–T36 already existed in the codebase (added by the gemini NIP-07 PR). The new tests are numbered T41–T45 to avoid conflicts with those existing tests.