test(energy_token): add overflow/underflow test coverage for token arithmetic - #4
Open
devnWisdom wants to merge 1 commit into
Open
test(energy_token): add overflow/underflow test coverage for token arithmetic#4devnWisdom wants to merge 1 commit into
devnWisdom wants to merge 1 commit into
Conversation
…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
🔍 Vercel Preview DeploymentURL: Learn More: https://err.sh/vercel/missing-token-value
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a dedicated
overflow_testsmodule with 16 tests covering everyi128arithmetic path inenergy_tokenfor overflow and underflow conditions.Tests added
Overflow (addition wraps past
i128::MAX)mint_overflows_recipient_balancebalance + amountinmint()mint_overflows_total_mintedtotal_minted + amountinmint()transfer_overflows_recipient_balancetb + amountinmove_balance()transfer_from_overflows_recipienttransfer_from()Underflow / insufficient funds (subtraction below zero)
burn_underflows_when_amount_exceeds_balancededuct_balance()burn_underflows_on_zero_balancededuct_balance()with no prior mintburn_from_underflows_when_balance_exhausteddeduct_balance()viaburn_from()burn_from_underflows_allowancespend_allowance()transfer_underflows_sendermove_balance()sender sideZero/negative input guards
mint_zero_amount_rejectedamount must be positivemint_negative_amount_rejectedamount must be positiveburn_zero_amount_rejectedamount must be positivetransfer_zero_amount_rejectedamount must be positiveapprove_negative_amount_rejectedamount must be non-negativeCloses AnnabelJoe#559