@@ -463,6 +463,8 @@ mod tests {
463
463
use bitcoin:: secp256k1:: schnorr:: Signature ;
464
464
use core:: convert:: { Infallible , TryFrom } ;
465
465
use core:: num:: NonZeroU64 ;
466
+ #[ cfg( feature = "std" ) ]
467
+ use core:: time:: Duration ;
466
468
use crate :: ln:: features:: InvoiceRequestFeatures ;
467
469
use crate :: ln:: msgs:: DecodeError ;
468
470
use crate :: offers:: offer:: { OfferBuilder , Quantity } ;
@@ -538,6 +540,34 @@ mod tests {
538
540
}
539
541
}
540
542
543
+ #[ cfg( feature = "std" ) ]
544
+ #[ test]
545
+ fn builds_invoice_request_from_offer_with_expiration ( ) {
546
+ let future_expiry = Duration :: from_secs ( u64:: max_value ( ) ) ;
547
+ let past_expiry = Duration :: from_secs ( 0 ) ;
548
+
549
+ if let Err ( e) = OfferBuilder :: new ( "foo" . into ( ) , recipient_pubkey ( ) )
550
+ . amount_msats ( 1000 )
551
+ . absolute_expiry ( future_expiry)
552
+ . build ( ) . unwrap ( )
553
+ . request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) )
554
+ . build ( )
555
+ {
556
+ panic ! ( "error building invoice_request: {:?}" , e) ;
557
+ }
558
+
559
+ match OfferBuilder :: new ( "foo" . into ( ) , recipient_pubkey ( ) )
560
+ . amount_msats ( 1000 )
561
+ . absolute_expiry ( past_expiry)
562
+ . build ( ) . unwrap ( )
563
+ . request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) )
564
+ . build ( )
565
+ {
566
+ Ok ( _) => panic ! ( "expected error" ) ,
567
+ Err ( e) => assert_eq ! ( e, SemanticError :: AlreadyExpired ) ,
568
+ }
569
+ }
570
+
541
571
#[ test]
542
572
fn builds_invoice_request_with_chain ( ) {
543
573
let mainnet = ChainHash :: using_genesis_block ( Network :: Bitcoin ) ;
0 commit comments