Skip to content

fix(oracle): accept any non-empty BaseAsset/QuoteAsset in OracleSet#335

Open
e-desouza wants to merge 1 commit into
mainfrom
fix/oracle-currency-validation
Open

fix(oracle): accept any non-empty BaseAsset/QuoteAsset in OracleSet#335
e-desouza wants to merge 1 commit into
mainfrom
fix/oracle-currency-validation

Conversation

@e-desouza

Copy link
Copy Markdown
Collaborator

Why

validate_oracle_currency restricted BaseAsset and QuoteAsset to 3-character ISO codes or 40-character hex strings. The rippled node imposes no such restriction — it accepts any non-empty string for these fields. This caused the Rust SDK to silently reject valid oracle pairs (e.g. BTC, DOGE, AAPL, EURO) that rippled would happily process.

Introduced in #156 (9570a0e).

What changed

  • validate_oracle_currency in src/models/transactions/mod.rs: replaced the ISO/hex pattern check with a simple non-empty string check
  • Replaced test_invalid_base_asset_rejected (which asserted the old ISO/hex restriction) with:
    • test_arbitrary_non_empty_base_asset_accepted — verifies EURO, BTC, DOGE, AAPL, and other arbitrary codes are accepted
    • test_empty_base_asset_rejected — verifies empty string is still rejected
    • test_empty_quote_asset_rejected — verifies empty string is rejected for quote_asset too

How to validate

cargo test --lib --features std

rippled does not restrict BaseAsset/QuoteAsset to ISO codes or 40-char hex.
Any non-empty string is valid per the XLS-47 spec. The previous restriction
would silently reject oracle pairs like BTC, DOGE, AAPL that rippled accepts.

Closes: pre-existing bug introduced in PR #156 (9570a0e).
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.53%. Comparing base (49196f9) to head (6611042).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
+ Coverage   84.49%   84.53%   +0.03%     
==========================================
  Files         227      227              
  Lines       24245    24283      +38     
==========================================
+ Hits        20487    20528      +41     
+ Misses       3758     3755       -3     
Flag Coverage Δ
integration 71.52% <ø> (+0.19%) ⬆️
unit 85.23% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/models/transactions/mod.rs 56.22% <100.00%> (-0.15%) ⬇️
src/models/transactions/oracle_set.rs 93.60% <100.00%> (+0.33%) ⬆️

... and 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.

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