Skip to content

Commit f755b4c

Browse files
committed
f - builds_invoice_request_from_offer_with_expiration test
1 parent 81b55ed commit f755b4c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ mod tests {
463463
use bitcoin::secp256k1::schnorr::Signature;
464464
use core::convert::{Infallible, TryFrom};
465465
use core::num::NonZeroU64;
466+
#[cfg(feature = "std")]
467+
use core::time::Duration;
466468
use crate::ln::features::InvoiceRequestFeatures;
467469
use crate::ln::msgs::DecodeError;
468470
use crate::offers::offer::{OfferBuilder, Quantity};
@@ -538,6 +540,34 @@ mod tests {
538540
}
539541
}
540542

543+
#[cfg(feature = "std")]
544+
#[test]
545+
fn builds_invoice_request_from_offer_with_expiration() {
546+
let future_expiry = Duration::from_secs(u64::max_value());
547+
let past_expiry = Duration::from_secs(0);
548+
549+
if let Err(e) = OfferBuilder::new("foo".into(), recipient_pubkey())
550+
.amount_msats(1000)
551+
.absolute_expiry(future_expiry)
552+
.build().unwrap()
553+
.request_invoice(vec![1; 32], payer_pubkey())
554+
.build()
555+
{
556+
panic!("error building invoice_request: {:?}", e);
557+
}
558+
559+
match OfferBuilder::new("foo".into(), recipient_pubkey())
560+
.amount_msats(1000)
561+
.absolute_expiry(past_expiry)
562+
.build().unwrap()
563+
.request_invoice(vec![1; 32], payer_pubkey())
564+
.build()
565+
{
566+
Ok(_) => panic!("expected error"),
567+
Err(e) => assert_eq!(e, SemanticError::AlreadyExpired),
568+
}
569+
}
570+
541571
#[test]
542572
fn builds_invoice_request_with_chain() {
543573
let mainnet = ChainHash::using_genesis_block(Network::Bitcoin);

0 commit comments

Comments
 (0)