Skip to content

Commit 12d9c1a

Browse files
committed
f - builds_invoice_request_from_offer_with_expiration test
1 parent 8d70eb7 commit 12d9c1a

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
@@ -467,6 +467,8 @@ mod tests {
467467
use bitcoin::secp256k1::schnorr::Signature;
468468
use core::convert::TryFrom;
469469
use core::num::NonZeroU64;
470+
#[cfg(feature = "std")]
471+
use core::time::Duration;
470472
use crate::ln::features::InvoiceRequestFeatures;
471473
use crate::ln::msgs::DecodeError;
472474
use crate::offers::offer::{OfferBuilder, Quantity};
@@ -542,6 +544,34 @@ mod tests {
542544
}
543545
}
544546

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

0 commit comments

Comments
 (0)