Skip to content

test(contracts): convert GovernanceToken tests to fuzz tests#19218

Closed
devin-ai-integration[bot] wants to merge 1 commit intodevelopfrom
devin/1771361791-improve-governance-token-coverage
Closed

test(contracts): convert GovernanceToken tests to fuzz tests#19218
devin-ai-integration[bot] wants to merge 1 commit intodevelopfrom
devin/1771361791-improve-governance-token-coverage

Conversation

@devin-ai-integration
Copy link
Contributor

test(contracts): convert GovernanceToken tests to fuzz tests

Summary

Converts all 9 hardcoded tests in GovernanceToken.t.sol to fuzz tests for broader input coverage. No new tests added; no tests removed. The test logic and assertions are preserved — only the inputs are parameterized.

Changes per test contract:

  • GovernanceToken_Mint_Test: mint success now fuzzes _account and _amount; revert test fuzzes _caller
  • GovernanceToken_Uncategorized_Test: All 7 tests (burn, burnFrom, transfer, approve, transferFrom, increaseAllowance, decreaseAllowance) converted to fuzz with appropriate bound() constraints

Mint amounts are bounded to type(uint224).max to respect the ERC20Votes checkpoint cap.

Review & Testing Checklist for Human

  • Verify type(uint224).max is the correct upper bound for ERC20Votes mint amounts (OpenZeppelin's _maxSupply())
  • Confirm increaseAllowance overflow guard (bound(_increase, 0, type(uint256).max - _initial)) is sufficient — _initial itself is unbounded fuzz input
  • Run forge test --match-path test/governance/GovernanceToken.t.sol with a higher fuzz run count (e.g., --fuzz-runs 1000) to stress-test edge cases

Notes

  • The testFuzz_approve_succeeds test keeps a hardcoded mint of 100 (matching the original) while other tests fuzz the mint amount. This is intentional since approve behavior is independent of token balance.
  • Inline comments were removed per repo conventions (no comments unless requested).
  • Link to Devin run: https://app.devin.ai/sessions/9c4590b2644c4689bad68f5e6b0d3d81
  • Requested by: @aliersh

Convert 9 hardcoded tests to fuzz tests for broader coverage:
- mint: fuzz account and amount for owner, fuzz caller for non-owner revert
- burn/burnFrom: fuzz mint and burn amounts
- transfer/transferFrom: fuzz mint and transfer amounts
- approve: fuzz approve amount
- increaseAllowance/decreaseAllowance: fuzz initial and delta amounts
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

function test_mint_fromOwner_succeeds() external {
// Mint 100 tokens.
/// @notice Tests that the owner can mint tokens.
function testFuzz_mint_fromOwner_succeeds(address _account, uint256 _amount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_mint_fromOwner_succeeds' does not follow the required format '[method][functionName][reason]_[status]'. It should be 'testFuzz_mint_succeeds' since 'fromOwner' is not the function name being tested (the function is 'mint'), and the reason/status should be combined into just 'succeeds'.

Suggested change
function testFuzz_mint_fromOwner_succeeds(address _account, uint256 _amount) external {
function testFuzz_mint_succeeds(address _account, uint256 _amount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_burn_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that a user can burn their tokens.
function testFuzz_burn_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_burn_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_burn_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_burn_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {
function testFuzz_burn_validAmount_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_burnFrom_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that an approved spender can burn tokens.
function testFuzz_burnFrom_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_burnFrom_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_burnFrom_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_burnFrom_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {
function testFuzz_burnFrom_validAmount_succeeds(uint256 _mintAmount, uint256 _burnAmount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_transfer_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that `transfer` correctly moves tokens.
function testFuzz_transfer_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_transfer_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_transfer_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_transfer_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {
function testFuzz_transfer_validAmount_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

/// @notice Tests that `approve` correctly sets allowances.
function test_approve_succeeds() external {
// Mint 100 tokens to rando.
function testFuzz_approve_succeeds(uint256 _approveAmount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_approve_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_approve_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_approve_succeeds(uint256 _approveAmount) external {
function testFuzz_approve_anyAmount_succeeds(uint256 _approveAmount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_transferFrom_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that `transferFrom` correctly moves tokens.
function testFuzz_transferFrom_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_transferFrom_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_transferFrom_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_transferFrom_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {
function testFuzz_transferFrom_validAmount_succeeds(uint256 _mintAmount, uint256 _transferAmount) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_increaseAllowance_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that `increaseAllowance` adds to allowance.
function testFuzz_increaseAllowance_succeeds(uint256 _initial, uint256 _increase) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_increaseAllowance_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_increaseAllowance_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_increaseAllowance_succeeds(uint256 _initial, uint256 _increase) external {
function testFuzz_increaseAllowance_validAmount_succeeds(uint256 _initial, uint256 _increase) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

function test_decreaseAllowance_succeeds() external {
// Mint 100 tokens to rando.
/// @notice Tests that `decreaseAllowance` reduces allowance.
function testFuzz_decreaseAllowance_succeeds(uint256 _initial, uint256 _decrease) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function naming violates the Optimism Solidity Style Guide. The function name 'testFuzz_decreaseAllowance_succeeds' follows the correct format '[method][functionName][reason]_[status]', but it's missing the reason component. It should be 'testFuzz_decreaseAllowance_validAmount_succeeds' or similar to indicate what makes this test succeed.

Suggested change
function testFuzz_decreaseAllowance_succeeds(uint256 _initial, uint256 _decrease) external {
function testFuzz_decreaseAllowance_validAmount_succeeds(uint256 _initial, uint256 _decrease) external {

Spotted by Graphite Agent (based on custom rule: Solidity Style Guide)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.1%. Comparing base (d15fb89) to head (19a7863).
⚠️ Report is 2 commits behind head on develop.

❗ There is a different number of reports uploaded between BASE (d15fb89) and HEAD (19a7863). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (d15fb89) HEAD (19a7863)
cannon-go-tests-64 2 0
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #19218     +/-   ##
==========================================
- Coverage     76.2%    71.1%   -5.2%     
==========================================
  Files          190      135     -55     
  Lines        10966     6936   -4030     
==========================================
- Hits          8367     4932   -3435     
+ Misses        2453     2004    -449     
+ Partials       146        0    -146     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests 71.1% <ø> (-10.5%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 88 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aliersh
Copy link
Contributor

aliersh commented Feb 17, 2026

PR opened for testing purposes

@aliersh aliersh closed this Feb 17, 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.

1 participant