@@ -73,6 +73,7 @@ use crate::util::ser::Writeable;
7373const MAX_SHORT_LIVED_RELATIVE_EXPIRY : Duration = Duration :: from_secs ( 60 * 60 * 24 ) ;
7474
7575use crate :: prelude:: * ;
76+ use crate :: util:: test_utils:: TestCurrencyConversion ;
7677
7778macro_rules! expect_recent_payment {
7879 ( $node: expr, $payment_state: path, $payment_id: expr) => { {
@@ -517,12 +518,14 @@ fn check_dummy_hop_pattern_in_offer() {
517518 }
518519
519520 let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
521+ let conversion = TestCurrencyConversion ;
522+
520523 bob. node . pay_for_offer ( & compact_offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
521524
522525 let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
523526 let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
524527
525- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
528+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
526529 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
527530 assert ! ( check_dummy_hopped_path_length( & reply_path, alice, bob_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
528531
@@ -544,7 +547,7 @@ fn check_dummy_hop_pattern_in_offer() {
544547 let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
545548 let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
546549
547- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
550+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
548551 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
549552 assert ! ( check_dummy_hopped_path_length( & reply_path, alice, bob_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
550553}
@@ -706,6 +709,8 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
706709 }
707710
708711 let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
712+ let conversion = TestCurrencyConversion ;
713+
709714 david. node . pay_for_offer ( & offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
710715 expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
711716
@@ -729,7 +734,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
729734 human_readable_name : None ,
730735 } ,
731736 } ) ;
732- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
737+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
733738 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
734739 assert ! ( check_dummy_hopped_path_length( & reply_path, bob, charlie_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
735740
@@ -871,6 +876,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
871876 }
872877
873878 let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
879+ let conversion = TestCurrencyConversion ;
874880 bob. node . pay_for_offer ( & offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
875881 expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
876882
@@ -887,7 +893,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
887893 human_readable_name : None ,
888894 } ,
889895 } ) ;
890- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
896+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
891897 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
892898 assert ! ( check_dummy_hopped_path_length( & reply_path, alice, bob_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
893899
@@ -1253,6 +1259,7 @@ fn creates_and_pays_for_offer_with_retry() {
12531259 assert ! ( check_compact_path_introduction_node( & path, bob, alice_id) ) ;
12541260 }
12551261 let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
1262+ let conversion = TestCurrencyConversion ;
12561263 bob. node . pay_for_offer ( & offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
12571264 expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
12581265
@@ -1276,7 +1283,7 @@ fn creates_and_pays_for_offer_with_retry() {
12761283 human_readable_name : None ,
12771284 } ,
12781285 } ) ;
1279- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1286+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
12801287 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , bob_id) ;
12811288 assert ! ( check_dummy_hopped_path_length( & reply_path, alice, bob_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
12821289 let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
@@ -1576,6 +1583,8 @@ fn fails_authentication_when_handling_invoice_request() {
15761583
15771584 // Send the invoice request directly to Alice instead of using a blinded path.
15781585 let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
1586+ let conversion = TestCurrencyConversion ;
1587+
15791588 david. node . pay_for_offer ( & offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
15801589 expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
15811590
@@ -1590,7 +1599,7 @@ fn fails_authentication_when_handling_invoice_request() {
15901599 alice. onion_messenger . handle_onion_message ( david_id, & onion_message) ;
15911600
15921601 let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1593- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1602+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
15941603 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
15951604 assert ! ( check_dummy_hopped_path_length( & reply_path, david, charlie_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
15961605
@@ -1619,7 +1628,7 @@ fn fails_authentication_when_handling_invoice_request() {
16191628 alice. onion_messenger . handle_onion_message ( bob_id, & onion_message) ;
16201629
16211630 let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1622- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1631+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
16231632 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
16241633 assert ! ( check_dummy_hopped_path_length( & reply_path, david, charlie_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
16251634
@@ -1693,6 +1702,8 @@ fn fails_authentication_when_handling_invoice_for_offer() {
16931702 } ;
16941703
16951704 let payment_id = PaymentId ( [ 2 ; 32 ] ) ;
1705+ let conversion = TestCurrencyConversion ;
1706+
16961707 david. node . pay_for_offer ( & offer, None , payment_id, Default :: default ( ) ) . unwrap ( ) ;
16971708 expect_recent_payment ! ( david, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
16981709
@@ -1719,7 +1730,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
17191730 alice. onion_messenger . handle_onion_message ( bob_id, & onion_message) ;
17201731
17211732 let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
1722- assert_eq ! ( invoice_request. amount_msats( ) , Some ( 10_000_000 ) ) ;
1733+ assert_eq ! ( invoice_request. amount_msats( & conversion ) , Ok ( 10_000_000 ) ) ;
17231734 assert_ne ! ( invoice_request. payer_signing_pubkey( ) , david_id) ;
17241735 assert ! ( check_dummy_hopped_path_length( & reply_path, david, charlie_id, DUMMY_HOPS_PATH_LENGTH ) ) ;
17251736
@@ -1973,6 +1984,7 @@ fn fails_creating_invoice_request_for_unsupported_chain() {
19731984 . create_offer_builder ( ) . unwrap ( )
19741985 . clear_chains ( )
19751986 . chain ( Network :: Signet )
1987+ . amount_msats ( 1_000 ) . unwrap ( )
19761988 . build ( ) ;
19771989
19781990 match bob. node . pay_for_offer ( & offer, None , PaymentId ( [ 1 ; 32 ] ) , Default :: default ( ) ) {
0 commit comments