Skip to content

Commit

Permalink
Tweak offer_tests to bypass liquidity check
Browse files Browse the repository at this point in the history
Modify tests to bypass liquidity check by giving the offer
a denomination in fiat. In turn, making amount() and
build_uchecked() pub(crate)s.
  • Loading branch information
slanesuke committed Jul 24, 2024
1 parent 699e495 commit ea2fc2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lightning/src/ln/offers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use crate::offers::invoice_error::InvoiceError;
use crate::offers::invoice_request::{InvoiceRequest, InvoiceRequestFields};
use crate::offers::parse::Bolt12SemanticError;
use crate::onion_message::messenger::{Destination, PeeledOnion};
use crate::offers::offer::Amount;
use crate::onion_message::offers::OffersMessage;
use crate::onion_message::packet::ParsedOnionMessageContents;
use crate::routing::gossip::{NodeAlias, NodeId};
Expand Down Expand Up @@ -1607,9 +1608,9 @@ fn fails_creating_or_paying_for_offer_without_connected_peers() {
reconnect_nodes(args);

let offer = alice.node
.create_offer_builder(Some(absolute_expiry)).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
.create_offer_builder(None).unwrap()
.amount(Amount::Currency {iso4217_code: *b"USD", amount: 6_000})
.build_unchecked();

let payment_id = PaymentId([1; 32]);

Expand Down Expand Up @@ -1771,8 +1772,9 @@ fn fails_creating_invoice_request_without_blinded_reply_path() {

let offer = alice.node
.create_offer_builder(None).unwrap()
.amount_msats(10_000_000)
.build().unwrap();
.amount(Amount::Currency {iso4217_code: *b"USD", amount: 6_000})
.build_unchecked();


let payment_id = PaymentId([1; 32]);

Expand Down
4 changes: 2 additions & 2 deletions lightning/src/offers/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ macro_rules! offer_builder_methods { (
/// Sets the [`Offer::amount`].
///
/// Successive calls to this method will override the previous setting.
pub(super) fn amount($($self_mut)* $self: $self_type, amount: Amount) -> $return_type {
pub(crate) fn amount($($self_mut)* $self: $self_type, amount: Amount) -> $return_type {
$self.offer.amount = Some(amount);
$return_value
}
Expand Down Expand Up @@ -460,7 +460,7 @@ macro_rules! offer_builder_test_methods { (
}

#[cfg_attr(c_bindings, allow(dead_code))]
pub(super) fn build_unchecked($self: $self_type) -> Offer {
pub(crate) fn build_unchecked($self: $self_type) -> Offer {
$self.build_without_checks()
}
} }
Expand Down

0 comments on commit ea2fc2d

Please sign in to comment.