Skip to content

feat: expand contract integration test coverage (24 new tests)#188

Open
sungdark wants to merge 1 commit intoANAVHEOBA:mainfrom
sungdark:feat/integration-test-coverage
Open

feat: expand contract integration test coverage (24 new tests)#188
sungdark wants to merge 1 commit intoANAVHEOBA:mainfrom
sungdark:feat/integration-test-coverage

Conversation

@sungdark
Copy link
Copy Markdown

Summary

Expands integration test coverage for the PrivacyLayer Soroban smart contracts with 24 new test cases, bringing the total to 38 integration tests.

Changes

New Deposit Tests (4)

  • test_deposit_max_commitment_value — Validates deposit with maximum field element
  • test_deposit_while_paused_rejected — Ensures PoolPaused error on paused pool
  • test_deposit_by_user_without_tokens_rejected — Rejects deposit from zero-balance account
  • test_merkle_tree_state_after_deposits — Verifies tree state after sequential deposits

New Withdrawal Tests (4)

  • test_withdraw_with_stale_root_still_in_history_succeeds — Root still valid before eviction
  • test_withdraw_fee_exceeds_amount_rejected — Fee validation enforcement
  • test_withdraw_relayer_non_zero_with_zero_fee_rejected — InvalidRelayerFee error
  • test_withdraw_zero_recipient_rejected — InvalidRecipient error
  • test_withdraw_with_fresh_nullifier — Fresh nullifier preconditions

New Admin Tests (5)

  • test_pause_unpause_multiple_cycles — Multiple pause/unpause cycles
  • test_vk_update_multiple_times — Repeated VK updates
  • test_admin_operations_with_wrong_admin_rejected — UnauthorizedAdmin for all admin ops
  • test_initialize_by_non_admin_rejected — Non-admin cannot initialize
  • test_admin_authorization_required_for_all_admin_ops — Full admin auth enforcement

New State Tests (6)

  • test_root_history_circular_buffer_no_duplicates — Circular buffer behavior
  • test_nullifier_tracking_across_deposits — Nullifier uniqueness tracking
  • test_view_functions_consistency — All view functions track state correctly
  • test_deposit_same_commitment_twice_different_indices — Same commitment, different nullifiers
  • test_multiple_users_deposit_independently — Alice + Bob independent deposits
  • test_deposit_count_matches_actual_deposits — Deposit counter accuracy

New Utility Tests (3)

  • test_config_view_returns_correct_config — PoolConfig matches initialization
  • test_token_balance_precision_across_deposits — Balance arithmetic correctness
  • test_is_known_root_boolean_results — Boolean correctness for known/unknown roots

Acceptance Criteria

  • 24 new integration test cases added (total: 38)
  • All existing tests remain passing
  • Covers deposit, withdraw, admin, and state scenarios
  • Tests all error conditions (PoolPaused, UnauthorizedAdmin, InvalidRelayerFee, etc.)
  • Tests concurrent operations and edge cases

Payment

收款地址(Solana/USDC via Drips Wave):eB51DWp1uECrLZRLsE2cnyZUzfRWvzUzaJzkatTpQV9

Implements 24 new integration tests for ANAVHEOBA/PrivacyLayer contracts,
covering the full scope specified in bounty issue ANAVHEOBA#14.

New tests cover:
- Deposit tests: max commitment, paused state, insufficient balance,
  sequential deposits with merkle state verification
- Withdrawal tests: stale root in history, fee exceeds amount,
  relayer with zero fee, zero recipient, fresh nullifier
- Admin tests: multiple pause/unpause cycles, VK update cycles,
  admin authorization enforcement for all admin operations
- State tests: circular buffer behavior, nullifier tracking,
  view function consistency, token balance precision, deposit count

Total: 38 integration tests (14 original + 24 new)
Target: >85% code coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant