tui: F7 becomes the node-setup screen, and F6 goes back to being the wallet
All checks were successful
ci / test (pull_request) Successful in 7m20s
ci / sdk (pull_request) Successful in 1m45s
android-ci / android (pull_request) Successful in 13m36s
ci / fuzz (pull_request) Successful in 5m29s

The chain source was reachable from three places and configured from none of
them properly: `F6`'s inline `1`/`2`/`3` picker wrote only the in-process
choice, the `F9` menu showed the state and named keys that edited it, and
`Node::set_local_monerod` / `set_remote_daemon` / `set_receive_only` — the only
way to point the app at a Monero node — had **no TUI caller at all** (Kotlin
only). `wallet::NOT_CONFIGURED_MSG` told users to "open F7" and there was no F7.

F7 (`WalletSetupConfig`) is now the one screen that sets up the node:

- The `datadir` row is new and editable. `Node::set_local_monerod_at` takes the
  path; `set_local_monerod` delegates with the derived default, so an existing
  install keeps the store it already has. An empty datadir is refused rather
  than silently replaced — a store that moved unasked looks like a vanished
  chain and resyncs somewhere the user did not choose.
- The `network` row is new: it carries the Cuprate mainnet/testnet choice that
  `F6`'s `1`/`2`/`3` used to own, so deleting those keys loses nothing. Mainnet
  reads `unvalidated` before it is picked.
- A `NODE` section shows the live `Node::wallet_child_status` line (state, chain
  source, `sync h/t`, last error) and the last save/test answer. It is the
  node's answer, never the draft above it, and `Ctrl-R` re-reads it.
- `Ctrl-S` saves and starts the child (the daemon, and `monerod` for a local
  source); `Ctrl-X` stops it. Both go through the same `Node::start_wallet_child`
  / `stop_wallet_child` the app's own lifecycle uses, so a start that lands on a
  wallet with no stored passphrase still reaches the unlock prompt.

F6 loses the chain picker and the `s`/`x`/`p` child keys — it is the wallet
again (receive, balance, transfers, create/import) — and its footer points at
`F7 node`. The `F9` menu's `child`/`sync` rows now name `F7 ctrl-s/x` and
`F7 ctrl-r` instead of keys that no longer exist on F6. `set_cuprate_chain` and
the `p` probe handler are deleted rather than left dead.

The node's own keys are named in the body, on the section they act on: at 80
columns the footer has room for one group and the status line already spends
half the width, which is the same reason the login row names `Ctrl-U`.

Tests: six new cases in `src/tui.rs`'s `wallet_setup_config_tests` drive the real
key path and the real node — the typed datadir reaching `ChainSource::Local`, an
empty one being refused with nothing written, the live row on open, `Ctrl-S`
saving then reporting the node's own refusal, the in-process network pick
reaching the store, and F6 no longer owning keys it does not handle.
`tests/tui_spec.rs`'s menu-key check now asserts the F7 keys; the F6 keys it
asserted before no longer work.
This commit is contained in:
agent 2026-09-27 20:06:51 -04:00
commit 5cdfbacf10
No known key found for this signature in database
6 changed files with 509 additions and 106 deletions

View file

@ -1384,7 +1384,7 @@ impl SetupSource {
Self::ReceiveOnly => "receive-only · no chain, no spend",
Self::Local => "local node · this box spawns monerod",
Self::Remote => "remote daemon · one you run elsewhere",
Self::InProcess => "in-process node · set on F6",
Self::InProcess => "in-process node · cuprate in this app",
}
}
}
@ -1396,8 +1396,10 @@ const SETUP_ROW_NO_SPEND: usize = 2;
const SETUP_ROW_CHAIN: usize = 3;
const SETUP_ROW_DAEMON: usize = 4;
const SETUP_ROW_MONEROD: usize = 5;
const SETUP_ROW_PRUNE: usize = 6;
const SETUP_ROWS: usize = 7;
const SETUP_ROW_DATADIR: usize = 6;
const SETUP_ROW_PRUNE: usize = 7;
const SETUP_ROW_NETWORK: usize = 8;
const SETUP_ROWS: usize = 9;
/// The F7 screen's draft: plain data taken once when the screen opens
/// (`Node::wallet_config` plus `Node::wallet_child_config`), never a handle onto
@ -1416,6 +1418,10 @@ pub struct WalletSetupConfigState {
/// `host:port` for the remote daemon.
daemon: String,
monerod_bin: String,
/// Chain datadir for a local node (spawned `monerod` or in-process Cuprate).
/// Prefilled with the path the node already uses, so a save that leaves it
/// alone keeps the chain where it is.
datadir: String,
prune: bool,
/// The chain row was changed on this screen. An untouched row is not
/// written, so an in-process Cuprate source survives an F7 save.
@ -1423,6 +1429,10 @@ pub struct WalletSetupConfigState {
cuprate_network: ChainNetwork,
/// The last save / test answer, display-ready, never a secret.
note: Option<String>,
/// The live node/child line, refreshed on open and by `Ctrl-R`. This is the
/// answer to "did the node I just configured come up?" — taken from
/// `Node::wallet_child_status`, never inferred from the draft above.
status: Option<String>,
}
/// `Debug` is written by hand and redacts the login. Nothing in the app prints
@ -1445,10 +1455,12 @@ impl std::fmt::Debug for WalletSetupConfigState {
.field("source", &self.source)
.field("daemon", &self.daemon)
.field("monerod_bin", &self.monerod_bin)
.field("datadir", &self.datadir)
.field("prune", &self.prune)
.field("chain_touched", &self.chain_touched)
.field("cuprate_network", &self.cuprate_network)
.field("note", &self.note)
.field("status", &self.status)
.finish()
}
}
@ -1471,26 +1483,38 @@ impl WalletSetupConfigState {
source: SetupSource::ReceiveOnly,
daemon: format!("127.0.0.1:{DEFAULT_MONEROD_RPC_PORT}"),
monerod_bin: "monerod".to_string(),
// The default a save would use if the user never types one; a stored
// local/in-process source overwrites it below with its real path.
datadir: node.local_chain_datadir(false).display().to_string(),
prune: false,
chain_touched: false,
cuprate_network: ChainNetwork::Mainnet,
note: None,
status: None,
};
match &child.source {
ChainSource::None => {}
ChainSource::Local {
monerod_bin, prune, ..
monerod_bin,
datadir,
prune,
} => {
state.source = SetupSource::Local;
state.monerod_bin = monerod_bin.display().to_string();
state.datadir = datadir.display().to_string();
state.prune = *prune;
}
ChainSource::Remote { host, port } => {
state.source = SetupSource::Remote;
state.daemon = format!("{host}:{port}");
}
ChainSource::InProcessCuprate { network, prune, .. } => {
ChainSource::InProcessCuprate {
datadir,
network,
prune,
} => {
state.source = SetupSource::InProcess;
state.datadir = datadir.display().to_string();
state.prune = *prune;
state.cuprate_network = *network;
}
@ -1498,6 +1522,18 @@ impl WalletSetupConfigState {
state
}
/// Read the live node/child line into the screen. Called on open and by
/// `Ctrl-R`, so what the status row shows is what the node answered, never
/// what the draft above it claims.
pub fn refresh_status(&mut self, node: &Node) {
let line = node.wallet_child_status().line();
self.status = Some(if line.is_empty() {
"node not configured · pick a chain source and ctrl-s".to_string()
} else {
format!("node {line}")
});
}
/// The one secret in this state goes away with the screen, on purpose.
fn close(&mut self) {
self.rpc_login.zeroize();
@ -1522,6 +1558,7 @@ impl WalletSetupConfigState {
SETUP_ROW_LOGIN => self.rpc_login.push(c),
SETUP_ROW_DAEMON => self.daemon.push(c),
SETUP_ROW_MONEROD => self.monerod_bin.push(c),
SETUP_ROW_DATADIR => self.datadir.push(c),
_ => {}
}
}
@ -1532,6 +1569,7 @@ impl WalletSetupConfigState {
SETUP_ROW_LOGIN => self.rpc_login.pop(),
SETUP_ROW_DAEMON => self.daemon.pop(),
SETUP_ROW_MONEROD => self.monerod_bin.pop(),
SETUP_ROW_DATADIR => self.datadir.pop(),
_ => None,
};
}
@ -1544,6 +1582,7 @@ impl WalletSetupConfigState {
SETUP_ROW_LOGIN => self.rpc_login.zeroize(),
SETUP_ROW_DAEMON => self.daemon.clear(),
SETUP_ROW_MONEROD => self.monerod_bin.clear(),
SETUP_ROW_DATADIR => self.datadir.clear(),
_ => {}
}
}
@ -1559,10 +1598,20 @@ impl WalletSetupConfigState {
self.prune = !self.prune;
self.chain_touched = true;
}
// The in-process node's network, which F6's `1`/`2`/`3` used to own:
// moving the chain picker here must not lose the choice.
SETUP_ROW_NETWORK => {
self.cuprate_network = match self.cuprate_network {
ChainNetwork::Mainnet => ChainNetwork::Testnet,
ChainNetwork::Testnet => ChainNetwork::Mainnet,
};
self.chain_touched = true;
}
SETUP_ROW_URL => self.rpc_url.push(' '),
SETUP_ROW_LOGIN => self.rpc_login.push(' '),
SETUP_ROW_DAEMON => self.daemon.push(' '),
SETUP_ROW_MONEROD => self.monerod_bin.push(' '),
SETUP_ROW_DATADIR => self.datadir.push(' '),
_ => {}
}
}
@ -1577,17 +1626,24 @@ impl WalletSetupConfigState {
}
let chain = match self.source {
SetupSource::ReceiveOnly => node.set_receive_only(),
SetupSource::Local => node.set_local_monerod(Path::new(&self.monerod_bin), self.prune),
SetupSource::Local => node.set_local_monerod_at(
Path::new(&self.monerod_bin),
Path::new(&self.datadir),
self.prune,
),
SetupSource::Remote => match parse_daemon_addr(&self.daemon) {
Some((host, port)) => node.set_remote_daemon(&host, port),
None => return "not saved · daemon address must be host:port".to_string(),
},
// Untouched: leave whatever F6 stored, including nothing.
// Untouched: leave whatever held it before, including the in-process
// choice F6 used to own, rather than silently rewriting its datadir.
SetupSource::InProcess if !self.chain_touched => Ok(()),
SetupSource::InProcess => node.set_in_process_cuprate(self.cuprate_network, self.prune),
};
match chain {
Ok(()) => "saved · not dialled — ctrl-t tests the endpoint".to_string(),
Ok(()) => {
"saved · not dialled yet — ctrl-s starts it, ctrl-t tests the endpoint".to_string()
}
Err(e) => format!("wallet config saved · chain source: {e}"),
}
}
@ -1624,6 +1680,16 @@ impl WalletSetupConfigState {
}
}
/// The in-process node's network row. Mainnet says it is unvalidated in the
/// same words `cuprate::TESTNET_ONLY` uses, because that is the fact a user
/// picking it needs.
fn network_display(&self) -> &'static str {
match self.cuprate_network {
ChainNetwork::Mainnet => "mainnet · unvalidated",
ChainNetwork::Testnet => "testnet",
}
}
fn status_display(&self) -> String {
self.note
.clone()
@ -2038,12 +2104,8 @@ impl App {
// `w` is the wallet list: the F6 screen is about the wallet you
// are on, and this is how you get off it.
KeyCode::Char('w') => self.open_wallet_select(),
KeyCode::Char('s') => self.wallet_child_start(),
KeyCode::Char('x') => self.wallet_child_stop(),
KeyCode::Char('p') => self.wallet_child_probe(),
KeyCode::Char('1') => self.set_cuprate_chain(ChainNetwork::Mainnet, true),
KeyCode::Char('2') => self.set_cuprate_chain(ChainNetwork::Mainnet, false),
KeyCode::Char('3') => self.set_cuprate_chain(ChainNetwork::Testnet, false),
// The node's own keys (start/stop/probe, chain source) are F7's.
// F6 is the wallet: receive, balance, transfers, create/import.
KeyCode::Char('c') => {
self.screen = Screen::WalletSetup(WalletSetup::CreateWarn {
typed: String::new(),
@ -2663,33 +2725,18 @@ impl App {
});
}
/// Key `p`: one probe of the running child — is its RPC answering, and is
/// the chain at the tip? The only thing that can report `ready`.
fn wallet_child_probe(&mut self) {
self.status_note = Some(self.wallet_child_note());
}
fn set_cuprate_chain(&mut self, network: ChainNetwork, prune: bool) {
self.status_note = Some(match self.node.set_in_process_cuprate(network, prune) {
Ok(()) => format!(
"chain source: {}",
self.node.wallet_child_config().source.label()
),
Err(e) => format!("chain source: {e}"),
});
}
/// F7: open the setup screen with the stored (or env-derived) values as the
/// draft. Nothing is read from the store while the screen is open.
fn open_setup_config(&mut self) {
self.screen = Screen::WalletSetupConfig {
state: WalletSetupConfigState::from_node(&self.node),
};
let mut state = WalletSetupConfigState::from_node(&self.node);
state.refresh_status(&self.node);
self.screen = Screen::WalletSetupConfig { state };
}
/// Keys on the F7 screen: `Tab` moves, `Enter` saves, `Ctrl-T` tests the
/// endpoint, `Ctrl-U` clears the focused field, `Esc` leaves and wipes the
/// login buffer.
/// wallet RPC endpoint, `Ctrl-S` saves and starts the node/wallet child,
/// `Ctrl-X` stops it, `Ctrl-R` re-reads the live node line, `Ctrl-U` clears
/// the focused field, `Esc` leaves and wipes the login buffer.
fn handle_wallet_setup_config(&mut self, key: KeyEvent) {
if key.code == KeyCode::Esc {
if let Screen::WalletSetupConfig { state } = &mut self.screen {
@ -2707,6 +2754,28 @@ impl App {
state.note = Some(note);
return;
}
// Start/stop go through `App`'s own child helpers so this screen and the
// wallet screen that used to own them cannot drift: same start, same
// passphrase prompt, same status line.
if ctrl && key.code == KeyCode::Char('s') {
let Screen::WalletSetupConfig { state } = &mut self.screen else {
return;
};
let note = state.save(&self.node);
state.note = Some(note);
self.wallet_child_start();
self.refresh_setup_status();
return;
}
if ctrl && key.code == KeyCode::Char('x') {
self.wallet_child_stop();
self.refresh_setup_status();
return;
}
if ctrl && key.code == KeyCode::Char('r') {
self.refresh_setup_status();
return;
}
let Screen::WalletSetupConfig { state } = &mut self.screen else {
return;
};
@ -2725,6 +2794,15 @@ impl App {
}
}
/// Re-read the live node line into the F7 screen, if it is still the screen
/// on show. A start that needed a passphrase has already moved the app to
/// the unlock prompt, and this must not drag it back.
fn refresh_setup_status(&mut self) {
if let Screen::WalletSetupConfig { state } = &mut self.screen {
state.refresh_status(&self.node);
}
}
/// The child status line, or the copy that names what is missing.
fn wallet_child_note(&mut self) -> String {
let line = self.rt.block_on(self.node.wallet_child_refresh()).line();
@ -3913,7 +3991,7 @@ match screen {
},
Screen::Passphrase { .. } => "Enter submit Esc cancel ? help",
Screen::Wallet { .. } => {
"c create i import r qr w wallets s/x child 1 pruned 2 full 3 testnet Esc back ? help"
"c create i import r qr w wallets F7 node Esc back ? help"
}
Screen::WalletSetup(WalletSetup::CreateWarn { .. }) => "type SPEND Esc cancel ? help",
Screen::WalletSetup(WalletSetup::CreatePass { .. } | WalletSetup::UnlockPass { .. }) => {
@ -4427,8 +4505,8 @@ fn menu_groups(s: &WalletMenuState) -> (Vec<MenuRow>, Vec<MenuRow>) {
// `F7` is the key that edits this row, so the row names it: the menu is
// the discovery layer, and the endpoint is the one thing only F7 writes.
MenuRow::new("endpoint", endpoint_value, "F7", endpoint_tone),
MenuRow::new("child", child_value, "F6 s/x", MenuTone::Normal),
MenuRow::new("sync", sync_value, "F6 p", sync_tone),
MenuRow::new("child", child_value, "F7 ctrl-s/x", MenuTone::Normal),
MenuRow::new("sync", sync_value, "F7 ctrl-r", sync_tone),
MenuRow::new(
"receive",
if receive_empty {
@ -4751,6 +4829,13 @@ pub fn wallet_setup_config_lines(width: u16, s: &WalletSetupConfigState) -> Vec<
"monerod",
&s.monerod_bin,
));
out.push(setup_row_line(
w,
s,
SETUP_ROW_DATADIR,
"datadir",
&s.datadir,
));
out.push(setup_row_line(
w,
s,
@ -4758,9 +4843,38 @@ pub fn wallet_setup_config_lines(width: u16, s: &WalletSetupConfigState) -> Vec<
"prune",
s.prune_display(),
));
out.push(setup_row_line(
w,
s,
SETUP_ROW_NETWORK,
"network",
&format!("{} (space changes)", s.network_display()),
));
out.push(Line::default());
out.push(menu_section_line(w, "NODE"));
// What the node answered, not what the draft claims: the row is filled from
// `Node::wallet_child_status` and says so when nothing is configured yet.
out.push(Line::from(
Span::raw(fit_cells(&format!("status {}", s.status_display()), w)).style(style_dim()),
Span::raw(fit_cells(
s.status
.as_deref()
.unwrap_or("node unknown — ctrl-r re-reads the live state"),
w,
))
.style(style_dim()),
));
// The node's own keys are named here, on the section they act on, for the
// same reason the login row names `ctrl-u`: at 80 columns the footer has
// room for one group and the status line already spends half the width.
out.push(Line::from(
Span::raw(fit_cells(
"keys ctrl-s save + start ctrl-x stop ctrl-r re-read",
w,
))
.style(style_dim()),
));
out.push(Line::from(
Span::raw(fit_cells(&format!("last {}", s.status_display()), w)).style(style_dim()),
));
out
}
@ -5910,7 +6024,7 @@ balance
lines.push(format!(" {} {} XMR", t.txid.chars().take(16).collect::<String>(), xmr));
}
}
let help = "s start child x stop child p probe c create i import r qr Esc back";
let help = "c create i import r qr w wallets F7 node Esc back";
lines.push("".into());
f.render_widget(
Paragraph::new(lines.join("\n"))
@ -6229,12 +6343,6 @@ mod wallet_store_tests {
frame_on(app, 80, 24)
}
/// Whitespace-collapsed copy of some drawn text, so a sentence the renderer
/// wrapped across lines still reads as the one string that produced it.
fn flattened(text: &str) -> String {
text.split_whitespace().collect::<Vec<_>>().join(" ")
}
/// Nothing remembered means nothing to warn about: a first run opens on the
/// main view, not on the create flow's spend-authority warning. Asserting
/// the screen alone would pass with the warning merely drawn behind Main, so
@ -6410,10 +6518,6 @@ mod wallet_store_tests {
assert_eq!(app.status_note.as_deref(), Some("opened wallet fresh"));
}
fn key(code: KeyCode) -> KeyEvent {
KeyEvent::new(code, KeyModifiers::NONE)
}
/// What the real render path puts on an 80x24 terminal — `App::draw`, not a
/// stand-in widget.
fn frame_text(app: &App) -> String {
@ -7412,4 +7516,245 @@ mod wallet_setup_config_tests {
assert_eq!(after, before, "a rejected form wrote something");
assert!(after.no_spend, "the stored view-only flag is untouched");
}
/// `Tab` from wherever the form is focused until `row` has it. The tests
/// below drive the real key path, not the state directly.
fn focus_row(app: &mut App, row: usize) {
let mut guard = 0;
while state_of(app).field != row {
app.handle_key(key(KeyCode::Tab)).expect("tab");
guard += 1;
assert!(guard <= SETUP_ROWS, "row {row} is unreachable by Tab");
}
}
/// Pick the `chain` row's source by cycling it with `space`.
fn pick_source(app: &mut App, want: SetupSource) {
focus_row(app, SETUP_ROW_CHAIN);
for _ in 0..4 {
if state_of(app).source == want {
return;
}
app.handle_key(key(KeyCode::Char(' '))).expect("space");
}
panic!("the picker never reached {want:?}");
}
/// The point of the datadir row: a local node goes where the user says, not
/// where the default was. This is the node-setup path the app lacked —
/// `set_local_monerod` was reachable only from Kotlin.
#[test]
fn a_local_node_saves_the_datadir_the_user_typed() {
let dir = tempfile::tempdir().unwrap();
let home = dir.path().join("home");
let (mut app, _rt) = app(&home);
app.handle_key(key(KeyCode::F(7))).expect("F7");
fill_endpoint(&mut app);
pick_source(&mut app, SetupSource::Local);
focus_row(&mut app, SETUP_ROW_MONEROD);
for _ in 0.."monerod".len() {
app.handle_key(key(KeyCode::Backspace)).expect("backspace");
}
type_str(&mut app, "/opt/monero/monerod");
let typed = home.join("chain-tank");
focus_row(&mut app, SETUP_ROW_DATADIR);
app.handle_key(KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL))
.expect("ctrl-u");
type_str(&mut app, typed.to_str().expect("utf8 path"));
app.handle_key(key(KeyCode::Enter)).expect("enter");
assert!(
state_of(&app)
.note
.as_deref()
.expect("a status line")
.starts_with("saved"),
"the save must land: {:?}",
state_of(&app).note
);
match &app.node.wallet_child_config().source {
ChainSource::Local {
monerod_bin,
datadir,
prune,
} => {
assert_eq!(monerod_bin.to_str(), Some("/opt/monero/monerod"));
assert_eq!(
datadir, &typed,
"the node must store its chain where the user said"
);
assert!(!prune);
}
other => panic!("expected a local node, got {other:?}"),
}
}
/// An empty datadir is refused rather than silently replaced with the
/// default: a store that moved without being asked looks like a vanished
/// chain, and the resync lands somewhere the user did not choose.
#[test]
fn an_empty_datadir_is_refused_and_the_source_is_not_written() {
let dir = tempfile::tempdir().unwrap();
let (mut app, _rt) = app(&dir.path().join("home"));
app.handle_key(key(KeyCode::F(7))).expect("F7");
fill_endpoint(&mut app);
pick_source(&mut app, SetupSource::Local);
focus_row(&mut app, SETUP_ROW_DATADIR);
app.handle_key(KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL))
.expect("ctrl-u");
app.handle_key(key(KeyCode::Enter)).expect("enter");
let note = state_of(&app).note.as_deref().expect("a status line");
assert!(
note.contains("datadir required"),
"the refusal must name the missing field: {note}"
);
assert_eq!(
app.node.wallet_child_config().source,
ChainSource::None,
"a refused chain source must not be stored"
);
}
/// The row answers with what the node says, not with what the draft above it
/// claims: on a fresh install that is "nothing configured yet".
#[test]
fn the_node_row_shows_the_live_state_on_open() {
let dir = tempfile::tempdir().unwrap();
let (mut app, _rt) = app(&dir.path().join("home"));
app.handle_key(key(KeyCode::F(7))).expect("F7");
let status = state_of(&app)
.status
.as_deref()
.expect("the screen reads the node on open");
assert!(
status.starts_with("node"),
"the live row must be the node's answer: {status}"
);
let body = wallet_setup_config_text(78, state_of(&app));
assert!(
body.contains("not configured"),
"an unconfigured install must say so, not print a blank row:\n{body}"
);
// The node's keys are discoverable from the body: at 80 columns the
// footer has no room for them.
for needle in ["ctrl-s save + start", "ctrl-x stop", "ctrl-r re-read"] {
assert!(
body.contains(needle),
"{needle:?} must be named on the screen that uses it:\n{body}"
);
}
}
/// `Ctrl-S` is the key that actually brings the node up: it saves the form
/// and then asks the node to start. With no chain source the start refuses
/// in the node's own words and the screen stays put.
#[test]
fn ctrl_s_saves_then_reports_the_nodes_own_refusal() {
let dir = tempfile::tempdir().unwrap();
let (mut app, _rt) = app(&dir.path().join("home"));
app.handle_key(key(KeyCode::F(7))).expect("F7");
fill_endpoint(&mut app);
app.handle_key(KeyEvent::new(KeyCode::Char('s'), KeyModifiers::CONTROL))
.expect("ctrl-s");
assert!(
state_of(&app)
.note
.as_deref()
.expect("a status line")
.starts_with("saved"),
"ctrl-s must save first: {:?}",
state_of(&app).note
);
assert_eq!(
app.node
.wallet_config()
.expect("the endpoint saved")
.rpc_url,
URL
);
let note = app.status_note.as_deref().expect("the start reported");
assert!(
note.contains("receive-only"),
"a receive-only install must be told why nothing started: {note}"
);
assert!(
matches!(app.screen, Screen::WalletSetupConfig { .. }),
"a start that needs no passphrase must leave the user on F7"
);
}
/// F6's `1`/`2`/`3` keys were also the only way to pick the in-process node's
/// network. That choice moved here with the picker instead of being lost.
#[test]
fn the_in_process_network_is_still_selectable() {
let dir = tempfile::tempdir().unwrap();
let (mut app, _rt) = app(&dir.path().join("home"));
app.handle_key(key(KeyCode::F(7))).expect("F7");
fill_endpoint(&mut app);
pick_source(&mut app, SetupSource::InProcess);
assert_eq!(state_of(&app).cuprate_network, ChainNetwork::Mainnet);
focus_row(&mut app, SETUP_ROW_NETWORK);
let body = wallet_setup_config_text(78, state_of(&app));
assert!(
body.contains("unvalidated"),
"mainnet must say it is unvalidated before it is picked:\n{body}"
);
app.handle_key(key(KeyCode::Char(' '))).expect("space");
assert_eq!(state_of(&app).cuprate_network, ChainNetwork::Testnet);
app.handle_key(key(KeyCode::Enter)).expect("enter");
match &app.node.wallet_child_config().source {
ChainSource::InProcessCuprate { network, .. } => assert_eq!(
*network,
ChainNetwork::Testnet,
"the network pick must reach the stored source"
),
other => panic!("expected an in-process source, got {other:?}"),
}
}
/// F6 is the wallet again: the chain picker and the child's start/stop keys
/// moved to F7, so pressing them there changes nothing and the store is not
/// touched behind the user's back.
#[test]
fn f6_no_longer_owns_the_chain_picker_or_the_child_keys() {
let dir = tempfile::tempdir().unwrap();
let (mut app, _rt) = app(&dir.path().join("home"));
app.handle_key(key(KeyCode::F(6))).expect("F6");
assert!(matches!(app.screen, Screen::Wallet { .. }));
for c in ['s', 'x', 'p', '1', '2', '3'] {
app.handle_key(key(KeyCode::Char(c))).expect("key");
assert!(
matches!(app.screen, Screen::Wallet { .. }),
"`{c}` must not leave the wallet screen"
);
}
assert_eq!(
app.node.wallet_child_config().source,
ChainSource::None,
"keys F6 no longer owns must not write a chain source"
);
// And the footer no longer advertises them.
let footer = footer_hints(&app.screen);
assert!(
footer.contains("F7 node"),
"F6 must point at F7 for the node: {footer}"
);
assert!(
!footer.contains("1 pruned") && !footer.contains("s/x child"),
"F6 must not still advertise the keys it lost: {footer}"
);
}
}