Skip to content

test: remove dual-denom test paths and add invariants coverage#1185

Open
aljo242 wants to merge 3 commits into
mainfrom
chore/remove-dual-denom-test-paths-and-add-invariants
Open

test: remove dual-denom test paths and add invariants coverage#1185
aljo242 wants to merge 3 commits into
mainfrom
chore/remove-dual-denom-test-paths-and-add-invariants

Conversation

@aljo242

@aljo242 aljo242 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove remaining dual-denom (6/12/2 decimal) support paths from test constants and test suites now that runtime enforces 18-decimal-only configuration
  • update non-18 rejection tests to use inline custom coin-info fixtures instead of shared multi-decimal constants
  • add randomized ERC20 convert round-trip invariant coverage and a Go fuzz target for scaling/denom conversion idempotence

Test plan

  • go test -tags=test ./x/vm/types ./utils
  • go test -tags=test ./tests/integration/testutil
  • go test -tags=test ./tests/integration -run 'TestERC20KeeperTestSuite|TestWERC20PrecompileUnitTestSuite' (from evmd/)

Made with Cursor

Drop remaining 6/12-decimal test-support paths now that only 18-decimal configs are supported, and add randomized conversion invariants plus a scaling fuzz target to harden regression coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aljo242 aljo242 requested a review from a team as a code owner May 15, 2026 15:21
@greptile-apps

greptile-apps Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes all non-18-decimal test fixtures and constants (SixDecimalsChainID, TwelveDecimalsChainID, TwoDecimalsChainID) now that the runtime enforces 18-decimal-only chains, replacing them with inline EvmCoinInfo fixtures in the rejection tests. It also adds a new randomized ERC20 convert round-trip invariant test and a Go fuzz target for the denom-relabeling conversion, including a regression unit test for the previously reported uint64 overflow guard.

  • Constants cleanup: Three non-18-decimal ChainID entries and their associated EvmCoinInfo maps are removed from testutil/constants/constants.go; rejection tests in utils_test.go and configurator_test.go now use self-contained inline fixtures.
  • New randomized invariant test (test_conversion_invariants_randomized.go): Runs 50 random ConvertERC20ConvertCoin operations across five deterministic seeds, asserting strict value conservation (erc20Bal + coinBal == 5000) at every step.
  • New fuzz target (scaling_fuzz_test.go): Verifies idempotency and amount preservation of ConvertCoinsDenomToExtendedDenomWithEvmParams, with a correctly guarded uint64 overflow path and a dedicated regression unit test.

Confidence Score: 5/5

Safe to merge — all changes are test-only, removing dead dual-decimal paths and adding well-guarded new coverage.

All modifications are confined to test files and documentation. The non-18-decimal constants and chain IDs are cleanly removed, the rejection tests are correctly rewritten with inline fixtures, the randomized invariant test properly guards against zero-balance panics, and the fuzz target uint64 overflow is addressed with both a runtime guard and a dedicated regression unit test.

No files require special attention.

Important Files Changed

Filename Overview
tests/integration/x/erc20/test_conversion_invariants_randomized.go New randomized round-trip invariant test; covers deterministic edge cases and 50 random steps per seed with correct balance-conservation assertions. No issues found.
x/vm/types/scaling_fuzz_test.go New fuzz target for denom-relabeling conversion with idempotency and amount-preservation checks; the previously reported uint64 overflow guard is correctly implemented and backed by TestBuildFuzzInputCoinsMaxUint64Guard.
testutil/constants/constants.go Removes SixDecimalsChainID, TwelveDecimalsChainID, TwoDecimalsChainID and their EvmCoinInfo entries; only 18-decimal entries remain.
utils/utils_test.go TestCalcBaseFeeRejectsUnsupportedDecimals now uses inline EvmCoinInfo fixtures instead of the removed shared constants; test intent and coverage are preserved.
x/vm/types/configurator_test.go TestEVMConfiguratorRejectsNon18Decimals migrated to inline fixtures for six- and twelve-decimal rejection cases; no behavioral change.
tests/integration/precompiles/werc20/test_events.go Removes six-decimal test cases from TestEmitDepositEvent and TestEmitWithdrawalEvent; straightforward cleanup.
tests/integration/testutil/test_config.go Removes the six-decimal test case from TestWithChainID; consistent with the constant cleanup.
README.md Adds fuzz target invocation examples with 30s and 5m fuzz windows; documentation only.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Mint 5000 ERC20 tokens] --> B[assertInvariants: initial]
    B --> C[ConvertERC20 amount=1]
    C --> D[assertInvariants: after convertERC20-1]
    D --> E[ConvertCoin amount=1]
    E --> F[assertInvariants: after convertCoin-1]
    F --> G{allERC20 > 0?}
    G -- yes --> H[ConvertERC20 full balance]
    H --> I[assertInvariants: after full convertERC20]
    I --> J{allCoin > 0?}
    J -- yes --> K[ConvertCoin full balance]
    K --> L[assertInvariants: after full convertCoin]
    L --> M[Random loop: 50 steps per seed]
    M --> N{erc20Bal == 0?}
    N -- yes --> O[convertFromERC20 = false]
    N -- no --> P{coinBal == 0?}
    P -- yes --> Q[convertFromERC20 = true]
    P -- no --> R[random choice]
    O --> S[ConvertCoin rand amount]
    Q --> T[ConvertERC20 rand amount]
    R --> S
    R --> T
    S --> U[assertInvariants: erc20Bal + coinBal == 5000]
    T --> U
    U --> M
    M --> V[assertInvariants: final]
Loading

Reviews (2): Last reviewed commit: "test: strengthen conversion invariants a..." | Re-trigger Greptile

Comment thread x/vm/types/scaling_fuzz_test.go Outdated
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.92%. Comparing base (7d11196) to head (100f0b8).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1185      +/-   ##
==========================================
+ Coverage   66.32%   66.92%   +0.60%     
==========================================
  Files         336      320      -16     
  Lines       23959    23409     -550     
==========================================
- Hits        15891    15667     -224     
+ Misses       6891     6583     -308     
+ Partials     1177     1159      -18     

see 2 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.

aljo242 and others added 2 commits May 15, 2026 11:45
Address PR feedback by guarding the fuzz input against uint64 overflow and rename local variables that shadow Go builtins so lint passes cleanly.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add deterministic boundary coverage around conversion invariants, include a regression test for the MaxUint64 fuzz edge case, and document local commands for running the denom conversion fuzz target.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aljo242

aljo242 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@greptile re-review

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs.

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