Skip to content

oracle: clear_prices, get_stable_price, and get_price_with_stable_fallback have zero test coverage #593

Description

@abayomicornelius

Problem

Three oracle view/mutating functions have zero test coverage:

  • clear_prices (contracts/oracle/src/lib.rs:402) — batch-clears temporary price entries for multiple tokens. Only the single-token clear_price appears to be exercised; the batch version is never called by any test.
  • get_stable_price (line 321) and get_price_with_stable_fallback (line 341) — both contain the overflow guard added for issue oracle: get_stable_price / get_price_with_stable_fallback trust an unchecked u128->i128 cast as a valid price #383 (if price_u128 == 0 || price_u128 > i128::MAX as u128 { None } / the equivalent inline check), but no test calls either function at all, so the guard itself is unverified by the test suite.
grep -rn "clear_prices\|get_stable_price\|get_price_with_stable_fallback" --include="*.rs" . | grep -v oracle/src/lib.rs
# no output

Why it matters

#383's fix (rejecting a stable_price value that doesn't fit in i128) is exactly the kind of boundary condition that regresses silently without a dedicated test — a future refactor of either function could reintroduce the unchecked cast and nothing in CI would catch it. clear_prices's loop-based batch clearing is also untested, so an off-by-one or early-return bug in the loop would not be caught.

Suggested fix

Add tests: clear_prices with a multi-token vector, asserting each token's price is actually cleared from temporary storage; get_stable_price/get_price_with_stable_fallback with a stable_price value at/above i128::MAX asserting None/fallback-to-primary behavior, and with a normal in-range value asserting the stable price is returned.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardStellar WaveIssues in the Stellar wave programThird CampaignCampaign: Third CampaignbugSomething isn't workingpriority:lowsize:s

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions