From: Matt Corallo Date: Sat, 4 Sep 2021 06:37:36 +0000 (+0000) Subject: [fuzz] Swap mode on most messages to account for TLV suffix X-Git-Tag: v0.0.101~14^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=7f9eef553c89bef4e5aaf369ad02cfff4e0f9048;p=rust-lightning [fuzz] Swap mode on most messages to account for TLV suffix --- diff --git a/fuzz/src/msg_targets/gen_target.sh b/fuzz/src/msg_targets/gen_target.sh index 0c1d061a7..2e1334841 100755 --- a/fuzz/src/msg_targets/gen_target.sh +++ b/fuzz/src/msg_targets/gen_target.sh @@ -11,36 +11,36 @@ echo "mod utils;" > 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 "" -GEN_TEST AnnouncementSignatures test_msg "" +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 FundingLocked 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 CommitmentSigned test_msg "" GEN_TEST DecodedOnionErrorPacket test_msg "" -GEN_TEST FundingCreated test_msg "" -GEN_TEST FundingLocked test_msg "" -GEN_TEST FundingSigned test_msg "" -GEN_TEST OpenChannel test_msg "" -GEN_TEST RevokeAndACK test_msg "" -GEN_TEST Shutdown test_msg "" -GEN_TEST UpdateFailHTLC test_msg "" -GEN_TEST UpdateFailMalformedHTLC test_msg "" -GEN_TEST UpdateFee test_msg "" -GEN_TEST UpdateFulfillHTLC test_msg "" 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" GEN_TEST ChannelUpdate test_msg_hole ", 108, 1" - -GEN_TEST ClosingSigned test_msg_simple "" -GEN_TEST Init test_msg_simple "" -GEN_TEST OnionHopData test_msg_simple "" -GEN_TEST Ping test_msg_simple "" -GEN_TEST Pong test_msg_simple "" diff --git a/fuzz/src/msg_targets/mod.rs b/fuzz/src/msg_targets/mod.rs index 0f273cb76..af70c58e3 100644 --- a/fuzz/src/msg_targets/mod.rs +++ b/fuzz/src/msg_targets/mod.rs @@ -1,31 +1,31 @@ mod utils; pub mod msg_accept_channel; pub mod msg_announcement_signatures; -pub mod msg_channel_reestablish; +pub mod msg_closing_signed; pub mod msg_commitment_signed; -pub mod msg_decoded_onion_error_packet; pub mod msg_funding_created; pub mod msg_funding_locked; pub mod msg_funding_signed; +pub mod msg_gossip_timestamp_filter; +pub mod msg_init; +pub mod msg_onion_hop_data; pub mod msg_open_channel; +pub mod msg_ping; +pub mod msg_pong; +pub mod msg_query_channel_range; +pub mod msg_reply_short_channel_ids_end; pub mod msg_revoke_and_ack; pub mod msg_shutdown; +pub mod msg_update_add_htlc; pub mod msg_update_fail_htlc; pub mod msg_update_fail_malformed_htlc; pub mod msg_update_fee; pub mod msg_update_fulfill_htlc; +pub mod msg_channel_reestablish; +pub mod msg_decoded_onion_error_packet; 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; -pub mod msg_closing_signed; -pub mod msg_init; -pub mod msg_onion_hop_data; -pub mod msg_ping; -pub mod msg_pong; diff --git a/fuzz/src/msg_targets/msg_accept_channel.rs b/fuzz/src/msg_targets/msg_accept_channel.rs index 095556d57..a8ec43878 100644 --- a/fuzz/src/msg_targets/msg_accept_channel.rs +++ b/fuzz/src/msg_targets/msg_accept_channel.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_accept_channel_test(data: &[u8], _out: Out) { - test_msg!(msgs::AcceptChannel, data); + test_msg_simple!(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!(msgs::AcceptChannel, data); + test_msg_simple!(msgs::AcceptChannel, data); } diff --git a/fuzz/src/msg_targets/msg_announcement_signatures.rs b/fuzz/src/msg_targets/msg_announcement_signatures.rs index 138ab5dbf..0fc40fcb6 100644 --- a/fuzz/src/msg_targets/msg_announcement_signatures.rs +++ b/fuzz/src/msg_targets/msg_announcement_signatures.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_announcement_signatures_test(data: &[u8], _out: Out) { - test_msg!(msgs::AnnouncementSignatures, data); + test_msg_simple!(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!(msgs::AnnouncementSignatures, data); + test_msg_simple!(msgs::AnnouncementSignatures, data); } diff --git a/fuzz/src/msg_targets/msg_commitment_signed.rs b/fuzz/src/msg_targets/msg_commitment_signed.rs index 9ac846f6f..163ce7446 100644 --- a/fuzz/src/msg_targets/msg_commitment_signed.rs +++ b/fuzz/src/msg_targets/msg_commitment_signed.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_commitment_signed_test(data: &[u8], _out: Out) { - test_msg!(msgs::CommitmentSigned, data); + test_msg_simple!(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!(msgs::CommitmentSigned, data); + test_msg_simple!(msgs::CommitmentSigned, data); } diff --git a/fuzz/src/msg_targets/msg_funding_created.rs b/fuzz/src/msg_targets/msg_funding_created.rs index 3b61a64bf..e0005cb08 100644 --- a/fuzz/src/msg_targets/msg_funding_created.rs +++ b/fuzz/src/msg_targets/msg_funding_created.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_funding_created_test(data: &[u8], _out: Out) { - test_msg!(msgs::FundingCreated, data); + test_msg_simple!(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!(msgs::FundingCreated, data); + test_msg_simple!(msgs::FundingCreated, data); } diff --git a/fuzz/src/msg_targets/msg_funding_locked.rs b/fuzz/src/msg_targets/msg_funding_locked.rs index 677af7318..2c6ad63c9 100644 --- a/fuzz/src/msg_targets/msg_funding_locked.rs +++ b/fuzz/src/msg_targets/msg_funding_locked.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_funding_locked_test(data: &[u8], _out: Out) { - test_msg!(msgs::FundingLocked, data); + test_msg_simple!(msgs::FundingLocked, data); } #[no_mangle] pub extern "C" fn msg_funding_locked_run(data: *const u8, datalen: usize) { let data = unsafe { std::slice::from_raw_parts(data, datalen) }; - test_msg!(msgs::FundingLocked, data); + test_msg_simple!(msgs::FundingLocked, data); } diff --git a/fuzz/src/msg_targets/msg_funding_signed.rs b/fuzz/src/msg_targets/msg_funding_signed.rs index 388738ff2..f0586e7b2 100644 --- a/fuzz/src/msg_targets/msg_funding_signed.rs +++ b/fuzz/src/msg_targets/msg_funding_signed.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_funding_signed_test(data: &[u8], _out: Out) { - test_msg!(msgs::FundingSigned, data); + test_msg_simple!(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!(msgs::FundingSigned, data); + test_msg_simple!(msgs::FundingSigned, data); } diff --git a/fuzz/src/msg_targets/msg_gossip_timestamp_filter.rs b/fuzz/src/msg_targets/msg_gossip_timestamp_filter.rs index 73999cd3a..448aaffc9 100644 --- a/fuzz/src/msg_targets/msg_gossip_timestamp_filter.rs +++ b/fuzz/src/msg_targets/msg_gossip_timestamp_filter.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_gossip_timestamp_filter_test(data: &[u8], _out: Out) { - test_msg!(msgs::GossipTimestampFilter, data); + test_msg_simple!(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); + test_msg_simple!(msgs::GossipTimestampFilter, data); } diff --git a/fuzz/src/msg_targets/msg_open_channel.rs b/fuzz/src/msg_targets/msg_open_channel.rs index b0e96734e..ce637c167 100644 --- a/fuzz/src/msg_targets/msg_open_channel.rs +++ b/fuzz/src/msg_targets/msg_open_channel.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_open_channel_test(data: &[u8], _out: Out) { - test_msg!(msgs::OpenChannel, data); + test_msg_simple!(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!(msgs::OpenChannel, data); + test_msg_simple!(msgs::OpenChannel, data); } diff --git a/fuzz/src/msg_targets/msg_query_channel_range.rs b/fuzz/src/msg_targets/msg_query_channel_range.rs index bd16147f6..4b3de6aa8 100644 --- a/fuzz/src/msg_targets/msg_query_channel_range.rs +++ b/fuzz/src/msg_targets/msg_query_channel_range.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_query_channel_range_test(data: &[u8], _out: Out) { - test_msg!(msgs::QueryChannelRange, data); + test_msg_simple!(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); + test_msg_simple!(msgs::QueryChannelRange, data); } diff --git a/fuzz/src/msg_targets/msg_reply_short_channel_ids_end.rs b/fuzz/src/msg_targets/msg_reply_short_channel_ids_end.rs index fcd131543..7634329a4 100644 --- a/fuzz/src/msg_targets/msg_reply_short_channel_ids_end.rs +++ b/fuzz/src/msg_targets/msg_reply_short_channel_ids_end.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_reply_short_channel_ids_end_test(data: &[u8], _out: Out) { - test_msg!(msgs::ReplyShortChannelIdsEnd, data); + test_msg_simple!(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); + test_msg_simple!(msgs::ReplyShortChannelIdsEnd, data); } diff --git a/fuzz/src/msg_targets/msg_revoke_and_ack.rs b/fuzz/src/msg_targets/msg_revoke_and_ack.rs index 41f40becd..873939ca7 100644 --- a/fuzz/src/msg_targets/msg_revoke_and_ack.rs +++ b/fuzz/src/msg_targets/msg_revoke_and_ack.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_revoke_and_ack_test(data: &[u8], _out: Out) { - test_msg!(msgs::RevokeAndACK, data); + test_msg_simple!(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!(msgs::RevokeAndACK, data); + test_msg_simple!(msgs::RevokeAndACK, data); } diff --git a/fuzz/src/msg_targets/msg_shutdown.rs b/fuzz/src/msg_targets/msg_shutdown.rs index 3e5358205..e6e74cc66 100644 --- a/fuzz/src/msg_targets/msg_shutdown.rs +++ b/fuzz/src/msg_targets/msg_shutdown.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_shutdown_test(data: &[u8], _out: Out) { - test_msg!(msgs::Shutdown, data); + test_msg_simple!(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!(msgs::Shutdown, data); + test_msg_simple!(msgs::Shutdown, data); } diff --git a/fuzz/src/msg_targets/msg_update_add_htlc.rs b/fuzz/src/msg_targets/msg_update_add_htlc.rs index d45eeadb1..409f0fac8 100644 --- a/fuzz/src/msg_targets/msg_update_add_htlc.rs +++ b/fuzz/src/msg_targets/msg_update_add_htlc.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_update_add_htlc_test(data: &[u8], _out: Out) { - test_msg_hole!(msgs::UpdateAddHTLC, data, 85, 33); + test_msg_simple!(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_hole!(msgs::UpdateAddHTLC, data, 85, 33); + test_msg_simple!(msgs::UpdateAddHTLC, data); } diff --git a/fuzz/src/msg_targets/msg_update_fail_htlc.rs b/fuzz/src/msg_targets/msg_update_fail_htlc.rs index 8fadde210..12d3f1c3f 100644 --- a/fuzz/src/msg_targets/msg_update_fail_htlc.rs +++ b/fuzz/src/msg_targets/msg_update_fail_htlc.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_update_fail_htlc_test(data: &[u8], _out: Out) { - test_msg!(msgs::UpdateFailHTLC, data); + test_msg_simple!(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!(msgs::UpdateFailHTLC, data); + test_msg_simple!(msgs::UpdateFailHTLC, data); } diff --git a/fuzz/src/msg_targets/msg_update_fail_malformed_htlc.rs b/fuzz/src/msg_targets/msg_update_fail_malformed_htlc.rs index 9d0481481..0b36070d1 100644 --- a/fuzz/src/msg_targets/msg_update_fail_malformed_htlc.rs +++ b/fuzz/src/msg_targets/msg_update_fail_malformed_htlc.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_update_fail_malformed_htlc_test(data: &[u8], _out: Out) { - test_msg!(msgs::UpdateFailMalformedHTLC, data); + test_msg_simple!(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!(msgs::UpdateFailMalformedHTLC, data); + test_msg_simple!(msgs::UpdateFailMalformedHTLC, data); } diff --git a/fuzz/src/msg_targets/msg_update_fee.rs b/fuzz/src/msg_targets/msg_update_fee.rs index 318f5b089..3c23a902f 100644 --- a/fuzz/src/msg_targets/msg_update_fee.rs +++ b/fuzz/src/msg_targets/msg_update_fee.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_update_fee_test(data: &[u8], _out: Out) { - test_msg!(msgs::UpdateFee, data); + test_msg_simple!(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!(msgs::UpdateFee, data); + test_msg_simple!(msgs::UpdateFee, data); } diff --git a/fuzz/src/msg_targets/msg_update_fulfill_htlc.rs b/fuzz/src/msg_targets/msg_update_fulfill_htlc.rs index 692cb972f..460ff0e16 100644 --- a/fuzz/src/msg_targets/msg_update_fulfill_htlc.rs +++ b/fuzz/src/msg_targets/msg_update_fulfill_htlc.rs @@ -17,11 +17,11 @@ use utils::test_logger; #[inline] pub fn msg_update_fulfill_htlc_test(data: &[u8], _out: Out) { - test_msg!(msgs::UpdateFulfillHTLC, data); + test_msg_simple!(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!(msgs::UpdateFulfillHTLC, data); + test_msg_simple!(msgs::UpdateFulfillHTLC, data); }