Rename SocketAddress from NetAddress
[rust-lightning] / fuzz / src / fromstr_to_netaddress.rs
1 // This file is Copyright its original authors, visible in version control
2 // history.
3 //
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
8 // licenses.
9
10 use lightning::ln::msgs::SocketAddress;
11 use core::str::FromStr;
12
13 use crate::utils::test_logger;
14
15 #[inline]
16 pub fn do_test(data: &[u8]) {
17         if let Ok(s) = std::str::from_utf8(data) {
18                 let _ = SocketAddress::from_str(s);
19         }
20
21 }
22
23 pub fn fromstr_to_netaddress_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
24         do_test(data);
25 }
26
27 #[no_mangle]
28 pub extern "C" fn fromstr_to_netaddress_run(data: *const u8, datalen: usize) {
29         do_test(unsafe { std::slice::from_raw_parts(data, datalen) });
30 }
31