projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bench build warning
[rust-lightning]
/
lightning
/
src
/
offers
/
offer.rs
diff --git
a/lightning/src/offers/offer.rs
b/lightning/src/offers/offer.rs
index 9772ee41758ac6fa9b66dbe10958b0b54ad9fc80..802813fd180f70d9f6006cdc126a69f5c5f8f6e3 100644
(file)
--- a/
lightning/src/offers/offer.rs
+++ b/
lightning/src/offers/offer.rs
@@
-339,6
+339,11
@@
impl<'a, M: MetadataStrategy, T: secp256k1::Signing> OfferBuilder<'a, M, T> {
self
}
self
}
+ pub(crate) fn clear_paths(mut self) -> Self {
+ self.offer.paths = None;
+ self
+ }
+
pub(super) fn build_unchecked(self) -> Offer {
self.build_without_checks()
}
pub(super) fn build_unchecked(self) -> Offer {
self.build_without_checks()
}
@@
-468,6
+473,11
@@
impl Offer {
self.contents.is_expired()
}
self.contents.is_expired()
}
+ /// Whether the offer has expired given the duration since the Unix epoch.
+ pub fn is_expired_no_std(&self, duration_since_epoch: Duration) -> bool {
+ self.contents.is_expired_no_std(duration_since_epoch)
+ }
+
/// Returns whether the given quantity is valid for the offer.
pub fn is_valid_quantity(&self, quantity: u64) -> bool {
self.contents.is_valid_quantity(quantity)
/// Returns whether the given quantity is valid for the offer.
pub fn is_valid_quantity(&self, quantity: u64) -> bool {
self.contents.is_valid_quantity(quantity)
@@
-1192,6
+1202,7
@@
mod tests {
fn builds_offer_with_absolute_expiry() {
let future_expiry = Duration::from_secs(u64::max_value());
let past_expiry = Duration::from_secs(0);
fn builds_offer_with_absolute_expiry() {
let future_expiry = Duration::from_secs(u64::max_value());
let past_expiry = Duration::from_secs(0);
+ let now = future_expiry - Duration::from_secs(1_000);
let offer = OfferBuilder::new("foo".into(), pubkey(42))
.absolute_expiry(future_expiry)
let offer = OfferBuilder::new("foo".into(), pubkey(42))
.absolute_expiry(future_expiry)
@@
-1199,6
+1210,7
@@
mod tests {
.unwrap();
#[cfg(feature = "std")]
assert!(!offer.is_expired());
.unwrap();
#[cfg(feature = "std")]
assert!(!offer.is_expired());
+ assert!(!offer.is_expired_no_std(now));
assert_eq!(offer.absolute_expiry(), Some(future_expiry));
assert_eq!(offer.as_tlv_stream().absolute_expiry, Some(future_expiry.as_secs()));
assert_eq!(offer.absolute_expiry(), Some(future_expiry));
assert_eq!(offer.as_tlv_stream().absolute_expiry, Some(future_expiry.as_secs()));
@@
-1209,6
+1221,7
@@
mod tests {
.unwrap();
#[cfg(feature = "std")]
assert!(offer.is_expired());
.unwrap();
#[cfg(feature = "std")]
assert!(offer.is_expired());
+ assert!(offer.is_expired_no_std(now));
assert_eq!(offer.absolute_expiry(), Some(past_expiry));
assert_eq!(offer.as_tlv_stream().absolute_expiry, Some(past_expiry.as_secs()));
}
assert_eq!(offer.absolute_expiry(), Some(past_expiry));
assert_eq!(offer.as_tlv_stream().absolute_expiry, Some(past_expiry.as_secs()));
}