Skip to content

fix(asset_scaling): match base asset exactly, not as a string prefix#140

Open
gfyrag wants to merge 1 commit into
test/asset-scaling-prefix-match-bugfrom
fix/asset-scaling-prefix-exact-match
Open

fix(asset_scaling): match base asset exactly, not as a string prefix#140
gfyrag wants to merge 1 commit into
test/asset-scaling-prefix-match-bugfrom
fix/asset-scaling-prefix-exact-match

Conversation

@gfyrag
Copy link
Copy Markdown
Contributor

@gfyrag gfyrag commented Jun 3, 2026

Summary

Tightens getAssets (in internal/interpreter/asset_scaling.go) so an entry
belongs to the baseAsset scaling pool iff its key is exactly
baseAsset or has the form baseAsset/N. Drops the spurious matches
the parent test PR pins.

This PR is stacked on #141 (the failing regression test). Merging
this flips TestGetAssetsRejectsSpuriousPrefixMatches from red to
green.

Stack

PR What it does Target
#141 Failing regression test pinning the bug main
this PR (#140) Tightens getAssets exact-match #141 branch

Diff vs the parent test branch

Single 5-line change in getAssets:

- if strings.HasPrefix(asset, baseAsset) {
-     _, scale := getAssetScale(asset)
-     result[scale] = amount
- }
+ if asset != baseAsset && !strings.HasPrefix(asset, baseAsset+"/") {
+     continue
+ }
+ _, scale := getAssetScale(asset)
+ result[scale] = amount

Plus a doc-comment on the function.

Test plan

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f87d3b58-f54d-4501-9e0b-8542c2bf822f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/asset-scaling-prefix-exact-match

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (test/asset-scaling-prefix-match-bug@7b65e3f). Learn more about missing BASE report.

Additional details and impacted files
@@                          Coverage Diff                           @@
##             test/asset-scaling-prefix-match-bug     #140   +/-   ##
======================================================================
  Coverage                                       ?   66.95%           
======================================================================
  Files                                          ?       47           
  Lines                                          ?     5069           
  Branches                                       ?        0           
======================================================================
  Hits                                           ?     3394           
  Misses                                         ?     1477           
  Partials                                       ?      198           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gfyrag gfyrag force-pushed the fix/asset-scaling-prefix-exact-match branch from 6556b5b to 077d45e Compare June 3, 2026 12:06
@gfyrag gfyrag changed the base branch from main to test/asset-scaling-prefix-match-bug June 3, 2026 12:06
@gfyrag gfyrag force-pushed the test/asset-scaling-prefix-match-bug branch from ff49c47 to 7b65e3f Compare June 3, 2026 12:10
Tighten `getAssets` so an entry belongs to the scaling pool iff its key
is exactly `baseAsset` or has the form `baseAsset/N`. Drops the
spurious matches that the regression test (introduced in the stacked
parent PR) pins:

  - `USDT`, `USDT/2`: unrelated asset, shared prefix
  - `USD_RED`, `USD_RED/2`: color-suffix-encoded variants from the
    experimental asset-colors feature flag

This flips `TestGetAssetsRejectsSpuriousPrefixMatches` from red to
green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gfyrag gfyrag force-pushed the fix/asset-scaling-prefix-exact-match branch from 077d45e to bcb2496 Compare June 3, 2026 12:10
@gfyrag gfyrag marked this pull request as ready for review June 3, 2026 12:13
@gfyrag gfyrag requested review from Azorlogh and ascandone June 3, 2026 12:22
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.

2 participants