onionwire/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
apk-dev 38fde75d40
feat(core,sdk): explicit Tor lifecycle — stop, flush, observable state
A node had no way to stop. `Wire` was a bare handle over a `Node`: dropping the
Kotlin reference left Arti's client, the hosted v3 onion service, the outbox
retry worker and the sqlite connection alive, and there was no way to ask where
the onion service was. On Android the process is killed without warning by Doze
and the background-process killer, so "drop everything when the process dies" is
not a lifecycle.

Core (`src/node.rs`, `src/hs.rs`):

* `Node::shutdown()` — bounded outbox drain (10s), stop the onion service (the
  rendezvous task is aborted and the RunningOnionService dropped), abort the
  retry worker, checkpoint the sqlite WAL. Idempotent at this level: the flag is
  swapped first, so a racing second call is a no-op.
* `Node::flush() -> FlushOutcome { attempted, delivered, remaining }` — one
  delivery attempt for every queued outbox row, ignoring backoff, then a WAL
  checkpoint. Bounded by 30s because a dead peer's onion holds a dial for ~20s
  and the caller is a UI thread. A timeout leaves rows in `sending`;
  `Outbox::reset_stale` requeues them on the next unlock, same as a process that
  died mid-attempt.
* `Node::tor_state() -> TorState` (`Bootstrapping` / `Published` /
  `DegradedReachable` / `Stopped`) and `hs::tor_state_of(state, stopped,
  reachable)`, which mirrors `hs_is_ready` exactly instead of re-deriving
  readiness.
* Every network entry point (`send`, `send_once`, `connect_onion`, `rotate`,
  `flush`) fails with a typed error after the node stops, rather than dialing a
  dead client.
* `checkpoint_wal` reaches the database through a short-lived second connection:
  `Store` owns the write connection and does not lend it out, and a checkpoint is
  a property of the database, not of one connection. Best effort — WAL replay on
  open recovers anything committed.

The `WorkerHandle` moved into a `Mutex<Option<...>>` so the teardown can *abort*
the retry worker instead of only dropping it when the whole `Node` dies.

SDK (`crates/onionwire-sdk/src/lib.rs`):

* `Wire.shutdown()`, `Wire.flush(): FlushOutcome`, `Wire.torState(): TorState`.
  `Wire` now holds `Mutex<Option<Arc<Node>>>`, so teardown drops the last
  reference to the Tor client and the store instead of keeping them alive behind
  a JNI handle.
* `WireError::Stopped` — a second flat variant, so "you must unlock again" is a
  typed `WireException.Stopped` in Kotlin, not a string match on `Failed`.
* No `unwrap()` on a poisoned mutex anywhere: a poisoned handle reports
  `Stopped`, which is the correct recovery (unlock again).
* Fixes the crate not compiling on this base at all: `Node::send` has returned
  `Result<OutboxStatus, String>` since the outbox landed, and the SDK still
  mapped it to `Result<(), String>` (E0308). CI's path allowlist excludes
  `crates/**` from the Rust job, which is why it stayed green.

The live Tor test found a real bug in the first version of `tor_state`: Arti's
combined status is still `Bootstrapping` after a *successful* probe of our own
onion (that mismatch is what the 360s publish wait exists for), and a freshly
launched service reports `Shutdown` before its publish reactor starts — so a
node that was live and reachable reported `Bootstrapping`, and briefly
`Stopped`, right after unlock. `Node` now tracks an `onion_reachable` flag set
when the publish bar is crossed and cleared when `rotate` hard-cuts the service,
and `Shutdown`/`Broken` on a live node read `Bootstrapping` (transient) rather
than terminal.
2026-09-12 15:10:29 -04:00
..
app_sig.rs fix(protocol): domain-separate loc/prf/inv/rcp signatures 2026-09-11 23:42:41 -04:00
backup.rs feat(core): zeroize in-memory secret material (Noise/Ed25519/X25519/store key) 2026-09-12 13:55:07 -04:00
dispatch.rs feat: drop unknown typed frames instead of storing as chat 2026-09-10 14:18:06 -04:00
file.rs Merge branch 'main' into wt/t_fc02d8b6 2026-09-12 04:11:00 +00:00
hs.rs feat(core,sdk): explicit Tor lifecycle — stop, flush, observable state 2026-09-12 15:10:29 -04:00
outbox.rs feat(outbox): local retry queue for chat sends 2026-09-12 14:39:14 -04:00
pay.rs fix(pay): checksum Monero addresses (base58 + keccak) 2026-09-10 20:01:45 -04:00
profile.rs fix(pay): checksum Monero addresses (base58 + keccak) 2026-09-10 20:01:45 -04:00
protocol.rs Add Noise IK encrypted stream over Arti. 2026-09-10 02:07:40 -04:00
qr.rs [verified] fix(qr): bind invite sig fields; cap decode 2026-09-10 19:52:44 -04:00
ratelimit.rs feat: incoming rate limit, identity backup, v0.2.0 2026-09-10 14:50:01 -04:00
rotate.rs feat(store): encrypt chat bodies at rest; Ctrl-Q CLEAR/QUIT 2026-09-10 17:19:50 -04:00
rotate_hs.rs feat(store): encrypt chat bodies at rest; Ctrl-Q CLEAR/QUIT 2026-09-10 17:19:50 -04:00
sanitize.rs [verified] sanitize peer chat/control/bidi before store and TUI render 2026-09-11 23:42:48 -04:00
send.rs fix(tui): do not freeze the UI on chat send 2026-09-11 22:33:55 -04:00
store.rs feat(core): zeroize in-memory secret material (Noise/Ed25519/X25519/store key) 2026-09-12 13:55:07 -04:00
tor_hs.rs [verified] fix(hs): redact onion in publish logs; cache 0700 2026-09-10 20:30:18 -04:00
tor_lifecycle.rs feat(core,sdk): explicit Tor lifecycle — stop, flush, observable state 2026-09-12 15:10:29 -04:00
tui_chrome.rs [verified] feat(tui): fail-closed /file transfer (1 MiB) 2026-09-10 23:32:06 -04:00
tui_frames.rs test(tui): keep send-failed visible in crowded status_footer 2026-09-12 00:22:04 -04:00
tui_spec.rs feat(tui): ASCII chrome, invite wrap, alert truncate, remaining copy 2026-09-12 00:54:16 -04:00
two_node.rs feat(store): encrypt chat bodies at rest; Ctrl-Q CLEAR/QUIT 2026-09-10 17:19:50 -04:00
wallet.rs Merge F5 wallet digest RPC onto audit bundle 2026-09-10 20:36:10 -04:00
wipe.rs fix(store): drop payments on /wipe; document non-forensic 2026-09-10 20:22:31 -04:00
zeroize.rs feat(core): zeroize in-memory secret material (Noise/Ed25519/X25519/store key) 2026-09-12 13:55:07 -04:00