Skip to content

Commit 75d69f3

Browse files
committed
Add reconversion unit test
We simply check that converting back-and-forth between hash types nothing is lost.
1 parent 92ee62f commit 75d69f3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/uniffi_types.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl UniffiCustomTypeConverter for NodeAlias {
348348

349349
/// Represents the description of an invoice which has to be either a directly included string or
350350
/// a hash of a description provided out of band.
351+
#[derive(Debug, Clone, PartialEq, Eq)]
351352
pub enum Bolt11InvoiceDescription {
352353
/// Contains a full description.
353354
Direct {
@@ -391,3 +392,17 @@ impl From<lightning_invoice::Bolt11InvoiceDescription> for Bolt11InvoiceDescript
391392
}
392393
}
393394
}
395+
396+
#[cfg(test)]
397+
mod tests {
398+
use super::*;
399+
#[test]
400+
fn test_invoice_description_conversion() {
401+
let hash = "09d08d4865e8af9266f6cc7c0ae23a1d6bf868207cf8f7c5979b9f6ed850dfb0".to_string();
402+
let description = Bolt11InvoiceDescription::Hash { hash };
403+
let converted_description =
404+
lightning_invoice::Bolt11InvoiceDescription::try_from(&description).unwrap();
405+
let reconverted_description: Bolt11InvoiceDescription = converted_description.into();
406+
assert_eq!(description, reconverted_description);
407+
}
408+
}

0 commit comments

Comments
 (0)