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