File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -468,6 +468,11 @@ impl Offer {
468
468
self . contents . is_expired ( )
469
469
}
470
470
471
+ /// Whether the offer has expired given the duration since the Unix epoch.
472
+ pub fn is_expired_no_std ( & self , duration_since_epoch : Duration ) -> bool {
473
+ self . contents . is_expired_no_std ( duration_since_epoch)
474
+ }
475
+
471
476
/// Returns whether the given quantity is valid for the offer.
472
477
pub fn is_valid_quantity ( & self , quantity : u64 ) -> bool {
473
478
self . contents . is_valid_quantity ( quantity)
@@ -1199,6 +1204,9 @@ mod tests {
1199
1204
. unwrap ( ) ;
1200
1205
#[ cfg( feature = "std" ) ]
1201
1206
assert ! ( !offer. is_expired( ) ) ;
1207
+ let now = std:: time:: SystemTime :: UNIX_EPOCH
1208
+ . elapsed ( ) . unwrap ( ) ;
1209
+ assert ! ( !offer. is_expired_no_std( now) ) ;
1202
1210
assert_eq ! ( offer. absolute_expiry( ) , Some ( future_expiry) ) ;
1203
1211
assert_eq ! ( offer. as_tlv_stream( ) . absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
1204
1212
Original file line number Diff line number Diff line change @@ -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 > {
@@ -1001,6 +1006,9 @@ mod tests {
1001
1006
let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
1002
1007
#[ cfg( feature = "std" ) ]
1003
1008
assert ! ( !refund. is_expired( ) ) ;
1009
+ let now = std:: time:: SystemTime :: UNIX_EPOCH
1010
+ . elapsed ( ) . unwrap ( ) ;
1011
+ assert ! ( !refund. is_expired_no_std( now) ) ;
1004
1012
assert_eq ! ( refund. absolute_expiry( ) , Some ( future_expiry) ) ;
1005
1013
assert_eq ! ( tlv_stream. absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
1006
1014
You can’t perform that action at this time.
0 commit comments