tui: re-probe chain height while the node screen is up
All checks were successful
ci / test (pull_request) Successful in 14m16s
ci / sdk (pull_request) Successful in 1m28s

The F7 NODE row kept the height from child start. Ctrl-R only
re-read that cache, so a syncing daemon looked frozen. Poll
wallet_child_refresh off the UI thread and copy the answer back.
This commit is contained in:
agent 2026-10-11 16:12:38 -04:00
commit 99581bec5e
No known key found for this signature in database
2 changed files with 201 additions and 6 deletions

View file

@ -3195,7 +3195,7 @@ pub(crate) mod tests {
/// single-child tests read; a test that spans two children reads the
/// pid-named one, because a previous child's write into the shared path is
/// unsequenced against the test (see [`wait_for_child_rpc_port`]).
fn fake_child_bin(dir: &Path, name: &str, log: &Path, body: &str) -> PathBuf {
pub(crate) fn fake_child_bin(dir: &Path, name: &str, log: &Path, body: &str) -> PathBuf {
fake_child_bin_after(dir, name, log, "", body)
}
@ -3294,6 +3294,41 @@ pub(crate) mod tests {
Wallet::from_url(&format!("http://ow:[email protected]:{port}")).expect("wallet url")
}
/// Point `node`'s wallet client at a mock. The child process stays whatever
/// `start_wallet_child` spawned; only the dial target moves.
pub(crate) fn test_install_wallet(node: &Node, wallet: Wallet) {
*node.wallet.lock().expect("wallet") = wallet;
}
/// Like [`mock_syncing_wallet`], but `height` is read on every `get_info`,
/// so a later store is a later answer. `synchronized` stays false: the
/// status line is a syncing chain, not a caught-up one.
pub(crate) async fn mock_wallet_at(
height: std::sync::Arc<std::sync::atomic::AtomicU64>,
target: u64,
) -> Wallet {
use std::sync::atomic::Ordering;
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
.await
.expect("bind mock wallet");
let port = listener.local_addr().expect("mock wallet addr").port();
let reply: Arc<dyn Fn(&str) -> String + Send + Sync> = Arc::new(move |req: &str| {
if req.contains("get_info") {
let h = height.load(Ordering::Relaxed);
format!(
r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{h},"target_height":{target},"synchronized":false}}}}"#
)
} else if req.contains("get_address") {
r#"{"jsonrpc":"2.0","id":"0","result":{"address":"4test"}}"#.to_string()
} else {
r#"{"jsonrpc":"2.0","id":"0","result":{"balance":"0"}}"#.to_string()
}
});
tokio::spawn(serve_mock_rpc(listener, reply));
Wallet::from_url(&format!("http://ow:[email protected]:{port}")).expect("wallet url")
}
/// A loopback daemon that answers `get_info` on the port the child probes
/// when its wallet RPC is down. `None` when that port is already held (a real
/// `monerod` on this box): that daemon is not ours to replace, and the test