[BOUNTY] Add Comprehensive Edge Case Tests for All Circuits
Description
Expand test coverage for commitment, withdrawal, and merkle circuits to include edge cases, boundary conditions, and attack scenarios. Current tests cover happy paths but miss critical edge cases that could lead to vulnerabilities.
Scope
Commitment Circuit Tests (circuits/commitment/src/main.nr)
Add tests for:
- Zero nullifier (should fail or handle gracefully)
- Zero secret (should fail or handle gracefully)
- Maximum field values (2^254 - 1 for BN254)
- Identical nullifier and secret
- Commitment collision detection
- Invalid field elements
Withdrawal Circuit Tests (circuits/withdraw/src/main.nr)
Add tests for:
- Invalid Merkle proof (wrong path, wrong indices)
- Merkle proof with zero commitment
- Root mismatch scenarios
- Nullifier reuse detection
- Invalid recipient address format
- Maximum tree depth edge cases (depth 20)
- Sibling hash validation
Merkle Library Tests (circuits/merkle/src/lib.nr)
Add tests for:
- Empty tree root calculation
- Single leaf tree
- Full tree (2^20 leaves)
- Invalid tree depth
- Hash function consistency
Test Infrastructure
- Create
circuits/lib/src/validation/test_helpers.nr:
- Generate valid/invalid test vectors
- Merkle tree test fixtures
- Known answer tests (KAT) from other implementations
- Add fuzzing test cases (random inputs)
Acceptance Criteria
Technical Notes
- Use Noir's
#[test] attribute for each test
- Use
assert() for positive tests, expect failures for negative tests
- Reference Tornado Cash test vectors for compatibility
- Consider property-based testing patterns
Labels: bounty,circuits,testing,good first issue,priority: high
[BOUNTY] Add Comprehensive Edge Case Tests for All Circuits
Description
Expand test coverage for commitment, withdrawal, and merkle circuits to include edge cases, boundary conditions, and attack scenarios. Current tests cover happy paths but miss critical edge cases that could lead to vulnerabilities.
Scope
Commitment Circuit Tests (
circuits/commitment/src/main.nr)Add tests for:
Withdrawal Circuit Tests (
circuits/withdraw/src/main.nr)Add tests for:
Merkle Library Tests (
circuits/merkle/src/lib.nr)Add tests for:
Test Infrastructure
circuits/lib/src/validation/test_helpers.nr:Acceptance Criteria
nargo testcircuits/TEST_VECTORS.mddocumenting test casesTechnical Notes
#[test]attribute for each testassert()for positive tests, expect failures for negative testsLabels: bounty,circuits,testing,good first issue,priority: high