diff --git a/src/node.rs b/src/node.rs index 3defa3a..21bd1ef 100644 --- a/src/node.rs +++ b/src/node.rs @@ -671,16 +671,6 @@ impl Node { pay::receipt_chat_line(atomic, true).as_bytes(), ) .map_err(|e| e.to_string())?; - // The receipt line is the recipient's view of the frame that arrived; - // the payer's own chat shows the tip they just spent (unverified: the - // recipient has not confirmed it). - store - .append_message( - friend_pk, - "out", - pay::tip_chat_line(atomic, _memo, false).as_bytes(), - ) - .map_err(|e| e.to_string())?; Ok(()) } @@ -1509,16 +1499,6 @@ mod tests { /// onion service, so this is the only way to drive the shipped send and /// receive path offline. fn offline_node(home: &Path, deliverer: Arc) -> Node { - offline_node_with_wallet(home, deliverer, Wallet::disabled()) - } - - /// [`offline_node`] with a wallet child attached: the outbound tip path - /// cannot get past `Wallet::configured()` without one. - fn offline_node_with_wallet( - home: &Path, - deliverer: Arc, - wallet: Wallet, - ) -> Node { std::fs::create_dir_all(home).expect("create home"); let store = Store::open_at_with_passphrase(home, PASS).expect("open store"); let keys = Keys::from_self(&store.self_identity().expect("self identity")).expect("keys"); @@ -1535,7 +1515,7 @@ mod tests { hs: Mutex::new(None), onion: Mutex::new("test.onion".to_string()), keys: Mutex::new(keys), - wallet, + wallet: Wallet::disabled(), incoming_limit: Mutex::new(TokenBucket::default()), inbox: Mutex::new(file::Inbox::new(home.join("inbox"))), outbox, @@ -1724,104 +1704,5 @@ mod tests { "three lines, arrival order, no duplicates" ); } - - /// The peer takes the frame: one-shot payment sends are fail-closed, so the - /// tip path only reaches its chat rows when the deliverer answers `Ok`. - struct DialOk; - - impl crate::outbox::Deliverer for DialOk { - fn deliver<'a>( - &'a self, - _onion: &'a str, - _pinned_id: &'a [u8], - _prekey: &'a [u8], - _payload: &'a [u8], - ) -> crate::outbox::BoxFut<'a, Result<(), String>> { - Box::pin(async { Ok(()) }) - } - } - - /// Same documented mainnet standard as `tests/wallet.rs`. - fn xmr_addr() -> String { - "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge" - .to_string() - } - - /// A wallet child that clears the Digest challenge and answers one - /// `transfer` — the two-connection dance `tests/wallet.rs` mocks. - async fn mock_wallet() -> Wallet { - use tokio::io::{AsyncReadExt, AsyncWriteExt}; - - let listener = tokio::net::TcpListener::bind("127.0.0.1:0") - .await - .expect("bind mock wallet"); - let port = listener.local_addr().expect("mock wallet addr").port(); - tokio::spawn(async move { - for attempt in 0..2 { - let Ok((mut sock, _)) = listener.accept().await else { - return; - }; - let mut buf = vec![0u8; 8192]; - let _ = sock.read(&mut buf).await; - if attempt == 0 { - let _ = sock - .write_all( - b"HTTP/1.1 401 Unauthorized\r\nWWW-Authenticate: Digest realm=\"monero-rpc\", nonce=\"abcnonce\", qop=\"auth\", algorithm=MD5\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", - ) - .await; - continue; - } - let body = r#"{"jsonrpc":"2.0","id":"0","result":{"tx_hash":"abc123"}}"#; - let _ = sock - .write_all( - format!( - "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", - body.len() - ) - .as_bytes(), - ) - .await; - } - }); - Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url") - } - - /// The payer of a tip must see it in their own chat: `receipt_chat_line` is - /// the recipient's view of the frame that arrived, `tip_chat_line` is what - /// the sender just spent. - #[tokio::test] - async fn outbound_tip_appends_the_senders_own_tip_chat_line() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node_with_wallet( - &dir.path().join("bob"), - Arc::new(DialOk), - mock_wallet().await, - ); - let peer = Keys::generate(); - let addr = xmr_addr(); - { - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - let prf = crate::profile::sign(&peer.identity_sk, "peer", "", &addr, 1) - .expect("sign peer profile"); - assert!(store.apply_profile(&peer.identity_pk, &prf).unwrap()); - } - - node.tip(&peer.identity_pk, "500000000000", "lunch") - .await - .expect("tip"); - - assert_eq!( - chat_lines(&node, &peer), - vec![ - ("out".to_string(), "[receipt] 0.5 XMR".to_string()), - ( - "out".to_string(), - "[tip] 0.5 XMR — lunch (pending)".to_string() - ), - ], - "the sender's chat must show the tip they just paid" - ); - } }