mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-10-17 07:21:32 +02:00
From a multi-lens adversarial review of the capabilities + prices work: - PRICES_ASSETS="" now means NONE, not all (real bug): from_env used env_opt, which collapses unset and present-but-empty into None, so the documented "empty = none" silently served all five feeds. Read via env::var so unset => all, present (even empty) => the listed subset or none. - PRICES_CURRENCY is now validated against a curated SUPPORTED_PRICE_CURRENCIES allowlist. Previously a typo (e.g. "usdd") booted, advertised prices:true, and served an empty feed forever (the provider returns empty quotes for an unknown currency) — a fail-open path inconsistent with the adjacent provider/asset checks. - PRICES_PROVIDER is lowercased at read, matching the asset/currency normalization (mixed-case no longer trips the allowlist). - validate() now requires an Electrum URL for an enabled BTC/LTC chain (hard error in prod, warn in dev), symmetric with the xmr/wow/grin secret checks. Keeps /capabilities honest: a chain it can't serve won't boot advertising itself as available. Tests: config regressions (currency, utxo-electrum); a PriceClient feed-subset selection unit test; the /prices integration test now populates the snapshot and asserts the served quotes + RFC-3339 timestamp (the prior PRICES_ASSETS env-var was inert under the harness); capabilities asserts network presence/null across all five chains. Dismissed after verification: coingecko json() was already switched to a streaming read_capped; fleet refresh-jitter (no API key, single-node, self-healing on 429); prices capability staying a bare bool (/prices carries the currency + per-asset map).
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
//! L1 integration: the public capabilities endpoint.
|
|
|
|
mod common;
|
|
|
|
use axum::http::StatusCode;
|
|
|
|
#[tokio::test]
|
|
async fn capabilities_is_public_and_well_shaped() {
|
|
let app = require_app!();
|
|
// No token required — the wallet reads this before/without login.
|
|
let (status, body) = app.request("GET", "/api/v1/capabilities", None, None).await;
|
|
assert_eq!(status, StatusCode::OK);
|
|
|
|
assert!(body["version"].as_str().is_some(), "version present");
|
|
// Every chain reports an `enabled` boolean.
|
|
for chain in ["btc", "ltc", "xmr", "wow", "grin"] {
|
|
assert!(
|
|
body["chains"][chain]["enabled"].is_boolean(),
|
|
"chain {chain} reports enabled"
|
|
);
|
|
}
|
|
// UTXO chains carry a network; CryptoNote/Grin report null.
|
|
for chain in ["btc", "ltc"] {
|
|
assert!(
|
|
body["chains"][chain]["network"].as_str().is_some(),
|
|
"{chain} carries a network"
|
|
);
|
|
}
|
|
for chain in ["xmr", "wow", "grin"] {
|
|
assert!(
|
|
body["chains"][chain]["network"].is_null(),
|
|
"{chain} network is null"
|
|
);
|
|
}
|
|
// Feature flags are present.
|
|
for feat in ["grin_relay", "prices", "nostr_identity", "tips"] {
|
|
assert!(
|
|
body["features"][feat].is_boolean(),
|
|
"feature {feat} reports a boolean"
|
|
);
|
|
}
|
|
}
|