Skip to content

test(learn-token): add i128 boundary tests for token operations - #653

Closed
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-639-i128-boundary-tests
Closed

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-639-i128-boundary-tests

Conversation

@lmduy2612

Copy link
Copy Markdown

Description

Fixes #639

This PR adds comprehensive unit test coverage for numeric boundaries across token operations in LearnToken:

  • test_approve_with_i128_max_amount: Verifies setting allowance to i128::MAX records exactly and does not overflow.
  • test_transfer_of_exact_balance_leaves_zero: Verifies transferring exactly 100% of an account's balance updates sender to 0 and recipient correctly.
  • test_burn_of_exact_balance_leaves_zero: Verifies burning 100% of balance leaves account at 0 and decrements total_supply cleanly.
  • test_mint_to_i128_max_supply_cap: Verifies minting up to i128::MAX total supply and balance boundary without panics.
  • test_allowance_operations_at_i128_max: Verifies decrease_allowance and subsequent increase_allowance operate reliably on maximum values.

Verification

  • All newly added tests pass cleanly:
    cargo test --test token_tests test_approve_with_i128_max_amount
    cargo test --test token_tests test_transfer_of_exact_balance_leaves_zero
    cargo test --test token_tests test_burn_of_exact_balance_leaves_zero
    cargo test --test token_tests test_mint_to_i128_max_supply_cap
    cargo test --test token_tests test_allowance_operations_at_i128_max
  • Code formatted with rustfmt.

@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 i128 boundary tests for token operations

2 participants