fix: isolate on-chain provider outages

This commit is contained in:
Hermes Agent
2026-07-26 23:32:54 +00:00
parent a2b9b431c7
commit 2da5d20ccd
2 changed files with 50 additions and 24 deletions
+15
View File
@@ -108,6 +108,21 @@ def test_partial_fast_scrape_preserves_last_known_good_metric(server, monkeypatc
assert saved["fear_greed"]["source"] == "alternative.me"
def test_onchain_sources_fail_independently(server, monkeypatch):
fake_lib = types.ModuleType("scrapers.lookintobitcoin")
setattr(fake_lib, "scrape_all", lambda: (_ for _ in ()).throw(RuntimeError("LIB down")))
fake_coc = types.ModuleType("scrapers.checkonchain")
setattr(fake_coc, "scrape_all", lambda: {"sopr": {"value": 0.99}})
monkeypatch.setitem(sys.modules, "scrapers.lookintobitcoin", fake_lib)
monkeypatch.setitem(sys.modules, "scrapers.checkonchain", fake_coc)
observations, errors, successful_sources = server._scrape_onchain_sources()
assert observations["sopr"]["value"] == 0.99
assert successful_sources == 1
assert any("LookIntoBitcoin" in error for error in errors)
def test_expired_onchain_timestamp_triggers_real_refresh(server, monkeypatch, tmp_path):
old = datetime.now(timezone.utc) - timedelta(hours=7)
cache_path = tmp_path / "cache.json"