Testing
Integration Tests
Integration tests are in web/tests/ and use Vitest.
All of the following must be running:
Hardhat node at localhost:9000
All web services (rpc-proxy, relayer, guard, faucet)
Caddy HTTPS reverse proxy
# From web/ root
pnpm test
# From tests directory
cd tests && pnpm test
# Run a specific test
cd tests && pnpm test deposit.test.ts
Test Idempotency
Tests are designed to be idempotent — they can run repeatedly without restarting services or clearing state. They handle:
Previously registered on-chain receiving keys
No need to clear apps/rpc-proxy/lmdb-data/ or redeploy contracts between test runs.
Exception: If the Hardhat node is restarted, run ./wipe-lmdb.sh to erase cached LMDB data and restart web services.
Contract tests use the Node.js test runner with Hardhat v3 + viem.
Key test files:
Complete deposit → shielded transfer → withdrawal flow
Merkle tree consistency between contract and JS
Note encryption/decryption
Deposit and guard approval flow
After changing Solidity struct definitions, always clean before compiling:
Stale ABI artifacts cause silent encoding mismatches.
Library tests verify cryptographic operations using pre-computed fixtures from fixtures.nr.
Manual Testing Checklist
For a comprehensive manual testing flow covering all operations, see the manual testing guide. The flow covers:
Onboarding (key generation, network switch, faucet, registration)
Swaps (ETH→ERC20, ERC20→ETH, ERC20→ERC20)
Withdrawals (ETH + ERC-20)
Shielded transfers (ETH + ERC-20)
Multi-device verification