1 // This file is Copyright its original authors, visible in version control
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
10 use crate::utils::test_logger;
11 use lightning::offers::invoice::Invoice;
12 use lightning::util::ser::Writeable;
13 use std::convert::TryFrom;
16 pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
17 if let Ok(invoice) = Invoice::try_from(data.to_vec()) {
18 let mut bytes = Vec::with_capacity(data.len());
19 invoice.write(&mut bytes).unwrap();
20 assert_eq!(data, bytes);
24 pub fn invoice_deser_test<Out: test_logger::Output>(data: &[u8], out: Out) {
29 pub extern "C" fn invoice_deser_run(data: *const u8, datalen: usize) {
30 do_test(unsafe { std::slice::from_raw_parts(data, datalen) }, test_logger::DevNull {});