@@ -185,7 +185,7 @@ fn route_bolt12_payment<'a, 'b, 'c>(
185185
186186fn claim_bolt12_payment < ' a , ' b , ' c > (
187187 node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , expected_payment_context : PaymentContext , invoice : & Bolt12Invoice
188- ) {
188+ ) -> Option < crate :: events :: ContactInfo > {
189189 let recipient = & path[ path. len ( ) - 1 ] ;
190190 let payment_purpose = match get_event ! ( recipient, Event :: PaymentClaimable ) {
191191 Event :: PaymentClaimable { purpose, .. } => purpose,
@@ -204,11 +204,13 @@ fn claim_bolt12_payment<'a, 'b, 'c>(
204204 } ,
205205 _ => panic ! ( "Unexpected payment purpose: {:?}" , payment_purpose) ,
206206 }
207- if let Some ( inv) = claim_payment ( node, path, payment_preimage) {
208- assert_eq ! ( inv, PaidBolt12Invoice :: Bolt12Invoice ( invoice. to_owned( ) ) ) ;
207+ let ( inv, contact_info) = claim_payment ( node, path, payment_preimage) ;
208+ if let Some ( paid_inv) = inv {
209+ assert_eq ! ( paid_inv, PaidBolt12Invoice :: Bolt12Invoice ( invoice. to_owned( ) ) ) ;
209210 } else {
210211 panic ! ( "Expected PaidInvoice::Bolt12Invoice" ) ;
211212 } ;
213+ contact_info
212214}
213215
214216fn extract_offer_nonce < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> Nonce {
@@ -714,7 +716,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
714716 route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
715717 expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
716718
717- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice) ;
719+ let _ = claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice) ;
718720 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
719721}
720722
@@ -796,7 +798,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
796798 route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
797799 expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
798800
799- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice) ;
801+ let _ = claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice) ;
800802 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
801803}
802804
@@ -863,7 +865,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
863865 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
864866 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
865867
866- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
868+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
867869 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
868870}
869871
@@ -919,7 +921,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
919921 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
920922 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
921923
922- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
924+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
923925 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
924926}
925927
@@ -973,7 +975,7 @@ fn pays_for_offer_without_blinded_paths() {
973975 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
974976 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
975977
976- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
978+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
977979 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
978980}
979981
@@ -1016,7 +1018,7 @@ fn pays_for_refund_without_blinded_paths() {
10161018 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
10171019 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
10181020
1019- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
1021+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
10201022 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
10211023}
10221024
@@ -1253,7 +1255,7 @@ fn creates_and_pays_for_offer_with_retry() {
12531255 }
12541256 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
12551257 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
1256- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
1258+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
12571259 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
12581260}
12591261
@@ -1331,7 +1333,7 @@ fn pays_bolt12_invoice_asynchronously() {
13311333 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
13321334 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
13331335
1334- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
1336+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
13351337 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
13361338
13371339 assert_eq ! (
@@ -1411,7 +1413,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
14111413 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
14121414 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
14131415
1414- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
1416+ let _ = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
14151417 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
14161418}
14171419
@@ -2251,7 +2253,7 @@ fn fails_paying_invoice_more_than_once() {
22512253 assert ! ( david. node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
22522254
22532255 // Complete paying the first invoice
2254- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice1) ;
2256+ let _ = claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice1) ;
22552257 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
22562258}
22572259
@@ -2576,10 +2578,6 @@ fn pay_offer_and_add_contacts_info_blip42() {
25762578 // TODO: we should check also if the contact secret is the same that we inject by bob.
25772579
25782580 assert ! ( invoice_request. payer_offer( ) . is_some( ) ) ;
2579- // FIXME: this is wrong but make sure that we are following correctly the code path.
2580- let payer_offer_bytes = invoice_request. payer_offer ( ) . unwrap ( ) ;
2581- let payer_offer = Offer :: try_from ( payer_offer_bytes. to_vec ( ) ) . unwrap ( ) ;
2582- assert_eq ! ( payer_offer, offer) ;
25832581
25842582 let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
25852583 bob. onion_messenger . handle_onion_message ( alice_id, & onion_message) ;
@@ -2592,9 +2590,15 @@ fn pay_offer_and_add_contacts_info_blip42() {
25922590 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
25932591 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
25942592
2595- claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
2593+ let contact_info = claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice) ;
25962594 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
25972595
2596+ assert ! ( contact_info. is_some( ) ) ;
2597+ let contact_info = contact_info. unwrap ( ) ;
2598+
2599+ assert ! ( invoice_request. contact_secret( ) . is_some( ) ) ;
2600+ assert_eq ! ( invoice_request. contact_secret( ) . unwrap( ) , contact_info. contact_secrets. primary_secret( ) ) ;
2601+
25982602 // TODO: now should be possible that alice will be able to repay bob without that
25992603 // bob give any offer in exchange!! but there is a contact list somewhere that allow
26002604 // to run something like bob.pay_for_contact(alice_contact_name, amount);
0 commit comments