Skip to content

CECHO-2510: statics: ERC20 duplicate-contract-address test rejects legitimate cross-chain address reuse - #10028

Merged
nayandas190 merged 1 commit into
masterfrom
CECHO-2510-fix-erc20-duplicate-address-test
Oct 22, 2026
Merged

nayandas190 merged 1 commit into
masterfrom
CECHO-2510-fix-erc20-duplicate-address-test

Conversation

@nayandas190

Copy link
Copy Markdown
Contributor

Summary

Fixes the @bitgo/statics unit test that rejected legitimate reuse of a contract address across different chains. Chains are separate namespaces, so a token deployed at the same (deterministic) address on two chains — e.g. eth:aaplx and okbxlayer:aaplx — is valid, and CoinMap already accepts it.

Linear: CECHO-2510

Changes

  • modules/statics/test/unit/coins.ts: rewrite ERC20 Coins › should have no duplicate contract addresses to key by family:contractAddress:network.type, mirroring the invariant enforced by CoinMap.addCoin. Cross-chain address reuse now passes; same-chain duplicates still fail.
  • Remove the now-unused DuplicateCoinObject interface.
  • Eliminates the previous order-dependence (the old test passed or failed depending on CoinMap iteration order) and the [object Object] error message.

No production code change — CoinMap already permits cross-chain reuse.

Test Plan

  • npx mocha test/unit/coins.ts → 40002 passing
  • tsc --build clean; eslint 0 errors; prettier clean
  • Injecting a second eth: token with the same address on mainnet.ethereum still throws DuplicateContractAddressDefinitionError
  • Confirm okbxlayer:aaplx (same address as eth:aaplx) can be onboarded once added

The test keyed duplicates by contract address alone and rejected any match
on a non-ETH family, so a token deployed at the same address on two
different chains (e.g. eth:aaplx and okbxlayer:aaplx) failed the suite even
though CoinMap accepts it. It was also order-dependent and interpolated the
accumulator object as [object Object].

Key by family:contractAddress:network.type to mirror CoinMap.addCoin so that
cross-chain address reuse passes while same-chain duplicates still fail.

Ticket: CECHO-2510
@linear-code

linear-code Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

CECHO-2510

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Unit tests are failing on Node 26.x (Current release line, non-blocking). This is not an LTS version yet, so it does not block merge, but it signals an incompatibility to fix before Node 26.x becomes LTS.

View run

@nayandas190
nayandas190 marked this pull request as ready for review October 22, 2026 09:37
@nayandas190
nayandas190 requested a review from a team as a code owner October 22, 2026 09:37
@nayandas190
nayandas190 requested a balanced review from Copilot October 22, 2026 09:48
@nayandas190
nayandas190 merged commit da4d891 into master Oct 22, 2026
27 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused test-only change preserves namespace-specific duplicate detection, with no unresolved review findings.

No open issues 🎉

What changed in this PR

Updates the statics ERC20 duplicate-address test to allow legitimate cross-chain address reuse without changing production code.

Changes:

  • Checks uniqueness by family:contractAddress:network.type, matching CoinMap collision rules.
  • Removes iteration-order dependence and reports both token names in duplicate errors.
  • Removes the unused DuplicateCoinObject interface.
File Description
modules/​statics/​test/​unit/​coins.ts Scopes duplicate-address checks to the intended namespace and simplifies test bookkeeping.

Review effort: Balanced

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.

4 participants