Skip to content

Commit

Permalink
Merge pull request #442 from tnull/2025-01-invoice-desc-followup
Browse files Browse the repository at this point in the history
Add reconversion unit test (#438 followup)
  • Loading branch information
tnull authored Jan 24, 2025
2 parents df964a9 + 75d69f3 commit 3cd1e98
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/uniffi_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ impl UniffiCustomTypeConverter for NodeAlias {

/// Represents the description of an invoice which has to be either a directly included string or
/// a hash of a description provided out of band.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Bolt11InvoiceDescription {
/// Contains a full description.
Direct {
Expand Down Expand Up @@ -391,3 +392,17 @@ impl From<lightning_invoice::Bolt11InvoiceDescription> for Bolt11InvoiceDescript
}
}
}

#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_invoice_description_conversion() {
let hash = "09d08d4865e8af9266f6cc7c0ae23a1d6bf868207cf8f7c5979b9f6ed850dfb0".to_string();
let description = Bolt11InvoiceDescription::Hash { hash };
let converted_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(&description).unwrap();
let reconverted_description: Bolt11InvoiceDescription = converted_description.into();
assert_eq!(description, reconverted_description);
}
}

0 comments on commit 3cd1e98

Please sign in to comment.