Skip to content

test(energy_token): add overflow/underflow test coverage for token arithmetic - #4

Open
devnWisdom wants to merge 1 commit into
mainfrom
feat/token-overflow-tests-559
Open

test(energy_token): add overflow/underflow test coverage for token arithmetic#4
devnWisdom wants to merge 1 commit into
mainfrom
feat/token-overflow-tests-559

Conversation

@devnWisdom

Copy link
Copy Markdown
Owner

Summary

Adds a dedicated overflow_tests module with 16 tests covering every i128 arithmetic path in energy_token for overflow and underflow conditions.

Tests added

Overflow (addition wraps past i128::MAX)

Test Path
mint_overflows_recipient_balance balance + amount in mint()
mint_overflows_total_minted total_minted + amount in mint()
transfer_overflows_recipient_balance tb + amount in move_balance()
transfer_from_overflows_recipient same path via transfer_from()

Underflow / insufficient funds (subtraction below zero)

Test Path
burn_underflows_when_amount_exceeds_balance deduct_balance()
burn_underflows_on_zero_balance deduct_balance() with no prior mint
burn_from_underflows_when_balance_exhausted deduct_balance() via burn_from()
burn_from_underflows_allowance spend_allowance()
transfer_underflows_sender move_balance() sender side

Zero/negative input guards

Test Guard
mint_zero_amount_rejected amount must be positive
mint_negative_amount_rejected amount must be positive
burn_zero_amount_rejected amount must be positive
transfer_zero_amount_rejected amount must be positive
approve_negative_amount_rejected amount must be non-negative

Closes AnnabelJoe#559

…oe#559)

Adds overflow_tests module with 16 tests covering every i128
arithmetic path in energy_token:

Overflow paths:
- mint() overflows recipient balance (balance + amount > i128::MAX)
- mint() overflows total_minted counter
- transfer() overflows recipient balance
- transfer_from() overflows recipient balance

Underflow / insufficient-funds paths:
- burn() amount > balance
- burn() on zero balance
- burn_from() amount > balance
- burn_from() amount > allowance
- transfer() amount > sender balance

Positive-only / non-negative guards:
- mint(0), mint(-1) rejected
- burn(0) rejected
- transfer(0) rejected
- approve(-1) rejected

Closes AnnabelJoe#559
@github-actions

Copy link
Copy Markdown

🔍 Vercel Preview Deployment

URL: Learn More: https://err.sh/vercel/missing-token-value

Uses Stellar testnet contract addresses.

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