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 {
468468 self . contents . is_expired ( )
469469 }
470470
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+
471476 /// Returns whether the given quantity is valid for the offer.
472477 pub fn is_valid_quantity ( & self , quantity : u64 ) -> bool {
473478 self . contents . is_valid_quantity ( quantity)
@@ -1199,6 +1204,9 @@ mod tests {
11991204 . unwrap ( ) ;
12001205 #[ cfg( feature = "std" ) ]
12011206 assert ! ( !offer. is_expired( ) ) ;
1207+ let now = std:: time:: SystemTime :: UNIX_EPOCH
1208+ . elapsed ( ) . unwrap ( ) ;
1209+ assert ! ( !offer. is_expired_no_std( now) ) ;
12021210 assert_eq ! ( offer. absolute_expiry( ) , Some ( future_expiry) ) ;
12031211 assert_eq ! ( offer. as_tlv_stream( ) . absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
12041212
Original file line number Diff line number Diff line change @@ -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 > {
@@ -1001,6 +1006,9 @@ mod tests {
10011006 let ( _, tlv_stream, _) = refund. as_tlv_stream ( ) ;
10021007 #[ cfg( feature = "std" ) ]
10031008 assert ! ( !refund. is_expired( ) ) ;
1009+ let now = std:: time:: SystemTime :: UNIX_EPOCH
1010+ . elapsed ( ) . unwrap ( ) ;
1011+ assert ! ( !refund. is_expired_no_std( now) ) ;
10041012 assert_eq ! ( refund. absolute_expiry( ) , Some ( future_expiry) ) ;
10051013 assert_eq ! ( tlv_stream. absolute_expiry, Some ( future_expiry. as_secs( ) ) ) ;
10061014
You can’t perform that action at this time.
0 commit comments