You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tests: NIP-42 and NIP-98 have no unit tests, nostreamd has none, and LMDB recovery is untested #1215
Measured on rewrite/main at ff045445. The security-relevant paths with no test at all:
crates/nostream-core/src/nip42.rs is 377 lines with zero test attributes and no mod tests. NIP-42 is the authentication path; the relay's handler tests cover the seven outcomes over the wire, but the module's own parsing and validation has no unit test, so a change that keeps the wire tests green while breaking an edge case in the module has nothing to fail.
crates/nostream-core/src/nip98.rs is 30 lines and has no direct test anywhere.verify is reached only through callers that exercise other behaviour.
crates/nostreamd/src has zero test attributes. The composition root — the place this repository has already been wrong once about which backend is wired — is untested by construction.
LMDB has no corruption, torn-write or crash-recovery test, and its rollback path is untested, so the failure mode that matters most for an embedded store is asserted only by the code's shape.
NIP-50 ranking has no dedicated test on either backend; the store's search tests assert membership and order on recorded rows, not the ranking itself against a fresh index.
Acceptance:
nip42.rs and nip98.rs each carry unit tests with inversions: a signature that verifies under one tag and not another, a replay outside the window, a NIP-98 token with the wrong u or a stale created_at.
nostreamd has a test that asserts the wired backend, so the "resolves the name then discards it" defect cannot recur silently.
An LMDB test opens a store, kills the process mid-write, and asserts the reopened environment is consistent — or documents why the guarantee comes from LMDB's own design and pins that with a test of the recovery path the code actually has.
NIP-50 ranking is asserted against a freshly built index on both backends, by rank position rather than membership.
Hi @cameri, I'd like to work on this one. While reading rewrite/main (1514e7f) I noticed nip98::verify is still the Phase 1 stub: it returns NotImplemented and nothing calls it, so it needs the port from src/utils/nip98.ts before there's anything to test. The nostreamd item also looks covered already by tests/store_wiring.rs from the #1206 fix.
I'd split the rest into two PRs. First, unit tests for nip42::authenticate, one per AuthFailure variant with inversions: a signature that verifies under one tag but not another, created_at just inside and just outside the 600 s window, relay host matching. The NIP-98 port goes in the same PR, tested with a wrong u, wrong method, stale created_at and the payload hash.
Second, LMDB: kill a writer process mid-write and check the reopened store, test the transaction.abort() rollback path, and assert NIP-50 ranking by position on a fresh index for both backends.
Should the NIP-98 port go in here, or is it still planned as job 005?
A few facts that will save you a wasted push, since the issue is the map rather than the route:
Branch from rewrite/main, not main — the measurements in this issue are against rewrite/main (ff045445), and main is the TypeScript tree. A PR opened against main will not see these files.
Smallest first, and separate PRs are better than one large one.nip98.rs is 30 lines with a single verify; take it, then nip42.rs parsing/validation, then the nostreamd wired-backend assertion, then NIP-50 ranking.
The LMDB box is deliberately open. "A test that kills the process mid-write" may not be reachable in CI; the acceptance line allows a documented argument plus a test of the recovery path the code actually has. If you conclude that, say so and pin the part that is real — that is a pass, not a dodge.
CI wants a changeset.Changeset Required runs pnpm exec changeset status --since origin/rewrite/main; a short .changeset/<name>.md satisfies it (.changeset/prometheus-metrics.md is a good shape to copy).
If any box turns out to need a design decision rather than a test, write that here instead of guessing — a wrong test is worse than a missing one.
No need to take all five. Land one well and claim the next.
First piece is up: Ansh-699#2 (one commit, d9d1966, on rewrite/mainead3997). Could you cherry-pick it?
nip98::verify was still the Phase 1 stub, so this ports verifyNip98Auth from src/utils/nip98.ts with the same check order and reasons (new CoreError::InvalidNip98), plus 24 unit tests including a wrong u, a wrong method, a stale created_at and the payload hash. The new arguments come from the TS input: an optional body, the payload policy and now. The header length limit stays at the 2048 default since no caller passes it. Replay stays with the admin job (ADR 0010), and the admin gate is untouched (ADR 0014 D6). Once this lands I'll take the nip42.rs tests.
Ansh-699's nip98::verify is in as #1355 (cherry-picked -x from their fork commit d9d1966): fmt, clippy and cargo test -p nostream-core green, 24 new unit tests. Screening found nothing: no workflow, dependency or install-time change, no hidden characters. The nip42.rs tests remain open.
Activity
Ansh-699 commentedon Nov 29, 2026
Hi @cameri, I'd like to work on this one. While reading
rewrite/main(1514e7f) I noticednip98::verifyis still the Phase 1 stub: it returnsNotImplementedand nothing calls it, so it needs the port fromsrc/utils/nip98.tsbefore there's anything to test. The nostreamd item also looks covered already bytests/store_wiring.rsfrom the #1206 fix.I'd split the rest into two PRs. First, unit tests for
nip42::authenticate, one perAuthFailurevariant with inversions: a signature that verifies under one tag but not another,created_atjust inside and just outside the 600 s window, relay host matching. The NIP-98 port goes in the same PR, tested with a wrongu, wrong method, stalecreated_atand the payload hash.Second, LMDB: kill a writer process mid-write and check the reopened store, test the
transaction.abort()rollback path, and assert NIP-50 ranking by position on a fresh index for both backends.Should the NIP-98 port go in here, or is it still planned as job 005?
cameri commentedon Nov 29, 2026
@Ansh-699 assigned to you
chappie-daemon commentedon Nov 29, 2026
A few facts that will save you a wasted push, since the issue is the map rather than the route:
rewrite/main, notmain— the measurements in this issue are againstrewrite/main(ff045445), andmainis the TypeScript tree. A PR opened againstmainwill not see these files.nip98.rsis 30 lines with a singleverify; take it, thennip42.rsparsing/validation, then thenostreamdwired-backend assertion, then NIP-50 ranking.Changeset Requiredrunspnpm exec changeset status --since origin/rewrite/main; a short.changeset/<name>.mdsatisfies it (.changeset/prometheus-metrics.mdis a good shape to copy).No need to take all five. Land one well and claim the next.
Ansh-699 commentedon Dec 2, 2026
First piece is up: Ansh-699#2 (one commit,
d9d1966, onrewrite/mainead3997). Could you cherry-pick it?nip98::verifywas still the Phase 1 stub, so this portsverifyNip98Authfromsrc/utils/nip98.tswith the same check order and reasons (newCoreError::InvalidNip98), plus 24 unit tests including a wrongu, a wrong method, a stalecreated_atand the payload hash. The new arguments come from the TS input: an optional body, the payload policy andnow. The header length limit stays at the 2048 default since no caller passes it. Replay stays with the admin job (ADR 0010), and the admin gate is untouched (ADR 0014 D6). Once this lands I'll take thenip42.rstests.chappie-daemon commentedon Dec 3, 2026
Ansh-699's
nip98::verifyis in as #1355 (cherry-picked-xfrom their fork commitd9d1966): fmt, clippy andcargo test -p nostream-coregreen, 24 new unit tests. Screening found nothing: no workflow, dependency or install-time change, no hidden characters. Thenip42.rstests remain open.cameri commentedon Dec 3, 2026
Thank you @Ansh-699