onionwire/tests/tui_spec.rs

238 lines
7.9 KiB
Rust
Raw Permalink Normal View History

use onionwire::Message;
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
use onionwire::node::{DaemonSync, WalletChildState};
use onionwire::outbox::{OutboxEntry, OutboxStatus};
use onionwire::Payment;
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
use onionwire::qr;
use onionwire::tui::{
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
OutboxSummary, WALLET_LINE_MAX, alert_line, ascii_chrome, chain_view_with_progress,
chat_with_delivery, delivery_tag, draw_chat, draw_share, draw_text_overlay,
empty_friend_chat_text, help_overlay_text, is_onion_host, main_footer_hints, main_header_line,
parse_daemon_addr, paste_screen_text, retry_in_text, roster_col_width, short_send_reason,
status_footer, sync_line, wallet_readiness, wrap_invite,
ConfigField, ConfigStatus, WalletConfigScreen,
};
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
use onionwire::wallet::{ChainSource, PingResult};
use ratatui::Frame;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
use ratatui::layout::{Constraint, Layout};
use ratatui::widgets::{Block, Borders, List, ListItem, Paragraph, Wrap};
use std::sync::Mutex;
struct Dead;
impl Deliverer for Dead {
fn deliver<'a>(
&'a self,
_onion: &'a str,
_pinned_id: &'a [u8],
_prekey: &'a [u8],
_plaintext: &'a [u8],
) -> BoxFut<'a, Result<(), String>> {
Box::pin(async { Err("connect dead.onion:80: timed out".to_string()) })
}
}
let dir = tempfile::tempdir().expect("tempdir");
let store = Store::open_at_with_passphrase(dir.path(), "tui-spec-pass").expect("open store");
let pk = [1u8; 32];
store
.upsert_friend(&pk, "dead.onion", None)
.expect("friend");
store.set_friend_prekey(&pk, &[7u8; 32]).expect("prekey");
let store = Arc::new(std::sync::Mutex::new(store));
let outbox = Outbox::new(Arc::clone(&store), Arc::new(Dead));
assert_eq!(
outbox.send(&pk, b"queued for a dead peer").await,
Ok(OutboxStatus::Queued)
);
let pending = outbox.pending(&pk).expect("pending rows");
assert_eq!(pending.len(), 1, "one queued row");
let msgs = store
.lock()
.expect("store lock")
.list_messages(&pk)
.expect("messages");
let now = pending[0].next_attempt_at - 45;
let (lines, summary) = chat_with_delivery(&msgs, &pending, now);
assert_eq!(lines.len(), 1);
assert!(
lines[0].contains("queued (try 1/8, retry 45s)"),
"real outbox row did not render: {:?}",
lines[0]
);
assert_eq!(summary.note().as_deref(), Some("1 queued"));
// And once a send crosses the circuit the row is gone, so the same message
// renders as delivered.
let (delivered, summary) = chat_with_delivery(&msgs, &[], now);
assert!(delivered[0].contains('✓'), "{:?}", delivered[0]);
assert_eq!(summary.note(), None);
}
/// The chain-source picker's address field: whatever the user typed either
/// parses into exactly `host:port`, or it is refused with a reason. `.onion`,
/// loopback and clearnet are all accepted — clearnet only because the user
/// typed it here — and there is no default port.
#[test]
fn daemon_addresses_parse_or_are_refused() {
assert_eq!(
parse_daemon_addr(" 127.0.0.1:18081 ").unwrap(),
("127.0.0.1".to_string(), 18081)
);
assert_eq!(
parse_daemon_addr("abc234defghijklmnop.onion:18089").unwrap(),
("abc234defghijklmnop.onion".to_string(), 18089)
);
assert_eq!(
parse_daemon_addr("node.example.com:18089").unwrap(),
("node.example.com".to_string(), 18089)
);
assert_eq!(parse_daemon_addr("[::1]:18081").unwrap().1, 18081);
for bad in [
"",
" ",
"127.0.0.1",
"host:",
":18081",
"host:0",
"host:65536",
"host:abc",
"host:-1",
"http://host:18081",
"host/path:18081",
"ho st:18081",
] {
let err = parse_daemon_addr(bad).expect_err(&format!("{bad:?} must be refused"));
assert!(!err.is_empty(), "{bad:?} refused without a reason");
}
}
#[test]
fn onion_hosts_are_recognised_before_any_spawn() {
assert!(is_onion_host("abc234.onion"));
assert!(is_onion_host("ABC234.ONION "));
assert!(!is_onion_host("127.0.0.1"));
assert!(!is_onion_host("node.example.com"));
assert!(!is_onion_host("notonion"));
}
// ---------------------------------------------------------------------------
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
// The chain view against a Cuprate daemon: connectivity is inferred from
// block-height movement, never from `get_info`'s peer counts (zero while it
// downloads blocks) or from its placeholder `database_size`/`free_space`.
// ---------------------------------------------------------------------------
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
/// A daemon that answered, but reported no chain target: exactly what Cuprate
/// does at rest — `synchronized = true`, `target_height = 0`, zero peers. The
/// screen must not dress that up as progress (`1160/0`) or as "synced".
#[test]
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
fn a_daemon_with_no_chain_target_is_unknown_not_synced() {
let sync = DaemonSync {
reachable: true,
height: 1160,
target_height: 0,
note: None,
};
let line = sync_line(&sync, None);
assert_eq!(
line,
"sync: unknown — daemon reports no chain target (height 1160)"
);
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
assert!(!line.contains("synced"), "{line}");
assert!(!line.contains("syncing"), "{line}");
assert!(!sync.synced(), "no target is not 'caught up'");
}
#[test]
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
fn connectivity_follows_block_height_movement_only() {
let sync = DaemonSync {
reachable: true,
height: 23_758,
target_height: 3_090_939,
note: None,
};
// No earlier sample: the old copy, no connectivity claim.
assert_eq!(sync_line(&sync, None), "sync: syncing — 23758/3090939");
// The height moved: this is the only evidence of a P2P connection we have.
assert_eq!(
sync_line(&sync, Some(23_000)),
"sync: connected to P2P — syncing 23758/3090939"
);
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
// The daemon answers, but nothing arrives: do not call that connected.
let stalled = sync_line(&sync, Some(23_758));
assert_eq!(
stalled,
"sync: no new blocks — 23758/3090939 (daemon answering, no progress)"
);
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
assert!(!stalled.contains("connected"), "{stalled}");
}
#[test]
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
fn reaching_the_target_is_synced_and_an_unreachable_daemon_stays_unknown() {
let synced = DaemonSync {
reachable: true,
height: 3_210_000,
target_height: 3_210_000,
note: None,
};
assert_eq!(
sync_line(&synced, Some(3_100_000)),
"sync: synced — height 3210000"
);
let dead = DaemonSync {
reachable: false,
height: 0,
target_height: 0,
note: Some("127.0.0.1:18081: Connection refused".into()),
};
assert_eq!(
sync_line(&dead, Some(3_210_000)),
"sync: unknown — 127.0.0.1:18081: Connection refused"
);
}
/// The whole chain block on a Cuprate answer: real numbers, placeholders
/// nowhere. `DaemonSync` has no peer/database/free-space field to leak, and the
/// storage line comes from `df` on our own disk, not from the daemon.
#[test]
fn the_chain_block_never_shows_a_daemon_placeholder_metric() {
let view = chain_view_with_progress(
&ChainSource::Remote {
host: "127.0.0.1".into(),
port: 18089,
},
WalletChildState::Running,
&DaemonSync {
reachable: true,
height: 23_758,
target_height: 3_090_939,
note: None,
},
None,
wallet_readiness(true, true, false),
Some(23_000),
);
let block = view.lines().join("\n");
for banned in [
"5368709120",
"peer",
"18446744073709551615",
"0.1.0-preview",
] {
assert!(!block.contains(banned), "{banned} reached the UI:\n{block}");
}
assert_eq!(
view.sync_line,
"sync: connected to P2P — syncing 23758/3090939"
);
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
for line in view.lines() {
assert!(
wallet: typed chain-daemon client for the Cuprate parity gaps The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in Spike A (`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The client now parses the HTTP status once, de-chunks `Transfer-Encoding: chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk), and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed: their 5xx is the height error. `get_info` is not: its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it downloads blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line is now built from block-height movement between two probes: "connected to P2P" needs the height to have moved, "no new blocks" is what a stalled daemon gets, and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned too: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the restricted one — a restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. Scope deviations, stated plainly: - the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates (net -100 lines there), and the routing constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has to survive is item 1, so the mapping lives with the client. - the card's item 3 gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port; the app's local source already dials the unrestricted 18081. The rule is what is pinned, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon client has no home on `main`. Retarget to `main` when that line lands. Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked --all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/ `tests/tui_spec.rs` are unchanged in count or region).
2026-09-17 00:24:09 -04:00
line.chars().count() <= WALLET_LINE_MAX,
"line too long: {line}"
);
}
}