monerod: fix the PATH-empty test and the wallet-child doc overclaim
Review round 1 (artifact lens) on PR #91 found two defects. 1. `spawn_without_monerod_on_path_is_a_clear_error` passed `Some(OsStr::new(""))` as the search path. `std::env::split_paths("")` yields ONE empty element, so `find_in` probed the relative path `monerod` in the test's cwd and passed only because the crate root happened to hold no such file. Point it at an empty temp dir instead, which is what the card's "test by pointing PATH empty" asked for. Verified RED first: with an executable `./monerod` planted in the crate root, the old test fails ("spawn monerod: No such file or directory") and the new one passes with that same file still present. 2. The docs claimed a wiring the code does not perform: "The wallet child is pointed at that RPC with --daemon-address 127.0.0.1:18089". Nothing points anything — `--daemon-address` exists in `src/` only inside comments, and `Node::monerod_rpc_addr()` has no caller. docs/WALLET.md now tells the operator to point their own wallet child at the loopback RPC and says the address is only exposed programmatically. The same overclaim in the `monerod_rpc_addr` doc comment in src/node.rs is corrected too. Also one module-doc line for the non-blocking note: a port-liveness check cannot tell whose port it is, so a pre-existing listener on 18089 yields Ok for a child that failed to bind.
This commit is contained in:
parent
c45b008e97
commit
4ff95ce271
3 changed files with 18 additions and 8 deletions
|
|
@ -86,9 +86,12 @@ Set `ONIONWIRE_MONEROD=1` and the app starts the daemon itself — you do not ru
|
||||||
`$ONIONWIRE_HOME/monero/` (mode 0700, never `/tmp` and never a shared location),
|
`$ONIONWIRE_HOME/monero/` (mode 0700, never `/tmp` and never a shared location),
|
||||||
and starts it with `--prune-blockchain --non-interactive`, its RPC bound to
|
and starts it with `--prune-blockchain --non-interactive`, its RPC bound to
|
||||||
loopback only (`--rpc-bind-ip 127.0.0.1 --rpc-bind-port 18089`), logging to
|
loopback only (`--rpc-bind-ip 127.0.0.1 --rpc-bind-port 18089`), logging to
|
||||||
`$ONIONWIRE_HOME/monero/monerod.log`. The wallet child is pointed at that RPC
|
`$ONIONWIRE_HOME/monero/monerod.log`. Point your wallet child at that RPC
|
||||||
with `--daemon-address 127.0.0.1:18089`; which process runs the wallet RPC (and
|
yourself — `--daemon-address 127.0.0.1:18089`, exactly like the daemon address in
|
||||||
how it is started) is separate from this and unchanged.
|
option 2 above. OnionWire does not configure the wallet child for you; the
|
||||||
|
address is only *exposed* to callers as `Node::monerod_rpc_addr()`, so a wallet
|
||||||
|
child left on its previous `--daemon-address` keeps using that one. Which process
|
||||||
|
runs the wallet RPC (and how it is started) is separate from this and unchanged.
|
||||||
|
|
||||||
Zero trust is not optional here either: the spawn never passes
|
Zero trust is not optional here either: the spawn never passes
|
||||||
`--trusted-daemon`, and the daemon's RPC is loopback so only this machine can
|
`--trusted-daemon`, and the daemon's RPC is loopback so only this machine can
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ pub fn rpc_addr(port: u16) -> SocketAddr {
|
||||||
///
|
///
|
||||||
/// A listening port is "ready enough": `monerod` binds RPC before it serves
|
/// A listening port is "ready enough": `monerod` binds RPC before it serves
|
||||||
/// blocks, and the wallet child reports its own sync progress from there. We do
|
/// blocks, and the wallet child reports its own sync progress from there. We do
|
||||||
/// not speak HTTP ourselves.
|
/// not speak HTTP ourselves. Corollary: a port check cannot tell *whose* port it
|
||||||
|
/// is — if something already listens on `addr` (an operator's own `monerod`),
|
||||||
|
/// this returns `Ok` even though our child may have failed to bind. The
|
||||||
|
/// effective state is still "a local chain on loopback `addr`".
|
||||||
pub fn wait_for_ready(addr: SocketAddr, timeout: Duration) -> Result<(), String> {
|
pub fn wait_for_ready(addr: SocketAddr, timeout: Duration) -> Result<(), String> {
|
||||||
let started = Instant::now();
|
let started = Instant::now();
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -234,7 +237,6 @@ fn sigterm(pid: u32) -> bool {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
@ -326,7 +328,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn spawn_without_monerod_on_path_is_a_clear_error() {
|
fn spawn_without_monerod_on_path_is_a_clear_error() {
|
||||||
let dir = tempfile::tempdir().expect("tempdir");
|
let dir = tempfile::tempdir().expect("tempdir");
|
||||||
let empty = OsStr::new("");
|
// The search path must be empty of `monerod`. `Some(OsStr::new(""))` is
|
||||||
|
// NOT that: `split_paths("")` yields one empty element, which `Path::join`
|
||||||
|
// resolves to `./monerod` in the test's cwd (so a `monerod` sitting in the
|
||||||
|
// crate root would be found). Point at an empty directory instead.
|
||||||
|
let empty = dir.path().as_os_str();
|
||||||
let err = match Monerod::spawn_with_path(dir.path(), Some(empty)) {
|
let err = match Monerod::spawn_with_path(dir.path(), Some(empty)) {
|
||||||
Ok(_) => panic!("no monerod on PATH"),
|
Ok(_) => panic!("no monerod on PATH"),
|
||||||
Err(e) => e,
|
Err(e) => e,
|
||||||
|
|
|
||||||
|
|
@ -278,8 +278,9 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where the spawned local chain source listens, if this node started one
|
/// Where the spawned local chain source listens, if this node started one
|
||||||
/// (`ONIONWIRE_MONEROD=1`). This is what the wallet child is pointed at
|
/// (`ONIONWIRE_MONEROD=1`). Exposed so a caller can point the wallet child
|
||||||
/// with `--daemon-address`; `None` means no local chain.
|
/// here with `--daemon-address`; the node does not wire that up itself.
|
||||||
|
/// `None` means no local chain.
|
||||||
pub fn monerod_rpc_addr(&self) -> Option<SocketAddr> {
|
pub fn monerod_rpc_addr(&self) -> Option<SocketAddr> {
|
||||||
self.monerod
|
self.monerod
|
||||||
.lock()
|
.lock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue