//! M3: two live Arti nodes, encrypted send, plaintext only in sqlite. use std::time::{Duration, Instant}; use onionwire::node::{self, Node}; const HELLO: &[u8] = b"hello wire"; #[tokio::test(flavor = "multi_thread")] #[ignore = "needs live Tor network"] async fn alice_sends_hello_wire_bob_sqlite_has_plaintext() { let _ = tracing_subscriber::fmt() .with_env_filter( tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()), ) .with_test_writer() .try_init(); let root = tempfile::tempdir().expect("tempdir"); let alice_home = root.path().join("alice"); let bob_home = root.path().join("bob"); eprintln!("starting alice + bob nodes…"); let (alice, bob) = tokio::join!( Node::start(alice_home.clone()), Node::start(bob_home.clone()) ); let alice = alice.expect("alice node"); let bob = bob.expect("bob node"); eprintln!("alice onion={}", alice.onion()); eprintln!("bob onion={}", bob.onion()); assert_ne!(alice.onion(), bob.onion()); let a_qr = alice.qr_payload().expect("alice qr"); let b_qr = bob.qr_payload().expect("bob qr"); alice.add_friend_from_qr(&b_qr).expect("alice adds bob"); bob.add_friend_from_qr(&a_qr).expect("bob adds alice"); eprintln!("alice → bob hello wire"); alice .send(&bob.identity_pk(), HELLO) .await .expect("alice send"); let deadline = Instant::now() + Duration::from_secs(30); loop { let msgs = bob .list_messages(&alice.identity_pk()) .expect("bob messages"); if msgs.iter().any(|m| m.dir == "in" && m.plaintext == HELLO) { break; } if Instant::now() >= deadline { panic!("bob sqlite missing incoming hello wire; got {msgs:?}"); } tokio::time::sleep(Duration::from_millis(200)).await; } assert!( !node::dir_contains_bytes(&alice.arti_dir(), HELLO), "plaintext leaked into alice arti dir" ); assert!( !node::dir_contains_bytes(&bob.arti_dir(), HELLO), "plaintext leaked into bob arti dir" ); assert!( !node::dir_contains_bytes(&alice.cache_dir(), HELLO), "plaintext leaked into alice cache dir" ); assert!( !node::dir_contains_bytes(&bob.cache_dir(), HELLO), "plaintext leaked into bob cache dir" ); }