-
Notifications
You must be signed in to change notification settings - Fork 40
[BOUNTY] Add Comprehensive Edge Case Tests for All Circuits #3
Copy link
Copy link
Open
Labels
bountyHas USDC reward via Drips WaveHas USDC reward via Drips WavecircuitsNoir circuit workNoir circuit workgood first issueBeginner-friendlyBeginner-friendlypriority: highUrgentUrgenttestingTest coverageTest coverage
Description
[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
- At least 15 new test cases for commitment circuit
- At least 20 new test cases for withdrawal circuit
- At least 10 new test cases for merkle library
- All tests pass:
nargo test - Test coverage report shows >90% coverage
- Each test has descriptive comments explaining the scenario
- Add
circuits/TEST_VECTORS.mddocumenting test cases
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bountyHas USDC reward via Drips WaveHas USDC reward via Drips WavecircuitsNoir circuit workNoir circuit workgood first issueBeginner-friendlyBeginner-friendlypriority: highUrgentUrgenttestingTest coverageTest coverage