Skip to content

Commit f638d1d

Browse files
Update fuzzing generated code to conform to rustfmt.
1 parent aca2378 commit f638d1d

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

fuzz/src/bin/target_template.txt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ extern crate lightning_fuzz;
77
use lightning_fuzz::TARGET_MOD::*;
88

99
#[cfg(feature = "afl")]
10-
#[macro_use] extern crate afl;
10+
#[macro_use]
11+
extern crate afl;
1112
#[cfg(feature = "afl")]
1213
fn main() {
1314
fuzz!(|data| {
@@ -16,7 +17,8 @@ fn main() {
1617
}
1718

1819
#[cfg(feature = "honggfuzz")]
19-
#[macro_use] extern crate honggfuzz;
20+
#[macro_use]
21+
extern crate honggfuzz;
2022
#[cfg(feature = "honggfuzz")]
2123
fn main() {
2224
loop {
@@ -27,7 +29,8 @@ fn main() {
2729
}
2830

2931
#[cfg(feature = "libfuzzer_fuzz")]
30-
#[macro_use] extern crate libfuzzer_sys;
32+
#[macro_use]
33+
extern crate libfuzzer_sys;
3134
#[cfg(feature = "libfuzzer_fuzz")]
3235
fuzz_target!(|data: &[u8]| {
3336
TARGET_NAME_run(data.as_ptr(), data.len());
@@ -44,9 +47,9 @@ fn main() {
4447

4548
#[test]
4649
fn run_test_cases() {
50+
use lightning_fuzz::utils::test_logger::StringBuffer;
4751
use std::fs;
4852
use std::io::Read;
49-
use lightning_fuzz::utils::test_logger::StringBuffer;
5053

5154
use std::sync::{atomic, Arc};
5255
{
@@ -64,20 +67,25 @@ fn run_test_cases() {
6467

6568
let thread_count_ref = Arc::clone(&threads_running);
6669
let main_thread_ref = std::thread::current();
67-
threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
70+
threads.push((
71+
path.file_name().unwrap().to_str().unwrap().to_string(),
6872
std::thread::spawn(move || {
6973
let string_logger = StringBuffer::new();
7074

7175
let panic_logger = string_logger.clone();
7276
let res = if ::std::panic::catch_unwind(move || {
7377
TARGET_NAME_test(&data, panic_logger);
74-
}).is_err() {
78+
})
79+
.is_err()
80+
{
7581
Some(string_logger.into_string())
76-
} else { None };
82+
} else {
83+
None
84+
};
7785
thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
7886
main_thread_ref.unpark();
7987
res
80-
})
88+
}),
8189
));
8290
while threads_running.load(atomic::Ordering::Acquire) > 32 {
8391
std::thread::park();

fuzz/src/msg_targets/gen_target.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,33 @@ GEN_TEST() {
77
echo "pub mod $tn;" >> mod.rs
88
}
99

10-
echo "mod utils;" > mod.rs
10+
echo "mod utils;
11+
" > mod.rs
1112

1213
# Note when adding new targets here you should add a similar line in src/bin/gen_target.sh
1314

1415
GEN_TEST AcceptChannel test_msg ""
1516
GEN_TEST AnnouncementSignatures test_msg ""
17+
GEN_TEST ChannelAnnouncement test_msg_exact ""
1618
GEN_TEST ChannelReestablish test_msg ""
19+
GEN_TEST ChannelUpdate test_msg_exact ""
1720
GEN_TEST ClosingSigned test_msg ""
1821
GEN_TEST CommitmentSigned test_msg ""
1922
GEN_TEST DecodedOnionErrorPacket test_msg ""
23+
GEN_TEST ErrorMessage test_msg_hole ", 32, 2"
2024
GEN_TEST FundingCreated test_msg ""
2125
GEN_TEST FundingLocked test_msg ""
2226
GEN_TEST FundingSigned test_msg ""
27+
GEN_TEST Init test_msg_simple ""
28+
GEN_TEST NodeAnnouncement test_msg_exact ""
29+
GEN_TEST OnionHopData test_msg_simple ""
2330
GEN_TEST OpenChannel test_msg ""
31+
GEN_TEST Ping test_msg_simple ""
32+
GEN_TEST Pong test_msg_simple ""
2433
GEN_TEST RevokeAndACK test_msg ""
2534
GEN_TEST Shutdown test_msg ""
35+
GEN_TEST UpdateAddHTLC test_msg_hole ", 85, 33"
2636
GEN_TEST UpdateFailHTLC test_msg ""
2737
GEN_TEST UpdateFailMalformedHTLC test_msg ""
2838
GEN_TEST UpdateFee test_msg ""
2939
GEN_TEST UpdateFulfillHTLC test_msg ""
30-
31-
GEN_TEST ChannelAnnouncement test_msg_exact ""
32-
GEN_TEST ChannelUpdate test_msg_exact ""
33-
GEN_TEST NodeAnnouncement test_msg_exact ""
34-
35-
GEN_TEST UpdateAddHTLC test_msg_hole ", 85, 33"
36-
GEN_TEST ErrorMessage test_msg_hole ", 32, 2"
37-
38-
GEN_TEST Init test_msg_simple ""
39-
GEN_TEST OnionHopData test_msg_simple ""
40-
GEN_TEST Ping test_msg_simple ""
41-
GEN_TEST Pong test_msg_simple ""

fuzz/src/msg_targets/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
mod utils;
2+
23
pub mod msg_accept_channel;
34
pub mod msg_announcement_signatures;
5+
pub mod msg_channel_announcement;
46
pub mod msg_channel_reestablish;
7+
pub mod msg_channel_update;
58
pub mod msg_closing_signed;
69
pub mod msg_commitment_signed;
710
pub mod msg_decoded_onion_error_packet;
11+
pub mod msg_error_message;
812
pub mod msg_funding_created;
913
pub mod msg_funding_locked;
1014
pub mod msg_funding_signed;
15+
pub mod msg_init;
16+
pub mod msg_node_announcement;
17+
pub mod msg_onion_hop_data;
1118
pub mod msg_open_channel;
19+
pub mod msg_ping;
20+
pub mod msg_pong;
1221
pub mod msg_revoke_and_ack;
1322
pub mod msg_shutdown;
23+
pub mod msg_update_add_htlc;
1424
pub mod msg_update_fail_htlc;
1525
pub mod msg_update_fail_malformed_htlc;
1626
pub mod msg_update_fee;
1727
pub mod msg_update_fulfill_htlc;
18-
pub mod msg_channel_announcement;
19-
pub mod msg_channel_update;
20-
pub mod msg_node_announcement;
21-
pub mod msg_update_add_htlc;
22-
pub mod msg_error_message;
23-
pub mod msg_init;
24-
pub mod msg_onion_hop_data;
25-
pub mod msg_ping;
26-
pub mod msg_pong;

0 commit comments

Comments
 (0)