File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -1032,6 +1032,42 @@ mod tests {
10321032 }
10331033 }
10341034
1035+ #[ cfg( feature = "std" ) ]
1036+ #[ test]
1037+ fn builds_invoice_from_offer_with_expiration ( ) {
1038+ let future_expiry = Duration :: from_secs ( u64:: max_value ( ) ) ;
1039+ let past_expiry = Duration :: from_secs ( 0 ) ;
1040+
1041+ if let Err ( e) = OfferBuilder :: new ( "foo" . into ( ) , recipient_pubkey ( ) )
1042+ . amount_msats ( 1000 )
1043+ . absolute_expiry ( future_expiry)
1044+ . build ( ) . unwrap ( )
1045+ . request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
1046+ . build ( ) . unwrap ( )
1047+ . sign ( payer_sign) . unwrap ( )
1048+ . respond_with ( payment_paths ( ) , payment_hash ( ) )
1049+ . unwrap ( )
1050+ . build ( )
1051+ {
1052+ panic ! ( "error building invoice: {:?}" , e) ;
1053+ }
1054+
1055+ match OfferBuilder :: new ( "foo" . into ( ) , recipient_pubkey ( ) )
1056+ . amount_msats ( 1000 )
1057+ . absolute_expiry ( past_expiry)
1058+ . build ( ) . unwrap ( )
1059+ . request_invoice ( vec ! [ 1 ; 32 ] , payer_pubkey ( ) ) . unwrap ( )
1060+ . build_unchecked ( )
1061+ . sign ( payer_sign) . unwrap ( )
1062+ . respond_with ( payment_paths ( ) , payment_hash ( ) )
1063+ . unwrap ( )
1064+ . build ( )
1065+ {
1066+ Ok ( _) => panic ! ( "expected error" ) ,
1067+ Err ( e) => assert_eq ! ( e, SemanticError :: AlreadyExpired ) ,
1068+ }
1069+ }
1070+
10351071 #[ cfg( feature = "std" ) ]
10361072 #[ test]
10371073 fn builds_invoice_from_refund_with_expiration ( ) {
You can’t perform that action at this time.
0 commit comments