digidem / digidem/comapeo-core-react-native
Backend test infrastructure + init handler tests
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 1
- Forks
- 0
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 9
Description
Context
PR #36 added the rootkey handshake ({type:"init",rootKey:"<base64>"}) and structured error-frame broadcast on the control socket. The native side (Android FGS + iOS NodeJSService) and the JS bridge both got direct test coverage, but the backend validation logic in backend/index.js did not.
Specifically untested today:
inithandler: rejects non-stringrootKey, rejects wrong-length-after-decode, ignores second init after consumption.handleFatal/uncaughtExceptionpath: tagged-phase routing, broadcast-then-exit, the 100ms flush wait.SimpleRpcServer.broadcastError: per-client try/catch, frame shape.
Why deferred
The backend/ directory has no test runner today (no mocha/tap/jest, no *.test.js invocation in package.json). Adding meaningful coverage means:
- Pick + add a test runner (likely
node --testfor zero-deps). - Refactor the inline
inithandler inbackend/index.jsinto something importable (or build a small test harness that drives the full process viachild_process.spawn+ a fake control-socket client).
PR #36 review explicitly deferred this as out of scope for the rootkey landing.
Acceptance
- Test runner wired up (likely
node --test, or align with whatever the rest of the repo standardises on). -
inithandler: malformed payload → process exits non-zero with broadcast{type:"error",phase:"init",…}. - Construction failure (e.g. malformed
privateStorageDir): broadcast{type:"error",phase:"construct",…}before exit. - Uncaught throw mid-runtime: same broadcast with
phase:"runtime".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with backend/index.js and package.json, then review PR #36 for the deferred behavior. Choose and wire a test runner, and inspect the init, handleFatal/uncaughtException, and SimpleRpcServer.broadcastError paths. Done means tests cover malformed init, construction failure, runtime throws, error phases, client handling, and broadcast-before-exit behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100