From: Matt Corallo Date: Fri, 16 Feb 2024 18:33:53 +0000 (+0000) Subject: Drop the `fails_paying_for_bolt12_invoice` test X-Git-Tag: v0.0.123-beta~63^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f3067b84c676efd5d9b3122c884c4c764b919430;p=rust-lightning Drop the `fails_paying_for_bolt12_invoice` test `fails_paying_for_bolt12_invoice` tests that we fail to send a payment if the router returns `Ok` but includes a bogus route (one with 0-length paths). While this marginally increases our test coverage, in the next commit we'll be testing that all routes round-trip serialization, which fails here as bogus routes are not supported in deserialization. Because this isn't particularly critical test coverage, we simply opt to drop the test entirely here. --- diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index c260bac85..b05d6f3f7 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -2283,65 +2283,6 @@ mod tests { assert!(pending_events.lock().unwrap().is_empty()); } - #[test] - fn fails_paying_for_bolt12_invoice() { - let logger = test_utils::TestLogger::new(); - let network_graph = Arc::new(NetworkGraph::new(Network::Testnet, &logger)); - let scorer = RwLock::new(test_utils::TestScorer::new()); - let router = test_utils::TestRouter::new(network_graph, &logger, &scorer); - let keys_manager = test_utils::TestKeysInterface::new(&[0; 32], Network::Testnet); - - let pending_events = Mutex::new(VecDeque::new()); - let outbound_payments = OutboundPayments::new(); - let payment_id = PaymentId([0; 32]); - let expiration = StaleExpiration::AbsoluteTimeout(Duration::from_secs(100)); - - let invoice = OfferBuilder::new("foo".into(), recipient_pubkey()) - .amount_msats(1000) - .build().unwrap() - .request_invoice(vec![1; 32], payer_pubkey()).unwrap() - .build().unwrap() - .sign(payer_sign).unwrap() - .respond_with_no_std(payment_paths(), payment_hash(), now()).unwrap() - .build().unwrap() - .sign(recipient_sign).unwrap(); - - assert!( - outbound_payments.add_new_awaiting_invoice( - payment_id, expiration, Retry::Attempts(0), - Some(invoice.amount_msats() / 100 + 50_000) - ).is_ok() - ); - assert!(outbound_payments.has_pending_payments()); - - let route_params = RouteParameters::from_payment_params_and_value( - PaymentParameters::from_bolt12_invoice(&invoice), - invoice.amount_msats(), - ); - router.expect_find_route( - route_params.clone(), Ok(Route { paths: vec![], route_params: Some(route_params) }) - ); - - assert_eq!( - outbound_payments.send_payment_for_bolt12_invoice( - &invoice, payment_id, &&router, vec![], || InFlightHtlcs::new(), &&keys_manager, - &&keys_manager, 0, &&logger, &pending_events, |_| panic!() - ), - Ok(()), - ); - assert!(!outbound_payments.has_pending_payments()); - - let payment_hash = invoice.payment_hash(); - let reason = Some(PaymentFailureReason::UnexpectedError); - - assert!(!pending_events.lock().unwrap().is_empty()); - assert_eq!( - pending_events.lock().unwrap().pop_front(), - Some((Event::PaymentFailed { payment_id, payment_hash, reason }, None)), - ); - assert!(pending_events.lock().unwrap().is_empty()); - } - #[test] fn sends_payment_for_bolt12_invoice() { let logger = test_utils::TestLogger::new();