@@ -359,6 +359,11 @@ impl Refund {
359
359
self . contents . is_expired ( )
360
360
}
361
361
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
+
362
367
/// The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be
363
368
/// displayed to the user but with the caveat that it has not been verified in any way.
364
369
pub fn issuer ( & self ) -> Option < PrintableString > {
@@ -993,6 +998,7 @@ mod tests {
993
998
fn builds_refund_with_absolute_expiry ( ) {
994
999
let future_expiry = Duration :: from_secs ( u64:: max_value ( ) ) ;
995
1000
let past_expiry = Duration :: from_secs ( 0 ) ;
1001
+ let now = future_expiry - Duration :: from_secs ( 1_000 ) ;
996
1002
997
1003
let refund = RefundBuilder :: new ( "foo" . into ( ) , vec ! [ 1 ; 32 ] , payer_pubkey ( ) , 1000 ) . unwrap ( )
998
1004
. absolute_expiry ( future_expiry)
@@ -1001,6 +1007,7 @@ mod tests {
1001
1007
let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
1002
1008
#[ cfg( feature = "std" ) ]
1003
1009
assert ! ( !refund. is_expired( ) ) ;
1010
+ assert ! ( !refund. is_expired_no_std( now) ) ;
1004
1011
assert_eq ! ( refund. absolute_expiry( ) , Some ( future_expiry) ) ;
1005
1012
assert_eq ! ( tlv_stream. absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
1006
1013
@@ -1012,6 +1019,7 @@ mod tests {
1012
1019
let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
1013
1020
#[ cfg( feature = "std" ) ]
1014
1021
assert ! ( refund. is_expired( ) ) ;
1022
+ assert ! ( refund. is_expired_no_std( now) ) ;
1015
1023
assert_eq ! ( refund. absolute_expiry( ) , Some ( past_expiry) ) ;
1016
1024
assert_eq ! ( tlv_stream. absolute_expiry, Some ( past_expiry. as_secs( ) ) ) ;
1017
1025
}
0 commit comments