Skip to content

Commit b153f50

Browse files
committed
f - update Offer tests for PrintableString
1 parent 3647567 commit b153f50

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lightning/src/offers/offer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ mod tests {
458458
use ln::msgs::MAX_VALUE_MSAT;
459459
use onion_message::{BlindedHop, BlindedPath};
460460
use util::ser::Writeable;
461+
use util::string::PrintableString;
461462

462463
fn pubkey(byte: u8) -> PublicKey {
463464
let secp_ctx = Secp256k1::new();
@@ -479,7 +480,7 @@ mod tests {
479480
assert_eq!(offer.chains(), vec![ChainHash::using_genesis_block(Network::Bitcoin)]);
480481
assert_eq!(offer.metadata(), None);
481482
assert_eq!(offer.amount(), None);
482-
assert_eq!(offer.description(), "foo");
483+
assert_eq!(offer.description(), PrintableString("foo"));
483484
assert_eq!(offer.features(), &OfferFeatures::empty());
484485
assert_eq!(offer.absolute_expiry(), None);
485486
#[cfg(feature = "std")]
@@ -678,15 +679,15 @@ mod tests {
678679
.issuer("bar".into())
679680
.build()
680681
.unwrap();
681-
assert_eq!(offer.issuer(), Some("bar"));
682+
assert_eq!(offer.issuer(), Some(PrintableString("bar")));
682683
assert_eq!(offer.as_tlv_stream().issuer, Some(&String::from("bar")));
683684

684685
let offer = OfferBuilder::new("foo".into(), pubkey(42))
685686
.issuer("bar".into())
686687
.issuer("baz".into())
687688
.build()
688689
.unwrap();
689-
assert_eq!(offer.issuer(), Some("baz"));
690+
assert_eq!(offer.issuer(), Some(PrintableString("baz")));
690691
assert_eq!(offer.as_tlv_stream().issuer, Some(&String::from("baz")));
691692
}
692693

lightning/src/util/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use core::fmt;
1313

1414
/// A string that displays only printable characters, replacing control characters with
1515
/// [`core::char::REPLACEMENT_CHARACTER`].
16+
#[derive(Debug, PartialEq)]
1617
pub struct PrintableString<'a>(pub &'a str);
1718

1819
impl<'a> fmt::Display for PrintableString<'a> {

0 commit comments

Comments
 (0)