tests: take the restart's port from the child that dials it
All checks were successful
ci / test (pull_request) Successful in 6m3s
ci / sdk (pull_request) Successful in 1m14s
ci / fuzz (pull_request) Successful in 4m53s
android-ci / android (pull_request) Successful in 12m15s

`a_restart_opens_the_stored_wallet_file` failed on the Pi runner twice in a
row — CI run 905 job 1373 and run 901 job 1365 — and passed 3/3 on a 16-core
host:

  open the wallet with a passphrase: "wallet file onionwire-1 is not open —
  the wallet RPC never answered (wallet connect: Connection refused (os error
  111))"

The whole `WALLET_OPEN_WAIT` was burned on refusals, so the mock was bound on
a port the restarted child never dialled. Production is not the suspect:
`WalletChild::start_children` builds the child's argv and the `WalletClient`
URL from the same `pick_port` value, and `start_wallet_child_with` installs
that client in `self.wallet` before `open_child_wallet` dials it, so the client
can never carry the previous child's port.

The harness is the suspect. It learned the restarted child's port from the
*shared* argv log — a file every child writes — and cleared that file first.
A clear is not a synchronisation: on a loaded runner the killed child's write
lands after it, so the poller read the port of a child that was already dead
and bound the mock there. Reproduced deterministically with a stand-in whose
exec is late; with the old read the new test fails with the CI message, byte
for byte.

Each fake child now writes `<log>.<pid>` as well, and the shared copy lands
first, so a pid-named file implies the shared one is complete. A test that
spans two children reads the pid-named file: only that child can write it, so
the port belongs to the child that dials it. `WalletChild::wallet_rpc_pid`
(test-only) supplies the pid.

`open_wallet_blocking` already retries while the RPC is unreachable and gives
up after a bounded wait with a typed `OpenFailure::NotAnswering`, so it cannot
refuse forever against a merely slow child: no production change.

new test: node::tests::a_restart_is_not_given_the_stopped_childs_port
This commit is contained in:
agent 2026-09-22 15:37:55 -04:00
commit 6edcd65e96
No known key found for this signature in database
2 changed files with 190 additions and 20 deletions

View file

@ -207,6 +207,20 @@ impl WalletChild {
self.wallet_rpc.lock().map(|g| g.is_some()).unwrap_or(false)
}
/// The pid of the running `monero-wallet-rpc` child, when there is one.
///
/// Test-only: the lib test harness names *this* spawn's argv log with it.
/// The shared log path is written by every child and a previous child's
/// write is unsequenced against anything a test does, so a restarted
/// child's port cannot be learned from it (see `node::tests`).
#[cfg(test)]
pub(crate) fn wallet_rpc_pid(&self) -> Option<u32> {
self.wallet_rpc
.lock()
.ok()
.and_then(|guard| guard.as_ref().map(std::process::Child::id))
}
/// Is a tracked child still alive? Polls the process table; an exited child
/// is reaped here so a later `stop` is a no-op.
///