Skip to content

test(security): add zero-address rejection tests for mint and admin functions - #654

Closed
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-638-zero-address-rejection-tests
Closed

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-638-zero-address-rejection-tests

Conversation

@lmduy2612

Copy link
Copy Markdown

Description

Fixes #638

This PR adds comprehensive zero-address validation and unit test coverage across all contracts in the workspace:

  • Credential NFT:
    • Validates recipient address in mint_credential against chainlearn_shared::zero_address, panicking with "cannot mint to zero address".
    • Added unit test test_mint_credential_to_zero_address_panics in tests/unit/credential_tests.rs.
    • Added unit test test_transfer_admin_to_zero_address_panics in tests/unit/credential_tests.rs.
  • Progress Tracker:
    • Added unit test test_transfer_admin_to_zero_address_panics in tests/unit/progress_tests.rs.
    • Validates delegate address in delegate_progress, panicking with "cannot delegate to zero address".
    • Added unit test test_delegate_progress_to_zero_address_panics in tests/unit/progress_tests.rs.
  • Learn Token:
    • Validates beneficiary address in create_vesting, panicking with "cannot vest to zero address".
    • Added unit test test_create_vesting_to_zero_address_panics in tests/unit/token_tests.rs.
    • Added unit test test_transfer_admin_to_zero_address_panics in tests/unit/token_tests.rs.

Verification

  • cargo test --test credential_tests -- test_mint_credential_to_zero_address_panics (Passed)
  • cargo test --test credential_tests -- test_transfer_admin_to_zero_address_panics (Passed)
  • cargo test --test progress_tests -- test_transfer_admin_to_zero_address_panics (Passed)
  • cargo test --test progress_tests -- test_delegate_progress_to_zero_address_panics (Passed)
  • cargo test --test token_tests -- test_create_vesting_to_zero_address_panics (Passed)
  • cargo test --test token_tests -- test_transfer_admin_to_zero_address_panics (Passed)
  • Full suites pass: credential_tests (30/30) and progress_tests (108/108).

@DeFiVC DeFiVC closed this Oct 19, 2026
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.

Add zero-address rejection tests for all mint and admin functions

2 participants