@@ -359,6 +359,11 @@ impl Refund {
359359 self . contents . is_expired ( )
360360 }
361361
362+ /// Whether the refund has expired given the duration since the Unix epoch.
363+ pub fn is_expired_no_std ( & self , duration_since_epoch : Duration ) -> bool {
364+ self . contents . is_expired_no_std ( duration_since_epoch)
365+ }
366+
362367 /// The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be
363368 /// displayed to the user but with the caveat that it has not been verified in any way.
364369 pub fn issuer ( & self ) -> Option < PrintableString > {
@@ -993,6 +998,7 @@ mod tests {
993998 fn builds_refund_with_absolute_expiry ( ) {
994999 let future_expiry = Duration :: from_secs ( u64:: max_value ( ) ) ;
9951000 let past_expiry = Duration :: from_secs ( 0 ) ;
1001+ let now = future_expiry - Duration :: from_secs ( 1_000 ) ;
9961002
9971003 let refund = RefundBuilder :: new ( "foo" . into ( ) , vec ! [ 1 ; 32 ] , payer_pubkey ( ) , 1000 ) . unwrap ( )
9981004 . absolute_expiry ( future_expiry)
@@ -1001,6 +1007,7 @@ mod tests {
10011007 let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
10021008 #[ cfg( feature = "std" ) ]
10031009 assert ! ( !refund. is_expired( ) ) ;
1010+ assert ! ( !refund. is_expired_no_std( now) ) ;
10041011 assert_eq ! ( refund. absolute_expiry( ) , Some ( future_expiry) ) ;
10051012 assert_eq ! ( tlv_stream. absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
10061013
@@ -1012,6 +1019,7 @@ mod tests {
10121019 let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
10131020 #[ cfg( feature = "std" ) ]
10141021 assert ! ( refund. is_expired( ) ) ;
1022+ assert ! ( refund. is_expired_no_std( now) ) ;
10151023 assert_eq ! ( refund. absolute_expiry( ) , Some ( past_expiry) ) ;
10161024 assert_eq ! ( tlv_stream. absolute_expiry, Some ( past_expiry. as_secs( ) ) ) ;
10171025 }
0 commit comments