wallet: land the file-name picker fix and the wallet manager on main (from t_67879b98) #153

Merged
sirius merged 8 commits from onionwire/t_67879b98-wallet-actually-open-the-wallet-file-and into main 2026-09-23 02:33:40 +00:00
2 changed files with 16 additions and 5 deletions
Showing only changes of commit 8d80a4fd55 - Show all commits

tests: write the fake child's argv log with one mv, not append-per-line
Some checks failed
android-ci / android (pull_request) Successful in 12m25s
ci / test (pull_request) Failing after 4m11s
ci / sdk (pull_request) Successful in 1m20s
ci / fuzz (pull_request) Successful in 5m28s

The wallet-child tests learn a spawned stand-in's port by polling its argv
log, and `fake_bin`/`fake_child_bin` truncated the log and then appended
one line per argument -- so a poller could read a prefix. A truncated port
is a *valid* u16 ("427" out of "42765"), so `wait_for_child_rpc_port`
happily returned a port nothing was listening on and the restart's
`open_wallet` died with `Connection refused` after its 10s budget; the
same prefix read is what `loopback_and_clearnet_remotes_carry_no_proxy...`
printed with its `--daemon-address` value missing.

Both tests failed on the first CI run of this branch (ci / test) and are
green in isolation, which is the signature of this race rather than of a
code defect. The argv now lands in the log with a single `mv`, so a reader
sees either no log or the complete one.

Measured with a tight read loop (argv-race-probe.sh): the append version
was caught mid-write 1/300 reads, the mv version 0/300.
agent 2026-09-22 14:33:32 -04:00
No known key found for this signature in database

View file

@ -3074,12 +3074,16 @@ pub(crate) mod tests {
/// A stand-in for `monero-wallet-rpc`: it records its argv, then does what
/// the test needs. The wallet child spawns a real process, so this is the
/// only honest way to drive the start path offline.
///
/// The argv is `mv`d into place in one step rather than truncated and
/// appended: a poller must never read half of it. It did — the port was
/// parsed while it was still being written, so `42765` read as `427`, and
/// the mock was bound on a port nothing dialled.
fn fake_child_bin(dir: &Path, name: &str, log: &Path, body: &str) -> PathBuf {
std::fs::create_dir_all(dir).expect("fake bin dir");
let path = dir.join(name);
let script = format!(
"#!/bin/sh\n: > '{}'\nprintf '%s\\n' \"$0\" >> '{}'\nfor a in \"$@\"; do printf '%s\\n' \"$a\" >> '{}'; done\n{body}\n",
log.display(),
"#!/bin/sh\ntmp='{}'.$$\n: > \"$tmp\"\nprintf '%s\\n' \"$0\" >> \"$tmp\"\nfor a in \"$@\"; do printf '%s\\n' \"$a\" >> \"$tmp\"; done\nmv -f \"$tmp\" '{}'\n{body}\n",
log.display(),
log.display()
);

View file

@ -1233,17 +1233,24 @@ mod tests {
}
/// A stand-in for monerod / monero-wallet-rpc: records its argv, then parks.
///
/// The argv lands in `<log>` with one `mv`, not a truncate-then-append: a
/// reader must never see half an argv. It did — the poll below could catch
/// `--rpc-bind-port` while the port was still being written and parse
/// `427` out of `42765`, a valid-but-wrong port, and the test then bound a
/// mock nobody dialled.
fn fake_bin(dir: &Path, name: &str, log: &Path) -> PathBuf {
let path = dir.join(name);
let mut f = fs::File::create(&path).unwrap();
writeln!(f, "#!/bin/sh").unwrap();
writeln!(f, ": > '{}'", log.display()).unwrap();
writeln!(f, "tmp='{}'.$$", log.display()).unwrap();
writeln!(f, ": > \"$tmp\"").unwrap();
writeln!(
f,
"for a in \"$@\"; do printf '%s\\n' \"$a\" >> '{}'; done",
log.display()
"for a in \"$@\"; do printf '%s\\n' \"$a\" >> \"$tmp\"; done"
)
.unwrap();
writeln!(f, "mv -f \"$tmp\" '{}'", log.display()).unwrap();
writeln!(f, "sleep 30").unwrap();
drop(f);
let mut perms = fs::metadata(&path).unwrap().permissions();