Skip to content

fix(price): repair test-only price seeding broken by #753/#770 merge skew#774

Merged
grunch merged 1 commit into
mainfrom
fix/price-test-seed-compile
Jun 12, 2026
Merged

fix(price): repair test-only price seeding broken by #753/#770 merge skew#774
grunch merged 1 commit into
mainfrom
fix/price-test-seed-compile

Conversation

@grunch

@grunch grunch commented Jun 12, 2026

Copy link
Copy Markdown
Member

Problem

main does not compile under cargo test (cargo check --all-targets / cargo clippy --all-targets) since the last two merges crossed:

error[E0425]: cannot find value `BITCOIN_PRICES` in this scope --> src/bitcoin_price.rs:31:9
error[E0433]: failed to resolve: use of undeclared type `BitcoinPriceManager` --> src/util.rs:1936:9

Fix

Re-point the test seam at a small #[cfg(test)] override map (price::test_price_overrides) consulted by price::get_bitcoin_price before the global manager:

Checks

  • cargo test: 426 passed
  • cargo clippy --all-targets --all-features: clean
  • cargo fmt: clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Restructured internal test price override handling for improved test isolation and consistency.

…skew

PR #753 removed the BITCOIN_PRICES static when it migrated price reads
to the PriceManager, while PR #770 (merged independently) added
BitcoinPriceManager::set_price_for_test writing to that static — the
combination doesn't compile under cargo test on main.

Re-point the test seam at a small cfg(test) override map consulted by
price::get_bitcoin_price before the global manager, so unit tests keep
seeding deterministic prices without installing the global PriceManager
(whose OnceLock would leak one test's configuration into the rest of
the binary).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8a2dc859-4204-4733-836f-d1f712bd83d8

📥 Commits

Reviewing files that changed from the base of the PR and between af8f05d and c80db44.

📒 Files selected for processing (3)
  • src/bitcoin_price.rs
  • src/price/mod.rs
  • src/util.rs

Walkthrough

This PR consolidates Bitcoin price test overrides into a centralized, thread-safe shared map. The new infrastructure in price/mod.rs exposes a per-currency override mechanism that the real get_bitcoin_price checks first under test mode, while the legacy BitcoinPriceManager::set_price_for_test helper is wired to use this shared map instead of maintaining its own in-memory cache.

Changes

Test price override consolidation

Layer / File(s) Summary
Test price override infrastructure and integration
src/price/mod.rs
A process-wide OnceLock<RwLock<HashMap<String, f64>>> backed override map is added via test_price_overrides(). The get_bitcoin_price function is updated to consult this map under #[cfg(test)] and return overridden prices when available, falling back to live retrieval otherwise.
Legacy test helper integration
src/bitcoin_price.rs
BitcoinPriceManager::set_price_for_test is updated to seed the new shared override map via crate::price::test_price_overrides() instead of the legacy per-module cache. Documentation describes override-map seeding and test isolation via per-test unique currencies.
Test module import
src/util.rs
BitcoinPriceManager is imported into the test module to support unit tests that set deterministic cached prices for calculations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • MostroP2P/mostro#747: Both PRs touch src/price/mod.rs and relate to BTC price retrieval logic by integrating get_bitcoin_price in test contexts atop the Phase-0 price module foundation.

Suggested reviewers

  • AndreaDiazCorreia
  • BraCR10
  • Catrya
  • mostronatorcoder

Poem

🐰 A currency cache once scattered and sparse,
Now gathered as one in a lock, thread-safe farce!
Test prices unified, no more duplicated state—
The override map handles them all, oh so great!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(price): repair test-only price seeding broken by #753/#770 merge skew' accurately describes the main change: fixing a broken test-only price seeding mechanism that resulted from merge conflicts between two prior PRs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/price-test-seed-compile

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.

@grunch grunch merged commit c610c34 into main Jun 12, 2026
8 checks passed
@grunch grunch deleted the fix/price-test-seed-compile branch June 12, 2026 14:02
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