@@ -517,25 +517,6 @@ mod tests {
517
517
. unwrap ( )
518
518
}
519
519
520
- fn will_expire_in_2_secs_invoice ( payment_preimage : PaymentPreimage ) -> Invoice {
521
- let payment_hash = Sha256 :: hash ( & payment_preimage. 0 ) ;
522
- let private_key = SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ;
523
- let timestamp = SystemTime :: now ( )
524
- . checked_sub ( Duration :: from_secs ( DEFAULT_EXPIRY_TIME - 2 ) )
525
- . unwrap ( ) ;
526
- InvoiceBuilder :: new ( Currency :: Bitcoin )
527
- . description ( "test" . into ( ) )
528
- . payment_hash ( payment_hash)
529
- . payment_secret ( PaymentSecret ( [ 0 ; 32 ] ) )
530
- . timestamp ( timestamp)
531
- . min_final_cltv_expiry ( 144 )
532
- . amount_milli_satoshis ( 128 )
533
- . build_signed ( |hash| {
534
- Secp256k1 :: new ( ) . sign_recoverable ( hash, & private_key)
535
- } )
536
- . unwrap ( )
537
- }
538
-
539
520
#[ test]
540
521
fn pays_invoice_on_first_attempt ( ) {
541
522
let event_handled = core:: cell:: RefCell :: new ( false ) ;
@@ -769,11 +750,15 @@ mod tests {
769
750
InvoicePayer :: new ( & payer, router, & scorer, & logger, event_handler, RetryAttempts ( 2 ) ) ;
770
751
771
752
let payment_preimage = PaymentPreimage ( [ 1 ; 32 ] ) ;
772
- let invoice = will_expire_in_2_secs_invoice ( payment_preimage) ;
753
+ let invoice = invoice ( payment_preimage) ;
773
754
let payment_id = Some ( invoice_payer. pay_invoice ( & invoice) . unwrap ( ) ) ;
774
755
std:: thread:: sleep ( Duration :: from_secs ( 4 ) ) ;
775
756
assert_eq ! ( * payer. attempts. borrow( ) , 1 ) ;
776
757
758
+ let mut retry_data = TestRouter :: retry_for_invoice ( & invoice) ;
759
+ retry_data. payee . expiry_time = Some ( SystemTime :: now ( )
760
+ . checked_sub ( Duration :: from_secs ( 2 ) ) . unwrap ( )
761
+ . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( ) . as_secs ( ) ) ;
777
762
let event = Event :: PaymentPathFailed {
778
763
payment_id,
779
764
payment_hash : PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ,
@@ -782,7 +767,7 @@ mod tests {
782
767
all_paths_failed : false ,
783
768
path : vec ! [ ] ,
784
769
short_channel_id : None ,
785
- retry : Some ( TestRouter :: retry_for_invoice ( & invoice ) ) ,
770
+ retry : Some ( retry_data ) ,
786
771
} ;
787
772
invoice_payer. handle_event ( & event) ;
788
773
assert_eq ! ( * event_handled. borrow( ) , true ) ;
0 commit comments