-# 0.0.109 - 2022-06-30
+# 0.0.109 - 2022-07-01
## API Updates
* `ChannelManager::update_channel_config` has been added to allow the fields
--- /dev/null
+# Security Policy
+
+## Reporting a Vulnerability
+
+Please report security vulnerabilities, including denial-of-service
+vulnerabilities such as spurious panics, via email to
+security@lightningdevkit.org.
+
+If possible, please PGP-encrypt such emails to the following keys (available on
+keyservers and WKD via `gpg --auto-key-locate wkd --locate-external-keys
+ldk-security-1@mattcorallo.com ldk-security-2@mattcorallo.com`). Please include
+your own public key as an attachment or inline for replies.
+
+ * 07DF3E57A548CCFB7530709189BBB8663E2E65CE (Matt Corallo)
+ * 5DBC576CCCF546CA72AB06CE912EF12EA67705F5 (Jeffrey Czyz)
+ * 729E9D9D92C75A5FBFEEE057B5DD717BEF7CA5B1 (Wilmer Paulino)
+ * BD6EED4D339EDBF7E7CE7F8836153082BDF676FD (Elias Rohrer)
+ * 6E0287D8849AE741E47CC586FD3E106A2CE099B4 (Valentine Wallace)
+ * 69CFEA635D0E6E6F13FD9D9136D932FCAC0305F0 (Arik Sosman)
+ * A5A6868D7AA91DD00AC1A67F817FFA028EF61C94 (Antoine Riard)
GEN_TEST msg_onion_hop_data msg_targets::
GEN_TEST msg_ping msg_targets::
GEN_TEST msg_pong msg_targets::
+
+GEN_TEST msg_channel_details msg_targets::
#!/bin/sh
GEN_TEST() {
- tn=msg_$(echo $1 | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]')
+ tn=msg_$(echo $1 | sed s'/.*:://g' | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]')
fn=${tn}.rs
cat msg_target_template.txt | sed s/MSG_TARGET/$1/ | sed "s/TARGET_NAME/$tn/" | sed "s/TEST_MSG/$2/" | sed "s/EXTRA_ARGS/$3/" > $fn
echo "pub mod $tn;" >> mod.rs
# Note when adding new targets here you should add a similar line in src/bin/gen_target.sh
-GEN_TEST AcceptChannel test_msg_simple ""
-GEN_TEST AnnouncementSignatures test_msg_simple ""
-GEN_TEST ClosingSigned test_msg_simple ""
-GEN_TEST CommitmentSigned test_msg_simple ""
-GEN_TEST FundingCreated test_msg_simple ""
-GEN_TEST ChannelReady test_msg_simple ""
-GEN_TEST FundingSigned test_msg_simple ""
-GEN_TEST GossipTimestampFilter test_msg_simple ""
-GEN_TEST Init test_msg_simple ""
-GEN_TEST OnionHopData test_msg_simple ""
-GEN_TEST OpenChannel test_msg_simple ""
-GEN_TEST Ping test_msg_simple ""
-GEN_TEST Pong test_msg_simple ""
-GEN_TEST QueryChannelRange test_msg_simple ""
-GEN_TEST ReplyShortChannelIdsEnd test_msg_simple ""
-GEN_TEST RevokeAndACK test_msg_simple ""
-GEN_TEST Shutdown test_msg_simple ""
-GEN_TEST UpdateAddHTLC test_msg_simple ""
-GEN_TEST UpdateFailHTLC test_msg_simple ""
-GEN_TEST UpdateFailMalformedHTLC test_msg_simple ""
-GEN_TEST UpdateFee test_msg_simple ""
-GEN_TEST UpdateFulfillHTLC test_msg_simple ""
-
-GEN_TEST ChannelReestablish test_msg ""
-GEN_TEST DecodedOnionErrorPacket test_msg ""
-
-GEN_TEST ChannelAnnouncement test_msg_exact ""
-GEN_TEST NodeAnnouncement test_msg_exact ""
-GEN_TEST QueryShortChannelIds test_msg ""
-GEN_TEST ReplyChannelRange test_msg ""
-
-GEN_TEST ErrorMessage test_msg_hole ", 32, 2"
-GEN_TEST WarningMessage test_msg_hole ", 32, 2"
-GEN_TEST ChannelUpdate test_msg_hole ", 108, 1"
+GEN_TEST lightning::ln::msgs::AcceptChannel test_msg_simple ""
+GEN_TEST lightning::ln::msgs::AnnouncementSignatures test_msg_simple ""
+GEN_TEST lightning::ln::msgs::ClosingSigned test_msg_simple ""
+GEN_TEST lightning::ln::msgs::CommitmentSigned test_msg_simple ""
+GEN_TEST lightning::ln::msgs::FundingCreated test_msg_simple ""
+GEN_TEST lightning::ln::msgs::ChannelReady test_msg_simple ""
+GEN_TEST lightning::ln::msgs::FundingSigned test_msg_simple ""
+GEN_TEST lightning::ln::msgs::GossipTimestampFilter test_msg_simple ""
+GEN_TEST lightning::ln::msgs::Init test_msg_simple ""
+GEN_TEST lightning::ln::msgs::OnionHopData test_msg_simple ""
+GEN_TEST lightning::ln::msgs::OpenChannel test_msg_simple ""
+GEN_TEST lightning::ln::msgs::Ping test_msg_simple ""
+GEN_TEST lightning::ln::msgs::Pong test_msg_simple ""
+GEN_TEST lightning::ln::msgs::QueryChannelRange test_msg_simple ""
+GEN_TEST lightning::ln::msgs::ReplyShortChannelIdsEnd test_msg_simple ""
+GEN_TEST lightning::ln::msgs::RevokeAndACK test_msg_simple ""
+GEN_TEST lightning::ln::msgs::Shutdown test_msg_simple ""
+GEN_TEST lightning::ln::msgs::UpdateAddHTLC test_msg_simple ""
+GEN_TEST lightning::ln::msgs::UpdateFailHTLC test_msg_simple ""
+GEN_TEST lightning::ln::msgs::UpdateFailMalformedHTLC test_msg_simple ""
+GEN_TEST lightning::ln::msgs::UpdateFee test_msg_simple ""
+GEN_TEST lightning::ln::msgs::UpdateFulfillHTLC test_msg_simple ""
+
+GEN_TEST lightning::ln::msgs::ChannelReestablish test_msg ""
+GEN_TEST lightning::ln::msgs::DecodedOnionErrorPacket test_msg ""
+
+GEN_TEST lightning::ln::msgs::ChannelAnnouncement test_msg_exact ""
+GEN_TEST lightning::ln::msgs::NodeAnnouncement test_msg_exact ""
+GEN_TEST lightning::ln::msgs::QueryShortChannelIds test_msg ""
+GEN_TEST lightning::ln::msgs::ReplyChannelRange test_msg ""
+
+GEN_TEST lightning::ln::msgs::ErrorMessage test_msg_hole ", 32, 2"
+GEN_TEST lightning::ln::msgs::WarningMessage test_msg_hole ", 32, 2"
+GEN_TEST lightning::ln::msgs::ChannelUpdate test_msg_hole ", 108, 1"
+
+GEN_TEST lightning::ln::channelmanager::ChannelDetails test_msg_simple ""
pub mod msg_error_message;
pub mod msg_warning_message;
pub mod msg_channel_update;
+pub mod msg_channel_details;
// 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_accept_channel_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::AcceptChannel, data);
+ test_msg_simple!(lightning::ln::msgs::AcceptChannel, data);
}
#[no_mangle]
pub extern "C" fn msg_accept_channel_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::AcceptChannel, data);
+ test_msg_simple!(lightning::ln::msgs::AcceptChannel, data);
}
// 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_announcement_signatures_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::AnnouncementSignatures, data);
+ test_msg_simple!(lightning::ln::msgs::AnnouncementSignatures, data);
}
#[no_mangle]
pub extern "C" fn msg_announcement_signatures_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::AnnouncementSignatures, data);
+ test_msg_simple!(lightning::ln::msgs::AnnouncementSignatures, data);
}
// 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_channel_announcement_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_exact!(msgs::ChannelAnnouncement, data);
+ test_msg_exact!(lightning::ln::msgs::ChannelAnnouncement, data);
}
#[no_mangle]
pub extern "C" fn msg_channel_announcement_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_exact!(msgs::ChannelAnnouncement, data);
+ test_msg_exact!(lightning::ln::msgs::ChannelAnnouncement, 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 msg_targets::utils::VecWriter;
+use utils::test_logger;
+
+#[inline]
+pub fn msg_channel_details_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
+ test_msg_simple!(lightning::ln::channelmanager::ChannelDetails, data);
+}
+
+#[no_mangle]
+pub extern "C" fn msg_channel_details_run(data: *const u8, datalen: usize) {
+ let data = unsafe { std::slice::from_raw_parts(data, datalen) };
+ test_msg_simple!(lightning::ln::channelmanager::ChannelDetails, data);
+}
// 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_channel_ready_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::ChannelReady, data);
+ test_msg_simple!(lightning::ln::msgs::ChannelReady, data);
}
#[no_mangle]
pub extern "C" fn msg_channel_ready_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::ChannelReady, data);
+ test_msg_simple!(lightning::ln::msgs::ChannelReady, data);
}
// 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_channel_reestablish_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg!(msgs::ChannelReestablish, data);
+ test_msg!(lightning::ln::msgs::ChannelReestablish, data);
}
#[no_mangle]
pub extern "C" fn msg_channel_reestablish_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg!(msgs::ChannelReestablish, data);
+ test_msg!(lightning::ln::msgs::ChannelReestablish, data);
}
// 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_channel_update_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_hole!(msgs::ChannelUpdate, data, 108, 1);
+ test_msg_hole!(lightning::ln::msgs::ChannelUpdate, data, 108, 1);
}
#[no_mangle]
pub extern "C" fn msg_channel_update_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_hole!(msgs::ChannelUpdate, data, 108, 1);
+ test_msg_hole!(lightning::ln::msgs::ChannelUpdate, data, 108, 1);
}
// 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_closing_signed_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::ClosingSigned, data);
+ test_msg_simple!(lightning::ln::msgs::ClosingSigned, data);
}
#[no_mangle]
pub extern "C" fn msg_closing_signed_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::ClosingSigned, data);
+ test_msg_simple!(lightning::ln::msgs::ClosingSigned, data);
}
// 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_commitment_signed_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::CommitmentSigned, data);
+ test_msg_simple!(lightning::ln::msgs::CommitmentSigned, data);
}
#[no_mangle]
pub extern "C" fn msg_commitment_signed_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::CommitmentSigned, data);
+ test_msg_simple!(lightning::ln::msgs::CommitmentSigned, data);
}
// 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_decoded_onion_error_packet_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg!(msgs::DecodedOnionErrorPacket, data);
+ test_msg!(lightning::ln::msgs::DecodedOnionErrorPacket, data);
}
#[no_mangle]
pub extern "C" fn msg_decoded_onion_error_packet_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg!(msgs::DecodedOnionErrorPacket, data);
+ test_msg!(lightning::ln::msgs::DecodedOnionErrorPacket, data);
}
// 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_error_message_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_hole!(msgs::ErrorMessage, data, 32, 2);
+ test_msg_hole!(lightning::ln::msgs::ErrorMessage, data, 32, 2);
}
#[no_mangle]
pub extern "C" fn msg_error_message_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_hole!(msgs::ErrorMessage, data, 32, 2);
+ test_msg_hole!(lightning::ln::msgs::ErrorMessage, data, 32, 2);
}
// 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_funding_created_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::FundingCreated, data);
+ test_msg_simple!(lightning::ln::msgs::FundingCreated, data);
}
#[no_mangle]
pub extern "C" fn msg_funding_created_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::FundingCreated, data);
+ test_msg_simple!(lightning::ln::msgs::FundingCreated, data);
}
// 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_funding_signed_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::FundingSigned, data);
+ test_msg_simple!(lightning::ln::msgs::FundingSigned, data);
}
#[no_mangle]
pub extern "C" fn msg_funding_signed_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::FundingSigned, data);
+ test_msg_simple!(lightning::ln::msgs::FundingSigned, data);
}
// 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_simple!(msgs::GossipTimestampFilter, data);
+ test_msg_simple!(lightning::ln::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_simple!(msgs::GossipTimestampFilter, data);
+ test_msg_simple!(lightning::ln::msgs::GossipTimestampFilter, data);
}
// 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_init_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::Init, data);
+ test_msg_simple!(lightning::ln::msgs::Init, data);
}
#[no_mangle]
pub extern "C" fn msg_init_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::Init, data);
+ test_msg_simple!(lightning::ln::msgs::Init, data);
}
// 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_node_announcement_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_exact!(msgs::NodeAnnouncement, data);
+ test_msg_exact!(lightning::ln::msgs::NodeAnnouncement, data);
}
#[no_mangle]
pub extern "C" fn msg_node_announcement_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_exact!(msgs::NodeAnnouncement, data);
+ test_msg_exact!(lightning::ln::msgs::NodeAnnouncement, data);
}
// 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_onion_hop_data_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::OnionHopData, data);
+ test_msg_simple!(lightning::ln::msgs::OnionHopData, data);
}
#[no_mangle]
pub extern "C" fn msg_onion_hop_data_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::OnionHopData, data);
+ test_msg_simple!(lightning::ln::msgs::OnionHopData, data);
}
// 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_open_channel_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::OpenChannel, data);
+ test_msg_simple!(lightning::ln::msgs::OpenChannel, data);
}
#[no_mangle]
pub extern "C" fn msg_open_channel_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::OpenChannel, data);
+ test_msg_simple!(lightning::ln::msgs::OpenChannel, data);
}
// 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_ping_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::Ping, data);
+ test_msg_simple!(lightning::ln::msgs::Ping, data);
}
#[no_mangle]
pub extern "C" fn msg_ping_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::Ping, data);
+ test_msg_simple!(lightning::ln::msgs::Ping, data);
}
// 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_pong_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::Pong, data);
+ test_msg_simple!(lightning::ln::msgs::Pong, data);
}
#[no_mangle]
pub extern "C" fn msg_pong_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::Pong, data);
+ test_msg_simple!(lightning::ln::msgs::Pong, data);
}
// 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_simple!(msgs::QueryChannelRange, data);
+ test_msg_simple!(lightning::ln::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_simple!(msgs::QueryChannelRange, data);
+ test_msg_simple!(lightning::ln::msgs::QueryChannelRange, data);
}
// 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);
+ test_msg!(lightning::ln::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);
+ test_msg!(lightning::ln::msgs::QueryShortChannelIds, data);
}
// 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);
+ test_msg!(lightning::ln::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);
+ test_msg!(lightning::ln::msgs::ReplyChannelRange, data);
}
// 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_simple!(msgs::ReplyShortChannelIdsEnd, data);
+ test_msg_simple!(lightning::ln::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_simple!(msgs::ReplyShortChannelIdsEnd, data);
+ test_msg_simple!(lightning::ln::msgs::ReplyShortChannelIdsEnd, data);
}
// 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_revoke_and_ack_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::RevokeAndACK, data);
+ test_msg_simple!(lightning::ln::msgs::RevokeAndACK, data);
}
#[no_mangle]
pub extern "C" fn msg_revoke_and_ack_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::RevokeAndACK, data);
+ test_msg_simple!(lightning::ln::msgs::RevokeAndACK, data);
}
// 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_shutdown_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::Shutdown, data);
+ test_msg_simple!(lightning::ln::msgs::Shutdown, data);
}
#[no_mangle]
pub extern "C" fn msg_shutdown_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::Shutdown, data);
+ test_msg_simple!(lightning::ln::msgs::Shutdown, data);
}
// 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 TARGET_NAME_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- TEST_MSG!(msgs::MSG_TARGET, dataEXTRA_ARGS);
+ TEST_MSG!(MSG_TARGET, dataEXTRA_ARGS);
}
#[no_mangle]
pub extern "C" fn TARGET_NAME_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- TEST_MSG!(msgs::MSG_TARGET, dataEXTRA_ARGS);
+ TEST_MSG!(MSG_TARGET, dataEXTRA_ARGS);
}
// 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_update_add_htlc_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::UpdateAddHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateAddHTLC, data);
}
#[no_mangle]
pub extern "C" fn msg_update_add_htlc_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::UpdateAddHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateAddHTLC, data);
}
// 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_update_fail_htlc_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::UpdateFailHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFailHTLC, data);
}
#[no_mangle]
pub extern "C" fn msg_update_fail_htlc_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::UpdateFailHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFailHTLC, data);
}
// 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_update_fail_malformed_htlc_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::UpdateFailMalformedHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFailMalformedHTLC, data);
}
#[no_mangle]
pub extern "C" fn msg_update_fail_malformed_htlc_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::UpdateFailMalformedHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFailMalformedHTLC, data);
}
// 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_update_fee_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::UpdateFee, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFee, data);
}
#[no_mangle]
pub extern "C" fn msg_update_fee_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::UpdateFee, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFee, data);
}
// 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_update_fulfill_htlc_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_simple!(msgs::UpdateFulfillHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFulfillHTLC, data);
}
#[no_mangle]
pub extern "C" fn msg_update_fulfill_htlc_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_simple!(msgs::UpdateFulfillHTLC, data);
+ test_msg_simple!(lightning::ln::msgs::UpdateFulfillHTLC, data);
}
// 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_warning_message_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
- test_msg_hole!(msgs::WarningMessage, data, 32, 2);
+ test_msg_hole!(lightning::ln::msgs::WarningMessage, data, 32, 2);
}
#[no_mangle]
pub extern "C" fn msg_warning_message_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
- test_msg_hole!(msgs::WarningMessage, data, 32, 2);
+ test_msg_hole!(lightning::ln::msgs::WarningMessage, data, 32, 2);
}
// Imports that need to be added manually
-use lightning::util::logger::Logger;
use lightning_rapid_gossip_sync::RapidGossipSync;
use utils::test_logger;
-use std::sync::Arc;
-
/// Actual fuzz test, method signature and name are fixed
fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
let block_hash = bitcoin::BlockHash::default();
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
use lightning::routing::scoring::FixedPenaltyScorer;
-use lightning::util::logger::Logger;
use lightning::util::ser::Readable;
use bitcoin::hashes::Hash;
void msg_onion_hop_data_run(const unsigned char* data, size_t data_len);
void msg_ping_run(const unsigned char* data, size_t data_len);
void msg_pong_run(const unsigned char* data, size_t data_len);
+void msg_channel_details_run(const unsigned char* data, size_t data_len);
#[allow(dead_code)]
// Messages of up to 64KB should never end up more than half full with addresses, as that would
- // be absurd. We ensure this by checking that at least 500 (our stated public contract on when
+ // be absurd. We ensure this by checking that at least 100 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
const HALF_MESSAGE_IS_ADDRS: u32 = ::core::u16::MAX as u32 / (NetAddress::MAX_LEN as u32 + 1) / 2;
#[deny(const_err)]
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
- // smaller than 500:
- const STATIC_ASSERT: u32 = Self::HALF_MESSAGE_IS_ADDRS - 500;
+ // smaller than 100:
+ const STATIC_ASSERT: u32 = Self::HALF_MESSAGE_IS_ADDRS - 100;
/// Regenerates channel_announcements and generates a signed node_announcement from the given
/// arguments, providing them in corresponding events via
/// tying these addresses together and to this node. If you wish to preserve user privacy,
/// addresses should likely contain only Tor Onion addresses.
///
- /// Panics if `addresses` is absurdly large (more than 500).
+ /// Panics if `addresses` is absurdly large (more than 100).
///
/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
pub fn broadcast_node_announcement(&self, rgb: [u8; 3], alias: [u8; 32], mut addresses: Vec<NetAddress>) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
- if addresses.len() > 500 {
+ if addresses.len() > 100 {
panic!("More than half the message size was taken up by public addresses!");
}
(18, outbound_capacity_msat, required),
// Note that by the time we get past the required read above, outbound_capacity_msat will be
// filled in, so we can safely unwrap it here.
- (19, next_outbound_htlc_limit_msat, (default_value, outbound_capacity_msat.0.unwrap())),
+ (19, next_outbound_htlc_limit_msat, (default_value, outbound_capacity_msat.0.unwrap() as u64)),
(20, inbound_capacity_msat, required),
(22, confirmations_required, option),
(24, force_close_spend_delay, option),
use util::events::MessageSendEventsProvider;
use util::logger;
-use util::ser::{Readable, Writeable, Writer, FixedLengthReader, HighZeroBytesDroppedVarInt};
+use util::ser::{Readable, Writeable, Writer, FixedLengthReader, HighZeroBytesDroppedVarInt, Hostname};
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
/// The port on which the node is listening
port: u16,
},
+ /// A hostname/port on which the peer is listening.
+ Hostname {
+ /// The hostname on which the node is listening.
+ hostname: Hostname,
+ /// The port on which the node is listening.
+ port: u16,
+ },
}
impl NetAddress {
/// Gets the ID of this address type. Addresses in node_announcement messages should be sorted
&NetAddress::IPv6 {..} => { 2 },
&NetAddress::OnionV2(_) => { 3 },
&NetAddress::OnionV3 {..} => { 4 },
+ &NetAddress::Hostname {..} => { 5 },
}
}
&NetAddress::IPv6 { .. } => { 18 },
&NetAddress::OnionV2(_) => { 12 },
&NetAddress::OnionV3 { .. } => { 37 },
+ // Consists of 1-byte hostname length, hostname bytes, and 2-byte port.
+ &NetAddress::Hostname { ref hostname, .. } => { u16::from(hostname.len()) + 3 },
}
}
- /// The maximum length of any address descriptor, not including the 1-byte type
- pub(crate) const MAX_LEN: u16 = 37;
+ /// The maximum length of any address descriptor, not including the 1-byte type.
+ /// This maximum length is reached by a hostname address descriptor:
+ /// a hostname with a maximum length of 255, its 1-byte length and a 2-byte port.
+ pub(crate) const MAX_LEN: u16 = 258;
}
impl Writeable for NetAddress {
checksum.write(writer)?;
version.write(writer)?;
port.write(writer)?;
- }
+ },
+ &NetAddress::Hostname { ref hostname, ref port } => {
+ 5u8.write(writer)?;
+ hostname.write(writer)?;
+ port.write(writer)?;
+ },
}
Ok(())
}
port: Readable::read(reader)?,
}))
},
+ 5 => {
+ Ok(Ok(NetAddress::Hostname {
+ hostname: Readable::read(reader)?,
+ port: Readable::read(reader)?,
+ }))
+ },
_ => return Ok(Err(byte)),
}
}
use ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
use ln::msgs;
use ln::msgs::{FinalOnionHopData, OptionalField, OnionErrorPacket, OnionHopDataFormat};
- use util::ser::{Writeable, Readable};
+ use util::ser::{Writeable, Readable, Hostname};
use bitcoin::hashes::hex::FromHex;
use bitcoin::util::address::Address;
use io::Cursor;
use prelude::*;
+ use core::convert::TryFrom;
#[test]
fn encoding_channel_reestablish_no_secret() {
do_encoding_channel_announcement(true, true);
}
- fn do_encoding_node_announcement(unknown_features_bits: bool, ipv4: bool, ipv6: bool, onionv2: bool, onionv3: bool, excess_address_data: bool, excess_data: bool) {
+ fn do_encoding_node_announcement(unknown_features_bits: bool, ipv4: bool, ipv6: bool, onionv2: bool, onionv3: bool, hostname: bool, excess_address_data: bool, excess_data: bool) {
let secp_ctx = Secp256k1::new();
let (privkey_1, pubkey_1) = get_keys_from!("0101010101010101010101010101010101010101010101010101010101010101", secp_ctx);
let sig_1 = get_sig_on!(privkey_1, secp_ctx, String::from("01010101010101010101010101010101"));
port: 9735
});
}
+ if hostname {
+ addresses.push(msgs::NetAddress::Hostname {
+ hostname: Hostname::try_from(String::from("host")).unwrap(),
+ port: 9735,
+ });
+ }
let mut addr_len = 0;
for addr in &addresses {
addr_len += addr.len() + 1;
if onionv3 {
target_value.append(&mut hex::decode("04fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e00020102607").unwrap());
}
+ if hostname {
+ target_value.append(&mut hex::decode("0504686f73742607").unwrap());
+ }
if excess_address_data {
target_value.append(&mut hex::decode("216c280b5395a2546e7e4b2663e04f811622f15a4f92e83aa2e92ba2a573c139142c54ae63072a1ec1ee7dc0c04bde5c847806172aa05c92c22ae8e308d1d269").unwrap());
}
#[test]
fn encoding_node_announcement() {
- do_encoding_node_announcement(true, true, true, true, true, true, true);
- do_encoding_node_announcement(false, false, false, false, false, false, false);
- do_encoding_node_announcement(false, true, false, false, false, false, false);
- do_encoding_node_announcement(false, false, true, false, false, false, false);
- do_encoding_node_announcement(false, false, false, true, false, false, false);
- do_encoding_node_announcement(false, false, false, false, true, false, false);
- do_encoding_node_announcement(false, false, false, false, false, true, false);
- do_encoding_node_announcement(false, true, false, true, false, true, false);
- do_encoding_node_announcement(false, false, true, false, true, false, false);
+ do_encoding_node_announcement(true, true, true, true, true, true, true, true);
+ do_encoding_node_announcement(false, false, false, false, false, false, false, false);
+ do_encoding_node_announcement(false, true, false, false, false, false, false, false);
+ do_encoding_node_announcement(false, false, true, false, false, false, false, false);
+ do_encoding_node_announcement(false, false, false, true, false, false, false, false);
+ do_encoding_node_announcement(false, false, false, false, true, false, false, false);
+ do_encoding_node_announcement(false, false, false, false, false, true, false, false);
+ do_encoding_node_announcement(false, false, false, false, false, false, true, false);
+ do_encoding_node_announcement(false, true, false, true, false, false, true, false);
+ do_encoding_node_announcement(false, false, true, false, true, false, false, false);
}
fn do_encoding_channel_update(direction: bool, disable: bool, htlc_maximum_msat: bool, excess_data: bool) {
let mut forwarding_fee_base_msat = 0;
read_tlv_fields!(reader, {
(0, forwarding_fee_proportional_millionths, required),
- (1, max_dust_htlc_exposure_msat, (default_value, 5_000_000)),
+ (1, max_dust_htlc_exposure_msat, (default_value, 5_000_000u64)),
(2, cltv_expiry_delta, required),
- (3, force_close_avoidance_max_fee_satoshis, (default_value, 1000)),
+ (3, force_close_avoidance_max_fee_satoshis, (default_value, 1000u64)),
(4, announced_channel, required),
(6, commit_upfront_shutdown_pubkey, required),
(8, forwarding_fee_base_msat, required),
use core::hash::Hash;
use sync::Mutex;
use core::cmp;
+use core::convert::TryFrom;
+use core::ops::Deref;
use bitcoin::secp256k1::{PublicKey, SecretKey};
use bitcoin::secp256k1::constants::{PUBLIC_KEY_SIZE, SECRET_KEY_SIZE, COMPACT_SIGNATURE_SIZE};
Ok(Self(Some(Readable::read(reader)?)))
}
}
+/// When handling default_values, we want to map the default-value T directly
+/// to a OptionDeserWrapper<T> in a way that works for `field: T = t;` as
+/// well. Thus, we assume `Into<T> for T` does nothing and use that.
+impl<T: Readable> From<T> for OptionDeserWrapper<T> {
+ fn from(t: T) -> OptionDeserWrapper<T> { OptionDeserWrapper(Some(t)) }
+}
/// Wrapper to write each element of a Vec with no length prefix
pub(crate) struct VecWriteWrapper<'a, T: Writeable>(pub &'a Vec<T>);
}
}
+/// Represents a hostname for serialization purposes.
+/// Only the character set and length will be validated.
+/// The character set consists of ASCII alphanumeric characters, hyphens, and periods.
+/// Its length is guaranteed to be representable by a single byte.
+/// This serialization is used by BOLT 7 hostnames.
+#[derive(Clone, Debug, PartialEq)]
+pub struct Hostname(String);
+impl Hostname {
+ /// Returns the length of the hostname.
+ pub fn len(&self) -> u8 {
+ (&self.0).len() as u8
+ }
+}
+impl Deref for Hostname {
+ type Target = String;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+impl From<Hostname> for String {
+ fn from(hostname: Hostname) -> Self {
+ hostname.0
+ }
+}
+impl TryFrom<Vec<u8>> for Hostname {
+ type Error = ();
+
+ fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
+ if let Ok(s) = String::from_utf8(bytes) {
+ Hostname::try_from(s)
+ } else {
+ Err(())
+ }
+ }
+}
+impl TryFrom<String> for Hostname {
+ type Error = ();
+
+ fn try_from(s: String) -> Result<Self, Self::Error> {
+ if s.len() <= 255 && s.chars().all(|c|
+ c.is_ascii_alphanumeric() ||
+ c == '.' ||
+ c == '-'
+ ) {
+ Ok(Hostname(s))
+ } else {
+ Err(())
+ }
+ }
+}
+impl Writeable for Hostname {
+ #[inline]
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ self.len().write(w)?;
+ w.write_all(self.as_bytes())
+ }
+}
+impl Readable for Hostname {
+ #[inline]
+ fn read<R: Read>(r: &mut R) -> Result<Hostname, DecodeError> {
+ let len: u8 = Readable::read(r)?;
+ let mut vec = Vec::with_capacity(len.into());
+ vec.resize(len.into(), 0);
+ r.read_exact(&mut vec)?;
+ Hostname::try_from(vec).map_err(|_| DecodeError::InvalidValue)
+ }
+}
+
impl Writeable for Duration {
#[inline]
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
Ok(Duration::new(secs, nanos))
}
}
+
+#[cfg(test)]
+mod tests {
+ use core::convert::TryFrom;
+ use util::ser::{Readable, Hostname, Writeable};
+
+ #[test]
+ fn hostname_conversion() {
+ assert_eq!(Hostname::try_from(String::from("a-test.com")).unwrap().as_str(), "a-test.com");
+
+ assert!(Hostname::try_from(String::from("\"")).is_err());
+ assert!(Hostname::try_from(String::from("$")).is_err());
+ assert!(Hostname::try_from(String::from("⚡")).is_err());
+ let mut large_vec = Vec::with_capacity(256);
+ large_vec.resize(256, b'A');
+ assert!(Hostname::try_from(String::from_utf8(large_vec).unwrap()).is_err());
+ }
+
+ #[test]
+ fn hostname_serialization() {
+ let hostname = Hostname::try_from(String::from("test")).unwrap();
+ let mut buf: Vec<u8> = Vec::new();
+ hostname.write(&mut buf).unwrap();
+ assert_eq!(Hostname::read(&mut buf.as_slice()).unwrap().as_str(), "test");
+ }
+}
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
if invalid_order {
- $field = $default;
+ $field = $default.into();
}
}};
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, required) => {{
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
if missing_req_type {
- $field = $default;
+ $field = $default.into();
}
}};
($last_seen_type: expr, $type: expr, $field: ident, required) => {{
macro_rules! init_tlv_based_struct_field {
($field: ident, (default_value, $default: expr)) => {
- $field
+ $field.0.unwrap()
};
($field: ident, option) => {
$field
macro_rules! init_tlv_field_var {
($field: ident, (default_value, $default: expr)) => {
- let mut $field = $default;
+ let mut $field = ::util::ser::OptionDeserWrapper(None);
};
($field: ident, required) => {
let mut $field = ::util::ser::OptionDeserWrapper(None);