GEN_TEST msg_channel_announcement msg_targets::
GEN_TEST msg_node_announcement msg_targets::
+GEN_TEST msg_query_short_channel_ids msg_targets::
+GEN_TEST msg_reply_short_channel_ids_end msg_targets::
+GEN_TEST msg_query_channel_range msg_targets::
+GEN_TEST msg_reply_channel_range msg_targets::
+GEN_TEST msg_gossip_timestamp_filter msg_targets::
GEN_TEST msg_update_add_htlc msg_targets::
GEN_TEST msg_error_message msg_targets::
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on target_template.txt
+// To modify it, modify target_template.txt and run gen_target.sh instead.
+
+#![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
+
+extern crate lightning_fuzz;
+use lightning_fuzz::msg_targets::msg_gossip_timestamp_filter::*;
+
+#[cfg(feature = "afl")]
+#[macro_use] extern crate afl;
+#[cfg(feature = "afl")]
+fn main() {
+ fuzz!(|data| {
+ msg_gossip_timestamp_filter_run(data.as_ptr(), data.len());
+ });
+}
+
+#[cfg(feature = "honggfuzz")]
+#[macro_use] extern crate honggfuzz;
+#[cfg(feature = "honggfuzz")]
+fn main() {
+ loop {
+ fuzz!(|data| {
+ msg_gossip_timestamp_filter_run(data.as_ptr(), data.len());
+ });
+ }
+}
+
+#[cfg(feature = "libfuzzer_fuzz")]
+#[macro_use] extern crate libfuzzer_sys;
+#[cfg(feature = "libfuzzer_fuzz")]
+fuzz_target!(|data: &[u8]| {
+ msg_gossip_timestamp_filter_run(data.as_ptr(), data.len());
+});
+
+#[cfg(feature = "stdin_fuzz")]
+fn main() {
+ use std::io::Read;
+
+ let mut data = Vec::with_capacity(8192);
+ std::io::stdin().read_to_end(&mut data).unwrap();
+ msg_gossip_timestamp_filter_run(data.as_ptr(), data.len());
+}
+
+#[test]
+fn run_test_cases() {
+ use std::fs;
+ use std::io::Read;
+ use lightning_fuzz::utils::test_logger::StringBuffer;
+
+ use std::sync::{atomic, Arc};
+ {
+ let data: Vec<u8> = vec![0];
+ msg_gossip_timestamp_filter_run(data.as_ptr(), data.len());
+ }
+ let mut threads = Vec::new();
+ let threads_running = Arc::new(atomic::AtomicUsize::new(0));
+ if let Ok(tests) = fs::read_dir("test_cases/msg_gossip_timestamp_filter") {
+ for test in tests {
+ let mut data: Vec<u8> = Vec::new();
+ let path = test.unwrap().path();
+ fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
+ threads_running.fetch_add(1, atomic::Ordering::AcqRel);
+
+ let thread_count_ref = Arc::clone(&threads_running);
+ let main_thread_ref = std::thread::current();
+ threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
+ std::thread::spawn(move || {
+ let string_logger = StringBuffer::new();
+
+ let panic_logger = string_logger.clone();
+ let res = if ::std::panic::catch_unwind(move || {
+ msg_gossip_timestamp_filter_test(&data, panic_logger);
+ }).is_err() {
+ Some(string_logger.into_string())
+ } else { None };
+ thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
+ main_thread_ref.unpark();
+ res
+ })
+ ));
+ while threads_running.load(atomic::Ordering::Acquire) > 32 {
+ std::thread::park();
+ }
+ }
+ }
+ for (test, thread) in threads.drain(..) {
+ if let Some(output) = thread.join().unwrap() {
+ println!("Output of {}:\n{}", test, output);
+ panic!();
+ }
+ }
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on target_template.txt
+// To modify it, modify target_template.txt and run gen_target.sh instead.
+
+#![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
+
+extern crate lightning_fuzz;
+use lightning_fuzz::msg_targets::msg_query_channel_range::*;
+
+#[cfg(feature = "afl")]
+#[macro_use] extern crate afl;
+#[cfg(feature = "afl")]
+fn main() {
+ fuzz!(|data| {
+ msg_query_channel_range_run(data.as_ptr(), data.len());
+ });
+}
+
+#[cfg(feature = "honggfuzz")]
+#[macro_use] extern crate honggfuzz;
+#[cfg(feature = "honggfuzz")]
+fn main() {
+ loop {
+ fuzz!(|data| {
+ msg_query_channel_range_run(data.as_ptr(), data.len());
+ });
+ }
+}
+
+#[cfg(feature = "libfuzzer_fuzz")]
+#[macro_use] extern crate libfuzzer_sys;
+#[cfg(feature = "libfuzzer_fuzz")]
+fuzz_target!(|data: &[u8]| {
+ msg_query_channel_range_run(data.as_ptr(), data.len());
+});
+
+#[cfg(feature = "stdin_fuzz")]
+fn main() {
+ use std::io::Read;
+
+ let mut data = Vec::with_capacity(8192);
+ std::io::stdin().read_to_end(&mut data).unwrap();
+ msg_query_channel_range_run(data.as_ptr(), data.len());
+}
+
+#[test]
+fn run_test_cases() {
+ use std::fs;
+ use std::io::Read;
+ use lightning_fuzz::utils::test_logger::StringBuffer;
+
+ use std::sync::{atomic, Arc};
+ {
+ let data: Vec<u8> = vec![0];
+ msg_query_channel_range_run(data.as_ptr(), data.len());
+ }
+ let mut threads = Vec::new();
+ let threads_running = Arc::new(atomic::AtomicUsize::new(0));
+ if let Ok(tests) = fs::read_dir("test_cases/msg_query_channel_range") {
+ for test in tests {
+ let mut data: Vec<u8> = Vec::new();
+ let path = test.unwrap().path();
+ fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
+ threads_running.fetch_add(1, atomic::Ordering::AcqRel);
+
+ let thread_count_ref = Arc::clone(&threads_running);
+ let main_thread_ref = std::thread::current();
+ threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
+ std::thread::spawn(move || {
+ let string_logger = StringBuffer::new();
+
+ let panic_logger = string_logger.clone();
+ let res = if ::std::panic::catch_unwind(move || {
+ msg_query_channel_range_test(&data, panic_logger);
+ }).is_err() {
+ Some(string_logger.into_string())
+ } else { None };
+ thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
+ main_thread_ref.unpark();
+ res
+ })
+ ));
+ while threads_running.load(atomic::Ordering::Acquire) > 32 {
+ std::thread::park();
+ }
+ }
+ }
+ for (test, thread) in threads.drain(..) {
+ if let Some(output) = thread.join().unwrap() {
+ println!("Output of {}:\n{}", test, output);
+ panic!();
+ }
+ }
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on target_template.txt
+// To modify it, modify target_template.txt and run gen_target.sh instead.
+
+#![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
+
+extern crate lightning_fuzz;
+use lightning_fuzz::msg_targets::msg_query_short_channel_ids::*;
+
+#[cfg(feature = "afl")]
+#[macro_use] extern crate afl;
+#[cfg(feature = "afl")]
+fn main() {
+ fuzz!(|data| {
+ msg_query_short_channel_ids_run(data.as_ptr(), data.len());
+ });
+}
+
+#[cfg(feature = "honggfuzz")]
+#[macro_use] extern crate honggfuzz;
+#[cfg(feature = "honggfuzz")]
+fn main() {
+ loop {
+ fuzz!(|data| {
+ msg_query_short_channel_ids_run(data.as_ptr(), data.len());
+ });
+ }
+}
+
+#[cfg(feature = "libfuzzer_fuzz")]
+#[macro_use] extern crate libfuzzer_sys;
+#[cfg(feature = "libfuzzer_fuzz")]
+fuzz_target!(|data: &[u8]| {
+ msg_query_short_channel_ids_run(data.as_ptr(), data.len());
+});
+
+#[cfg(feature = "stdin_fuzz")]
+fn main() {
+ use std::io::Read;
+
+ let mut data = Vec::with_capacity(8192);
+ std::io::stdin().read_to_end(&mut data).unwrap();
+ msg_query_short_channel_ids_run(data.as_ptr(), data.len());
+}
+
+#[test]
+fn run_test_cases() {
+ use std::fs;
+ use std::io::Read;
+ use lightning_fuzz::utils::test_logger::StringBuffer;
+
+ use std::sync::{atomic, Arc};
+ {
+ let data: Vec<u8> = vec![0];
+ msg_query_short_channel_ids_run(data.as_ptr(), data.len());
+ }
+ let mut threads = Vec::new();
+ let threads_running = Arc::new(atomic::AtomicUsize::new(0));
+ if let Ok(tests) = fs::read_dir("test_cases/msg_query_short_channel_ids") {
+ for test in tests {
+ let mut data: Vec<u8> = Vec::new();
+ let path = test.unwrap().path();
+ fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
+ threads_running.fetch_add(1, atomic::Ordering::AcqRel);
+
+ let thread_count_ref = Arc::clone(&threads_running);
+ let main_thread_ref = std::thread::current();
+ threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
+ std::thread::spawn(move || {
+ let string_logger = StringBuffer::new();
+
+ let panic_logger = string_logger.clone();
+ let res = if ::std::panic::catch_unwind(move || {
+ msg_query_short_channel_ids_test(&data, panic_logger);
+ }).is_err() {
+ Some(string_logger.into_string())
+ } else { None };
+ thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
+ main_thread_ref.unpark();
+ res
+ })
+ ));
+ while threads_running.load(atomic::Ordering::Acquire) > 32 {
+ std::thread::park();
+ }
+ }
+ }
+ for (test, thread) in threads.drain(..) {
+ if let Some(output) = thread.join().unwrap() {
+ println!("Output of {}:\n{}", test, output);
+ panic!();
+ }
+ }
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on target_template.txt
+// To modify it, modify target_template.txt and run gen_target.sh instead.
+
+#![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
+
+extern crate lightning_fuzz;
+use lightning_fuzz::msg_targets::msg_reply_channel_range::*;
+
+#[cfg(feature = "afl")]
+#[macro_use] extern crate afl;
+#[cfg(feature = "afl")]
+fn main() {
+ fuzz!(|data| {
+ msg_reply_channel_range_run(data.as_ptr(), data.len());
+ });
+}
+
+#[cfg(feature = "honggfuzz")]
+#[macro_use] extern crate honggfuzz;
+#[cfg(feature = "honggfuzz")]
+fn main() {
+ loop {
+ fuzz!(|data| {
+ msg_reply_channel_range_run(data.as_ptr(), data.len());
+ });
+ }
+}
+
+#[cfg(feature = "libfuzzer_fuzz")]
+#[macro_use] extern crate libfuzzer_sys;
+#[cfg(feature = "libfuzzer_fuzz")]
+fuzz_target!(|data: &[u8]| {
+ msg_reply_channel_range_run(data.as_ptr(), data.len());
+});
+
+#[cfg(feature = "stdin_fuzz")]
+fn main() {
+ use std::io::Read;
+
+ let mut data = Vec::with_capacity(8192);
+ std::io::stdin().read_to_end(&mut data).unwrap();
+ msg_reply_channel_range_run(data.as_ptr(), data.len());
+}
+
+#[test]
+fn run_test_cases() {
+ use std::fs;
+ use std::io::Read;
+ use lightning_fuzz::utils::test_logger::StringBuffer;
+
+ use std::sync::{atomic, Arc};
+ {
+ let data: Vec<u8> = vec![0];
+ msg_reply_channel_range_run(data.as_ptr(), data.len());
+ }
+ let mut threads = Vec::new();
+ let threads_running = Arc::new(atomic::AtomicUsize::new(0));
+ if let Ok(tests) = fs::read_dir("test_cases/msg_reply_channel_range") {
+ for test in tests {
+ let mut data: Vec<u8> = Vec::new();
+ let path = test.unwrap().path();
+ fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
+ threads_running.fetch_add(1, atomic::Ordering::AcqRel);
+
+ let thread_count_ref = Arc::clone(&threads_running);
+ let main_thread_ref = std::thread::current();
+ threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
+ std::thread::spawn(move || {
+ let string_logger = StringBuffer::new();
+
+ let panic_logger = string_logger.clone();
+ let res = if ::std::panic::catch_unwind(move || {
+ msg_reply_channel_range_test(&data, panic_logger);
+ }).is_err() {
+ Some(string_logger.into_string())
+ } else { None };
+ thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
+ main_thread_ref.unpark();
+ res
+ })
+ ));
+ while threads_running.load(atomic::Ordering::Acquire) > 32 {
+ std::thread::park();
+ }
+ }
+ }
+ for (test, thread) in threads.drain(..) {
+ if let Some(output) = thread.join().unwrap() {
+ println!("Output of {}:\n{}", test, output);
+ panic!();
+ }
+ }
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on target_template.txt
+// To modify it, modify target_template.txt and run gen_target.sh instead.
+
+#![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
+
+extern crate lightning_fuzz;
+use lightning_fuzz::msg_targets::msg_reply_short_channel_ids_end::*;
+
+#[cfg(feature = "afl")]
+#[macro_use] extern crate afl;
+#[cfg(feature = "afl")]
+fn main() {
+ fuzz!(|data| {
+ msg_reply_short_channel_ids_end_run(data.as_ptr(), data.len());
+ });
+}
+
+#[cfg(feature = "honggfuzz")]
+#[macro_use] extern crate honggfuzz;
+#[cfg(feature = "honggfuzz")]
+fn main() {
+ loop {
+ fuzz!(|data| {
+ msg_reply_short_channel_ids_end_run(data.as_ptr(), data.len());
+ });
+ }
+}
+
+#[cfg(feature = "libfuzzer_fuzz")]
+#[macro_use] extern crate libfuzzer_sys;
+#[cfg(feature = "libfuzzer_fuzz")]
+fuzz_target!(|data: &[u8]| {
+ msg_reply_short_channel_ids_end_run(data.as_ptr(), data.len());
+});
+
+#[cfg(feature = "stdin_fuzz")]
+fn main() {
+ use std::io::Read;
+
+ let mut data = Vec::with_capacity(8192);
+ std::io::stdin().read_to_end(&mut data).unwrap();
+ msg_reply_short_channel_ids_end_run(data.as_ptr(), data.len());
+}
+
+#[test]
+fn run_test_cases() {
+ use std::fs;
+ use std::io::Read;
+ use lightning_fuzz::utils::test_logger::StringBuffer;
+
+ use std::sync::{atomic, Arc};
+ {
+ let data: Vec<u8> = vec![0];
+ msg_reply_short_channel_ids_end_run(data.as_ptr(), data.len());
+ }
+ let mut threads = Vec::new();
+ let threads_running = Arc::new(atomic::AtomicUsize::new(0));
+ if let Ok(tests) = fs::read_dir("test_cases/msg_reply_short_channel_ids_end") {
+ for test in tests {
+ let mut data: Vec<u8> = Vec::new();
+ let path = test.unwrap().path();
+ fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
+ threads_running.fetch_add(1, atomic::Ordering::AcqRel);
+
+ let thread_count_ref = Arc::clone(&threads_running);
+ let main_thread_ref = std::thread::current();
+ threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
+ std::thread::spawn(move || {
+ let string_logger = StringBuffer::new();
+
+ let panic_logger = string_logger.clone();
+ let res = if ::std::panic::catch_unwind(move || {
+ msg_reply_short_channel_ids_end_test(&data, panic_logger);
+ }).is_err() {
+ Some(string_logger.into_string())
+ } else { None };
+ thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
+ main_thread_ref.unpark();
+ res
+ })
+ ));
+ while threads_running.load(atomic::Ordering::Acquire) > 32 {
+ std::thread::park();
+ }
+ }
+ }
+ for (test, thread) in threads.drain(..) {
+ if let Some(output) = thread.join().unwrap() {
+ println!("Output of {}:\n{}", test, output);
+ panic!();
+ }
+ }
+}
GEN_TEST ChannelAnnouncement test_msg_exact ""
GEN_TEST NodeAnnouncement test_msg_exact ""
+GEN_TEST QueryShortChannelIds test_msg ""
+GEN_TEST ReplyShortChannelIdsEnd test_msg ""
+GEN_TEST QueryChannelRange test_msg ""
+GEN_TEST ReplyChannelRange test_msg ""
+GEN_TEST GossipTimestampFilter test_msg ""
GEN_TEST UpdateAddHTLC test_msg_hole ", 85, 33"
GEN_TEST ErrorMessage test_msg_hole ", 32, 2"
pub mod msg_update_fulfill_htlc;
pub mod msg_channel_announcement;
pub mod msg_node_announcement;
+pub mod msg_query_short_channel_ids;
+pub mod msg_reply_short_channel_ids_end;
+pub mod msg_query_channel_range;
+pub mod msg_reply_channel_range;
+pub mod msg_gossip_timestamp_filter;
pub mod msg_update_add_htlc;
pub mod msg_error_message;
pub mod msg_channel_update;
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on msg_target_template.txt
+// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
+
+use lightning::ln::msgs;
+
+use msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_gossip_timestamp_filter_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg!(msgs::GossipTimestampFilter, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_gossip_timestamp_filter_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg!(msgs::GossipTimestampFilter, data);
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on msg_target_template.txt
+// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
+
+use lightning::ln::msgs;
+
+use msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_query_channel_range_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg!(msgs::QueryChannelRange, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_query_channel_range_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg!(msgs::QueryChannelRange, data);
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on msg_target_template.txt
+// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
+
+use lightning::ln::msgs;
+
+use msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_query_short_channel_ids_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg!(msgs::QueryShortChannelIds, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_query_short_channel_ids_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg!(msgs::QueryShortChannelIds, data);
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on msg_target_template.txt
+// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
+
+use lightning::ln::msgs;
+
+use msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_reply_channel_range_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg!(msgs::ReplyChannelRange, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_reply_channel_range_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg!(msgs::ReplyChannelRange, data);
+}
--- /dev/null
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+// This file is auto-generated by gen_target.sh based on msg_target_template.txt
+// To modify it, modify msg_target_template.txt and run gen_target.sh instead.
+
+use lightning::ln::msgs;
+
+use msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_reply_short_channel_ids_end_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg!(msgs::ReplyShortChannelIdsEnd, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_reply_short_channel_ids_end_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg!(msgs::ReplyShortChannelIdsEnd, data);
+}
void msg_update_fulfill_htlc_run(const unsigned char* data, size_t data_len);
void msg_channel_announcement_run(const unsigned char* data, size_t data_len);
void msg_node_announcement_run(const unsigned char* data, size_t data_len);
+void msg_query_short_channel_ids_run(const unsigned char* data, size_t data_len);
+void msg_reply_short_channel_ids_end_run(const unsigned char* data, size_t data_len);
+void msg_query_channel_range_run(const unsigned char* data, size_t data_len);
+void msg_reply_channel_range_run(const unsigned char* data, size_t data_len);
+void msg_gossip_timestamp_filter_run(const unsigned char* data, size_t data_len);
void msg_update_add_htlc_run(const unsigned char* data, size_t data_len);
void msg_error_message_run(const unsigned char* data, size_t data_len);
void msg_channel_update_run(const unsigned char* data, size_t data_len);
pub contents: UnsignedChannelUpdate,
}
+/// A query_channel_range message is used to query a peer for channel
+/// UTXOs in a range of blocks. The recipient of a query makes a best
+/// effort to reply to the query using one or more reply_channel_range
+/// messages.
+#[derive(Clone, Debug)]
+pub struct QueryChannelRange {
+ /// The genesis hash of the blockchain being queried
+ pub chain_hash: BlockHash,
+ /// The height of the first block for the channel UTXOs being queried
+ pub first_blocknum: u32,
+ /// The number of blocks to include in the query results
+ pub number_of_blocks: u32,
+}
+
+/// A reply_channel_range message is a reply to a query_channel_range
+/// message. Multiple reply_channel_range messages can be sent in reply
+/// to a single query_channel_range message. The query recipient makes a
+/// best effort to respond based on their local network view which may
+/// not be a perfect view of the network. The short_channel_ids in the
+/// reply are encoded. We only support encoding_type=0 uncompressed
+/// serialization and do not support encoding_type=1 zlib serialization.
+#[derive(Clone, Debug)]
+pub struct ReplyChannelRange {
+ /// The genesis hash of the blockchain being queried
+ pub chain_hash: BlockHash,
+ /// The height of the first block in the range of the reply
+ pub first_blocknum: u32,
+ /// The number of blocks included in the range of the reply
+ pub number_of_blocks: u32,
+ /// Indicates if the query recipient maintains up-to-date channel
+ /// information for the chain_hash
+ pub full_information: bool,
+ /// The short_channel_ids in the channel range
+ pub short_channel_ids: Vec<u64>,
+}
+
+/// A query_short_channel_ids message is used to query a peer for
+/// routing gossip messages related to one or more short_channel_ids.
+/// The query recipient will reply with the latest, if available,
+/// channel_announcement, channel_update and node_announcement messages
+/// it maintains for the requested short_channel_ids followed by a
+/// reply_short_channel_ids_end message. The short_channel_ids sent in
+/// this query are encoded. We only support encoding_type=0 uncompressed
+/// serialization and do not support encoding_type=1 zlib serialization.
+#[derive(Clone, Debug)]
+pub struct QueryShortChannelIds {
+ /// The genesis hash of the blockchain being queried
+ pub chain_hash: BlockHash,
+ /// The short_channel_ids that are being queried
+ pub short_channel_ids: Vec<u64>,
+}
+
+/// A reply_short_channel_ids_end message is sent as a reply to a
+/// query_short_channel_ids message. The query recipient makes a best
+/// effort to respond based on their local network view which may not be
+/// a perfect view of the network.
+#[derive(Clone, Debug)]
+pub struct ReplyShortChannelIdsEnd {
+ /// The genesis hash of the blockchain that was queried
+ pub chain_hash: BlockHash,
+ /// Indicates if the query recipient maintains up-to-date channel
+ /// information for the chain_hash
+ pub full_information: bool,
+}
+
+/// A gossip_timestamp_filter message is used by a node to request
+/// gossip relay for messages in the requested time range when the
+/// gossip_queries feature has been negotiated.
+#[derive(Clone, Debug)]
+pub struct GossipTimestampFilter {
+ /// The genesis hash of the blockchain for channel and node information
+ pub chain_hash: BlockHash,
+ /// The starting unix timestamp
+ pub first_timestamp: u32,
+ /// The range of information in seconds
+ pub timestamp_range: u32,
+}
+
+/// Encoding type for data compression of collections in gossip queries.
+/// We do not support encoding_type=1 zlib serialization defined in BOLT #7.
+enum EncodingType {
+ Uncompressed = 0x00,
+}
+
/// Used to put an error message in a LightningError
#[derive(Clone)]
pub enum ErrorAction {
contents
});
+impl Readable for QueryShortChannelIds {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let chain_hash: BlockHash = Readable::read(r)?;
+
+ // We expect the encoding_len to always includes the 1-byte
+ // encoding_type and that short_channel_ids are 8-bytes each
+ let encoding_len: u16 = Readable::read(r)?;
+ if encoding_len == 0 || (encoding_len - 1) % 8 != 0 {
+ return Err(DecodeError::InvalidValue);
+ }
+
+ // Must be encoding_type=0 uncompressed serialization. We do not
+ // support encoding_type=1 zlib serialization.
+ let encoding_type: u8 = Readable::read(r)?;
+ if encoding_type != EncodingType::Uncompressed as u8 {
+ return Err(DecodeError::InvalidValue);
+ }
+
+ // Read short_channel_ids (8-bytes each), for the u16 encoding_len
+ // less the 1-byte encoding_type
+ let short_channel_id_count: u16 = (encoding_len - 1)/8;
+ let mut short_channel_ids = Vec::with_capacity(short_channel_id_count as usize);
+ for _ in 0..short_channel_id_count {
+ short_channel_ids.push(Readable::read(r)?);
+ }
+
+ Ok(QueryShortChannelIds {
+ chain_hash,
+ short_channel_ids,
+ })
+ }
+}
+
+impl Writeable for QueryShortChannelIds {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ // Calculated from 1-byte encoding_type plus 8-bytes per short_channel_id
+ let encoding_len: u16 = 1 + self.short_channel_ids.len() as u16 * 8;
+
+ w.size_hint(32 + 2 + encoding_len as usize);
+ self.chain_hash.write(w)?;
+ encoding_len.write(w)?;
+
+ // We only support type=0 uncompressed serialization
+ (EncodingType::Uncompressed as u8).write(w)?;
+
+ for scid in self.short_channel_ids.iter() {
+ scid.write(w)?;
+ }
+
+ Ok(())
+ }
+}
+
+impl Readable for ReplyShortChannelIdsEnd {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let chain_hash: BlockHash = Readable::read(r)?;
+ let full_information: bool = Readable::read(r)?;
+ Ok(ReplyShortChannelIdsEnd {
+ chain_hash,
+ full_information,
+ })
+ }
+}
+
+impl Writeable for ReplyShortChannelIdsEnd {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ w.size_hint(32 + 1);
+ self.chain_hash.write(w)?;
+ self.full_information.write(w)?;
+ Ok(())
+ }
+}
+
+impl Readable for QueryChannelRange {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let chain_hash: BlockHash = Readable::read(r)?;
+ let first_blocknum: u32 = Readable::read(r)?;
+ let number_of_blocks: u32 = Readable::read(r)?;
+ Ok(QueryChannelRange {
+ chain_hash,
+ first_blocknum,
+ number_of_blocks
+ })
+ }
+}
+
+impl Writeable for QueryChannelRange {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ w.size_hint(32 + 4 + 4);
+ self.chain_hash.write(w)?;
+ self.first_blocknum.write(w)?;
+ self.number_of_blocks.write(w)?;
+ Ok(())
+ }
+}
+
+impl Readable for ReplyChannelRange {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let chain_hash: BlockHash = Readable::read(r)?;
+ let first_blocknum: u32 = Readable::read(r)?;
+ let number_of_blocks: u32 = Readable::read(r)?;
+ let full_information: bool = Readable::read(r)?;
+
+ // We expect the encoding_len to always includes the 1-byte
+ // encoding_type and that short_channel_ids are 8-bytes each
+ let encoding_len: u16 = Readable::read(r)?;
+ if encoding_len == 0 || (encoding_len - 1) % 8 != 0 {
+ return Err(DecodeError::InvalidValue);
+ }
+
+ // Must be encoding_type=0 uncompressed serialization. We do not
+ // support encoding_type=1 zlib serialization.
+ let encoding_type: u8 = Readable::read(r)?;
+ if encoding_type != EncodingType::Uncompressed as u8 {
+ return Err(DecodeError::InvalidValue);
+ }
+
+ // Read short_channel_ids (8-bytes each), for the u16 encoding_len
+ // less the 1-byte encoding_type
+ let short_channel_id_count: u16 = (encoding_len - 1)/8;
+ let mut short_channel_ids = Vec::with_capacity(short_channel_id_count as usize);
+ for _ in 0..short_channel_id_count {
+ short_channel_ids.push(Readable::read(r)?);
+ }
+
+ Ok(ReplyChannelRange {
+ chain_hash,
+ first_blocknum,
+ number_of_blocks,
+ full_information,
+ short_channel_ids
+ })
+ }
+}
+
+impl Writeable for ReplyChannelRange {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ let encoding_len: u16 = 1 + self.short_channel_ids.len() as u16 * 8;
+ w.size_hint(32 + 4 + 4 + 1 + 2 + encoding_len as usize);
+ self.chain_hash.write(w)?;
+ self.first_blocknum.write(w)?;
+ self.number_of_blocks.write(w)?;
+ self.full_information.write(w)?;
+
+ encoding_len.write(w)?;
+ (EncodingType::Uncompressed as u8).write(w)?;
+ for scid in self.short_channel_ids.iter() {
+ scid.write(w)?;
+ }
+
+ Ok(())
+ }
+}
+
+impl Readable for GossipTimestampFilter {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let chain_hash: BlockHash = Readable::read(r)?;
+ let first_timestamp: u32 = Readable::read(r)?;
+ let timestamp_range: u32 = Readable::read(r)?;
+ Ok(GossipTimestampFilter {
+ chain_hash,
+ first_timestamp,
+ timestamp_range,
+ })
+ }
+}
+
+impl Writeable for GossipTimestampFilter {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ w.size_hint(32 + 4 + 4);
+ self.chain_hash.write(w)?;
+ self.first_timestamp.write(w)?;
+ self.timestamp_range.write(w)?;
+ Ok(())
+ }
+}
+
+
#[cfg(test)]
mod tests {
use hex;
assert_eq!(msg.amt_to_forward, 0x0badf00d01020304);
assert_eq!(msg.outgoing_cltv_value, 0xffffffff);
}
+
+ #[test]
+ fn encoding_query_channel_range() {
+ let mut query_channel_range = msgs::QueryChannelRange {
+ chain_hash: BlockHash::from_hex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f").unwrap(),
+ first_blocknum: 100000,
+ number_of_blocks: 1500,
+ };
+ let encoded_value = query_channel_range.encode();
+ let target_value = hex::decode("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206000186a0000005dc").unwrap();
+ assert_eq!(encoded_value, target_value);
+
+ query_channel_range = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
+ assert_eq!(query_channel_range.first_blocknum, 100000);
+ assert_eq!(query_channel_range.number_of_blocks, 1500);
+ }
+
+ #[test]
+ fn encoding_reply_channel_range() {
+ do_encoding_reply_channel_range(0);
+ do_encoding_reply_channel_range(1);
+ }
+
+ fn do_encoding_reply_channel_range(encoding_type: u8) {
+ let mut target_value = hex::decode("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206000b8a06000005dc01").unwrap();
+ let expected_chain_hash = BlockHash::from_hex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f").unwrap();
+ let mut reply_channel_range = msgs::ReplyChannelRange {
+ chain_hash: expected_chain_hash,
+ first_blocknum: 756230,
+ number_of_blocks: 1500,
+ full_information: true,
+ short_channel_ids: vec![0x000000000000008e, 0x0000000000003c69, 0x000000000045a6c4],
+ };
+
+ if encoding_type == 0 {
+ target_value.append(&mut hex::decode("001900000000000000008e0000000000003c69000000000045a6c4").unwrap());
+ let encoded_value = reply_channel_range.encode();
+ assert_eq!(encoded_value, target_value);
+
+ reply_channel_range = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
+ assert_eq!(reply_channel_range.chain_hash, expected_chain_hash);
+ assert_eq!(reply_channel_range.first_blocknum, 756230);
+ assert_eq!(reply_channel_range.number_of_blocks, 1500);
+ assert_eq!(reply_channel_range.full_information, true);
+ assert_eq!(reply_channel_range.short_channel_ids[0], 0x000000000000008e);
+ assert_eq!(reply_channel_range.short_channel_ids[1], 0x0000000000003c69);
+ assert_eq!(reply_channel_range.short_channel_ids[2], 0x000000000045a6c4);
+ } else {
+ target_value.append(&mut hex::decode("001601789c636000833e08659309a65878be010010a9023a").unwrap());
+ let result: Result<msgs::ReplyChannelRange, msgs::DecodeError> = Readable::read(&mut Cursor::new(&target_value[..]));
+ assert!(result.is_err(), "Expected decode failure with unsupported zlib encoding");
+ }
+ }
+
+ #[test]
+ fn encoding_query_short_channel_ids() {
+ do_encoding_query_short_channel_ids(0);
+ do_encoding_query_short_channel_ids(1);
+ }
+
+ fn do_encoding_query_short_channel_ids(encoding_type: u8) {
+ let mut target_value = hex::decode("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206").unwrap();
+ let expected_chain_hash = BlockHash::from_hex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f").unwrap();
+ let mut query_short_channel_ids = msgs::QueryShortChannelIds {
+ chain_hash: expected_chain_hash,
+ short_channel_ids: vec![0x0000000000008e, 0x0000000000003c69, 0x000000000045a6c4],
+ };
+
+ if encoding_type == 0 {
+ target_value.append(&mut hex::decode("001900000000000000008e0000000000003c69000000000045a6c4").unwrap());
+ let encoded_value = query_short_channel_ids.encode();
+ assert_eq!(encoded_value, target_value);
+
+ query_short_channel_ids = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
+ assert_eq!(query_short_channel_ids.chain_hash, expected_chain_hash);
+ assert_eq!(query_short_channel_ids.short_channel_ids[0], 0x000000000000008e);
+ assert_eq!(query_short_channel_ids.short_channel_ids[1], 0x0000000000003c69);
+ assert_eq!(query_short_channel_ids.short_channel_ids[2], 0x000000000045a6c4);
+ } else {
+ target_value.append(&mut hex::decode("001601789c636000833e08659309a65878be010010a9023a").unwrap());
+ let result: Result<msgs::QueryShortChannelIds, msgs::DecodeError> = Readable::read(&mut Cursor::new(&target_value[..]));
+ assert!(result.is_err(), "Expected decode failure with unsupported zlib encoding");
+ }
+ }
+
+ #[test]
+ fn encoding_reply_short_channel_ids_end() {
+ let expected_chain_hash = BlockHash::from_hex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f").unwrap();
+ let mut reply_short_channel_ids_end = msgs::ReplyShortChannelIdsEnd {
+ chain_hash: expected_chain_hash,
+ full_information: true,
+ };
+ let encoded_value = reply_short_channel_ids_end.encode();
+ let target_value = hex::decode("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e220601").unwrap();
+ assert_eq!(encoded_value, target_value);
+
+ reply_short_channel_ids_end = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
+ assert_eq!(reply_short_channel_ids_end.chain_hash, expected_chain_hash);
+ assert_eq!(reply_short_channel_ids_end.full_information, true);
+ }
+
+ #[test]
+ fn encoding_gossip_timestamp_filter(){
+ let expected_chain_hash = BlockHash::from_hex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f").unwrap();
+ let mut gossip_timestamp_filter = msgs::GossipTimestampFilter {
+ chain_hash: expected_chain_hash,
+ first_timestamp: 1590000000,
+ timestamp_range: 0xffff_ffff,
+ };
+ let encoded_value = gossip_timestamp_filter.encode();
+ let target_value = hex::decode("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e22065ec57980ffffffff").unwrap();
+ assert_eq!(encoded_value, target_value);
+
+ gossip_timestamp_filter = Readable::read(&mut Cursor::new(&target_value[..])).unwrap();
+ assert_eq!(gossip_timestamp_filter.chain_hash, expected_chain_hash);
+ assert_eq!(gossip_timestamp_filter.first_timestamp, 1590000000);
+ assert_eq!(gossip_timestamp_filter.timestamp_range, 0xffff_ffff);
+ }
}