Description
src/db/index.ts and src/starknet/client.ts both have documented reliability behaviors — bounded pool size with DB_POOL_MAX, connection retry with backoff (waitForDbReadiness), and RPC failover with per-endpoint circuit breakers — but none of these are exercised under an actually degraded environment in tests; the test suite mocks happy-path and simple error responses. Add chaos-style tests that saturate the pool and inject RPC timeouts/connection resets to prove the documented degradation behavior actually holds.
Requirements and context
- Add a test that exhausts
DB_POOL_MAX connections concurrently and asserts getPoolStats().waiting behaves as documented and that waitForDbReadiness recovers once connections free up
- Add a test that forces every Starknet RPC endpoint to time out/reset and asserts the circuit breakers in
src/starknet/circuit-breaker.ts open as configured and that src/starknet/client.ts surfaces a clean error rather than hanging
- Keep these tests isolated (a dedicated test suite/tag) so they do not slow down the default
pnpm test run if they are inherently slower
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested execution
Fork the repo and create a branch
git checkout -b test/chaos-db-rpc-failures
Implement changes
- Update/Write:
src/db/index.ts
- Update/Write:
src/starknet/client.ts
- Add/Update tests:
src/db/chaos.test.ts, src/starknet/client.chaos.test.ts
- Add documentation:
docs/starknet/client.md
- Include clear code comments and TS types
- Validate security assumptions
Test and commit
- Run tests:
pnpm test
- Cover edge cases
- Include test output and security notes
Example commit message
test: add chaos tests for DB and RPC failure modes
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
src/db/index.tsandsrc/starknet/client.tsboth have documented reliability behaviors — bounded pool size withDB_POOL_MAX, connection retry with backoff (waitForDbReadiness), and RPC failover with per-endpoint circuit breakers — but none of these are exercised under an actually degraded environment in tests; the test suite mocks happy-path and simple error responses. Add chaos-style tests that saturate the pool and inject RPC timeouts/connection resets to prove the documented degradation behavior actually holds.Requirements and context
DB_POOL_MAXconnections concurrently and assertsgetPoolStats().waitingbehaves as documented and thatwaitForDbReadinessrecovers once connections free upsrc/starknet/circuit-breaker.tsopen as configured and thatsrc/starknet/client.tssurfaces a clean error rather than hangingpnpm testrun if they are inherently slowerSuggested execution
Fork the repo and create a branch
Implement changes
src/db/index.tssrc/starknet/client.tssrc/db/chaos.test.ts,src/starknet/client.chaos.test.tsdocs/starknet/client.mdTest and commit
pnpm testExample commit message
Guidelines