tui: the chain row says when this build has no in-process daemon
cuprate::available() was never consulted in the TUI, so the 'chain' row offered 'in-process node · cuprate in this app' in a build whose only possible answer is cuprate::NO_FEATURE_MSG. The row now carries that wording where the choice is made, the same way prune_display()/network_display() carry theirs. The choice stays in the picker: builds with the feature exist, and a stored in-process source must still be readable.
This commit is contained in:
parent
c877375ea5
commit
c776ea3e0c
1 changed files with 61 additions and 1 deletions
62
src/tui.rs
62
src/tui.rs
|
|
@ -1727,6 +1727,23 @@ impl WalletSetupConfigState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The value the `chain` row prints, including the one thing this build may
|
||||||
|
/// not be able to do: without `cuprate-daemon` the in-process choice cannot
|
||||||
|
/// start anything at all, so the row says so where the choice is made rather
|
||||||
|
/// than leaving the refusal for the start (`crate::cuprate::NO_FEATURE_MSG`).
|
||||||
|
/// The choice itself is never removed — builds with the feature exist.
|
||||||
|
fn chain_display(&self) -> String {
|
||||||
|
if self.source == SetupSource::InProcess && !crate::cuprate::available() {
|
||||||
|
format!(
|
||||||
|
"{} — {}",
|
||||||
|
self.source.word(),
|
||||||
|
crate::cuprate::NO_FEATURE_MSG
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
self.source.word().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn status_display(&self) -> String {
|
fn status_display(&self) -> String {
|
||||||
self.note
|
self.note
|
||||||
.clone()
|
.clone()
|
||||||
|
|
@ -4856,7 +4873,7 @@ pub fn wallet_setup_config_lines(width: u16, s: &WalletSetupConfigState) -> Vec<
|
||||||
s,
|
s,
|
||||||
SETUP_ROW_CHAIN,
|
SETUP_ROW_CHAIN,
|
||||||
"chain",
|
"chain",
|
||||||
&format!("{} (space changes)", s.source.word()),
|
&format!("{} (space changes)", s.chain_display()),
|
||||||
));
|
));
|
||||||
if s.source == SetupSource::Remote {
|
if s.source == SetupSource::Remote {
|
||||||
out.push(Line::from(
|
out.push(Line::from(
|
||||||
|
|
@ -7882,6 +7899,49 @@ mod wallet_setup_config_tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A build without `cuprate-daemon` cannot start the in-process daemon at
|
||||||
|
/// all, so the `chain` row has to say that where the choice is made rather
|
||||||
|
/// than offering one whose only answer is `cuprate::NO_FEATURE_MSG`.
|
||||||
|
#[cfg(not(feature = "cuprate-daemon"))]
|
||||||
|
#[test]
|
||||||
|
fn a_build_without_the_daemon_says_so_on_the_chain_row() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
let (mut app, _rt) = app(&dir.path().join("home"));
|
||||||
|
app.handle_key(key(KeyCode::F(7))).expect("F7");
|
||||||
|
pick_source(&mut app, SetupSource::InProcess);
|
||||||
|
|
||||||
|
let body = wallet_setup_config_text(200, state_of(&app));
|
||||||
|
assert!(
|
||||||
|
body.contains("in-process node"),
|
||||||
|
"the choice is still offered:\n{body}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
body.contains("--features cuprate-daemon"),
|
||||||
|
"the row must name the feature this build lacks:\n{body}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The same row in a build that *can* start it: no unavailable wording, and
|
||||||
|
/// the choice still reaches the store.
|
||||||
|
#[cfg(feature = "cuprate-daemon")]
|
||||||
|
#[test]
|
||||||
|
fn a_build_with_the_daemon_does_not_disown_the_in_process_choice() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
let (mut app, _rt) = app(&dir.path().join("home"));
|
||||||
|
app.handle_key(key(KeyCode::F(7))).expect("F7");
|
||||||
|
pick_source(&mut app, SetupSource::InProcess);
|
||||||
|
|
||||||
|
let body = wallet_setup_config_text(200, state_of(&app));
|
||||||
|
assert!(
|
||||||
|
body.contains("in-process node · cuprate in this app"),
|
||||||
|
"the row keeps the plain wording:\n{body}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!body.contains("rebuild with --features cuprate-daemon"),
|
||||||
|
"a build that can start it must not say it cannot:\n{body}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// F6 is the wallet again: the chain picker and the child's start/stop keys
|
/// 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
|
/// moved to F7, so pressing them there changes nothing and the store is not
|
||||||
/// touched behind the user's back.
|
/// touched behind the user's back.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue