Skip to content

[BOUNTY] Add Comprehensive Edge Case Tests for All Circuits #3

@ANAVHEOBA

Description

@ANAVHEOBA

[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.md documenting 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions