+ #[test]
+ fn scores_successful_channels() {
+ let event_handled = core::cell::RefCell::new(false);
+ let event_handler = |_: &_| { *event_handled.borrow_mut() = true; };
+
+ let payment_preimage = PaymentPreimage([1; 32]);
+ let invoice = invoice(payment_preimage);
+ let payment_hash = Some(PaymentHash(invoice.payment_hash().clone().into_inner()));
+ let final_value_msat = invoice.amount_milli_satoshis().unwrap();
+ let route = TestRouter::route_for_value(final_value_msat);
+
+ // Expect that scorer is given short_channel_id upon handling the event.
+ let payer = TestPayer::new().expect_send(Amount::ForInvoice(final_value_msat));
+ let router = TestRouter {};
+ let scorer = RefCell::new(TestScorer::new()
+ .expect(PaymentPath::Success { path: route.paths[0].clone() })
+ .expect(PaymentPath::Success { path: route.paths[1].clone() })
+ );
+ let logger = TestLogger::new();
+ let invoice_payer =
+ InvoicePayer::new(&payer, router, &scorer, &logger, event_handler, RetryAttempts(2));
+
+ let payment_id = invoice_payer.pay_invoice(&invoice).unwrap();
+ let event = Event::PaymentPathSuccessful {
+ payment_id, payment_hash, path: route.paths[0].clone()
+ };
+ invoice_payer.handle_event(&event);
+ let event = Event::PaymentPathSuccessful {
+ payment_id, payment_hash, path: route.paths[1].clone()
+ };
+ invoice_payer.handle_event(&event);
+ }
+