Testing
How tests are organized in v2-monorepo and how to add your own.
Unit tests (SDK)
cd packages/sdk
pnpm test # runs vitest, no chain interaction
pnpm typecheck # tsc --noEmit
Located in packages/sdk/test/unit/. Cover individual services (PoseidonHashService, NoteComputationService) and schemas. CryptoService tests live in packages/sdk/test/services/.
Integration tests (SDK)
cd apps/sample
cp tests/integration/.env.example tests/integration/.env
# Fill in real Sepolia values
pnpm test:integration
End-to-end against the real Sepolia testnet. Slow but high-confidence: the test suite makes deposits, runs transfers, and exits the pool.
Contracts (forge)
cd packages/contracts
forge test # full suite
forge test --match-test Transact -vvv # one test, verbose trace
Located in packages/contracts/test/. Forks Sepolia state, exercises end-to-end transact flows including verifier contract calls.
Circuits (circomkit)
cd packages/circuits
pnpm test # runs circomkit's proving tests
Builds witnesses, runs the prover, verifies proofs. Useful for changes that modify circuit signal layout.
Adding a new test that covers a real flow
- Pick the layer the change lives at (SDK unit / integration / contracts / circuits).
- Read an existing test in that layer as a template.
- For integration tests, expect long run times: forks, real RPC, and real proofs.
- For new contract behaviors, add both a unit-style test (single revert path) and an integration test (full E2E flow).
CI
GitHub Actions runs several workflows. SDK unit tests and typecheck, contract tests, circuit tests, and the relayer CI run automatically on push and pull request. Contract integration tests run in CI as well, against mainnet and Sepolia forks using RPC secrets, and the relayer has its own end-to-end workflow on pull request. The SDK and sample end-to-end integration suite is the exception: it runs only on manual workflow_dispatch and needs configured secrets (an RPC endpoint, a funded key, and the postman-role key), so it is not part of the automatic PR gate.