Skip to content

Add chaos tests simulating Postgres pool exhaustion and Starknet RPC timeouts against src/db/index.ts and src/starknet/client.ts #685

Description

@Jagadeeshftw

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebackendBackend / API worktestingTests and coverage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions