Skip to content

Commit 8e8dcb4

Browse files
committed
fuzz: remove afl support, run clippy and fmt on fuzz targets
1 parent 14ceccd commit 8e8dcb4

8 files changed

+21
-140
lines changed

fuzz/fuzz_targets/compile_descriptor.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
extern crate miniscript;
2-
31
use std::str::FromStr;
42

3+
use honggfuzz::fuzz;
54
use miniscript::{policy, Miniscript, Segwitv0};
65
use policy::Liftable;
76

@@ -14,10 +13,7 @@ fn do_test(data: &[u8]) {
1413
// Compile
1514
if let Ok(desc) = pol.compile::<Segwitv0>() {
1615
// Lift
17-
assert_eq!(
18-
desc.clone().lift().unwrap().sorted(),
19-
pol.clone().lift().unwrap().sorted()
20-
);
16+
assert_eq!(desc.lift().unwrap().sorted(), pol.lift().unwrap().sorted());
2117
// Try to roundtrip the output of the compiler
2218
let output = desc.to_string();
2319
if let Ok(desc) = Script::from_str(&output) {
@@ -30,19 +26,6 @@ fn do_test(data: &[u8]) {
3026
}
3127
}
3228

33-
#[cfg(feature = "afl")]
34-
extern crate afl;
35-
#[cfg(feature = "afl")]
36-
fn main() {
37-
afl::read_stdio_bytes(|data| {
38-
do_test(&data);
39-
});
40-
}
41-
42-
#[cfg(feature = "honggfuzz")]
43-
#[macro_use]
44-
extern crate honggfuzz;
45-
#[cfg(feature = "honggfuzz")]
4629
fn main() {
4730
loop {
4831
fuzz!(|data| {

fuzz/fuzz_targets/parse_descriptor.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
extern crate miniscript;
2-
31
use std::str::FromStr;
42

3+
use honggfuzz::fuzz;
54
use miniscript::DescriptorPublicKey;
65

76
fn do_test(data: &[u8]) {
87
let data_str = String::from_utf8_lossy(data);
98
if let Ok(dpk) = DescriptorPublicKey::from_str(&data_str) {
10-
let output = dpk.to_string();
11-
// assert_eq!(data_str.to_lowercase(), output.to_lowercase());
9+
let _output = dpk.to_string();
10+
// assert_eq!(data_str.to_lowercase(), _output.to_lowercase());
1211
}
1312
}
1413

15-
#[cfg(feature = "afl")]
16-
extern crate afl;
17-
#[cfg(feature = "afl")]
18-
fn main() {
19-
afl::read_stdio_bytes(|data| {
20-
do_test(&data);
21-
});
22-
}
23-
24-
#[cfg(feature = "honggfuzz")]
25-
#[macro_use]
26-
extern crate honggfuzz;
27-
#[cfg(feature = "honggfuzz")]
2814
fn main() {
2915
loop {
3016
fuzz!(|data| {

fuzz/fuzz_targets/parse_descriptor_secret.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
extern crate miniscript;
2-
31
use std::str::FromStr;
42

3+
use honggfuzz::fuzz;
54
use miniscript::descriptor::DescriptorSecretKey;
65

76
fn do_test(data: &[u8]) {
@@ -12,19 +11,6 @@ fn do_test(data: &[u8]) {
1211
}
1312
}
1413

15-
#[cfg(feature = "afl")]
16-
extern crate afl;
17-
#[cfg(feature = "afl")]
18-
fn main() {
19-
afl::read_stdio_bytes(|data| {
20-
do_test(&data);
21-
});
22-
}
23-
24-
#[cfg(feature = "honggfuzz")]
25-
#[macro_use]
26-
extern crate honggfuzz;
27-
#[cfg(feature = "honggfuzz")]
2814
fn main() {
2915
loop {
3016
fuzz!(|data| {

fuzz/fuzz_targets/roundtrip_concrete.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
extern crate miniscript;
2-
extern crate regex;
31
use std::str::FromStr;
42

3+
use honggfuzz::fuzz;
54
use miniscript::policy;
65
use regex::Regex;
76

@@ -19,19 +18,6 @@ fn do_test(data: &[u8]) {
1918
}
2019
}
2120

22-
#[cfg(feature = "afl")]
23-
extern crate afl;
24-
#[cfg(feature = "afl")]
25-
fn main() {
26-
afl::read_stdio_bytes(|data| {
27-
do_test(&data);
28-
});
29-
}
30-
31-
#[cfg(feature = "honggfuzz")]
32-
#[macro_use]
33-
extern crate honggfuzz;
34-
#[cfg(feature = "honggfuzz")]
3521
fn main() {
3622
loop {
3723
fuzz!(|data| {
@@ -47,9 +33,9 @@ mod tests {
4733
for (idx, c) in hex.as_bytes().iter().enumerate() {
4834
b <<= 4;
4935
match *c {
50-
b'A'...b'F' => b |= c - b'A' + 10,
51-
b'a'...b'f' => b |= c - b'a' + 10,
52-
b'0'...b'9' => b |= c - b'0',
36+
b'A'..=b'F' => b |= c - b'A' + 10,
37+
b'a'..=b'f' => b |= c - b'a' + 10,
38+
b'0'..=b'9' => b |= c - b'0',
5339
_ => panic!("Bad hex"),
5440
}
5541
if (idx & 1) == 1 {

fuzz/fuzz_targets/roundtrip_descriptor.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
extern crate miniscript;
2-
extern crate regex;
3-
41
use std::str::FromStr;
52

3+
use honggfuzz::fuzz;
64
use miniscript::Descriptor;
7-
use regex::Regex;
85

96
fn do_test(data: &[u8]) {
107
let s = String::from_utf8_lossy(data);
@@ -16,19 +13,6 @@ fn do_test(data: &[u8]) {
1613
}
1714
}
1815

19-
#[cfg(feature = "afl")]
20-
extern crate afl;
21-
#[cfg(feature = "afl")]
22-
fn main() {
23-
afl::read_stdio_bytes(|data| {
24-
do_test(&data);
25-
});
26-
}
27-
28-
#[cfg(feature = "honggfuzz")]
29-
#[macro_use]
30-
extern crate honggfuzz;
31-
#[cfg(feature = "honggfuzz")]
3216
fn main() {
3317
loop {
3418
fuzz!(|data| {

fuzz/fuzz_targets/roundtrip_miniscript_script.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
1-
extern crate miniscript;
2-
1+
use honggfuzz::fuzz;
32
use miniscript::bitcoin::blockdata::script;
43
use miniscript::{Miniscript, Segwitv0};
54

65
fn do_test(data: &[u8]) {
76
// Try round-tripping as a script
87
let script = script::Script::from_bytes(data);
98

10-
if let Ok(pt) = Miniscript::<miniscript::bitcoin::PublicKey, Segwitv0>::parse(&script) {
9+
if let Ok(pt) = Miniscript::<miniscript::bitcoin::PublicKey, Segwitv0>::parse(script) {
1110
let output = pt.encode();
1211
assert_eq!(pt.script_size(), output.len());
1312
assert_eq!(&output, script);
1413
}
1514
}
1615

17-
#[cfg(feature = "afl")]
18-
extern crate afl;
19-
#[cfg(feature = "afl")]
20-
fn main() {
21-
afl::read_stdio_bytes(|data| {
22-
do_test(&data);
23-
});
24-
}
25-
26-
#[cfg(feature = "honggfuzz")]
27-
#[macro_use]
28-
extern crate honggfuzz;
29-
#[cfg(feature = "honggfuzz")]
3016
fn main() {
3117
loop {
3218
fuzz!(|data| {
@@ -42,9 +28,9 @@ mod tests {
4228
for (idx, c) in hex.as_bytes().iter().enumerate() {
4329
b <<= 4;
4430
match *c {
45-
b'A'...b'F' => b |= c - b'A' + 10,
46-
b'a'...b'f' => b |= c - b'a' + 10,
47-
b'0'...b'9' => b |= c - b'0',
31+
b'A'..=b'F' => b |= c - b'A' + 10,
32+
b'a'..=b'f' => b |= c - b'a' + 10,
33+
b'0'..=b'9' => b |= c - b'0',
4834
_ => panic!("Bad hex"),
4935
}
5036
if (idx & 1) == 1 {

fuzz/fuzz_targets/roundtrip_miniscript_str.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
extern crate miniscript;
2-
extern crate regex;
3-
41
use std::str::FromStr;
52

3+
use honggfuzz::fuzz;
64
use miniscript::{Miniscript, Segwitv0};
7-
use regex::Regex;
85

96
fn do_test(data: &[u8]) {
107
let s = String::from_utf8_lossy(data);
@@ -16,19 +13,6 @@ fn do_test(data: &[u8]) {
1613
}
1714
}
1815

19-
#[cfg(feature = "afl")]
20-
extern crate afl;
21-
#[cfg(feature = "afl")]
22-
fn main() {
23-
afl::read_stdio_bytes(|data| {
24-
do_test(&data);
25-
});
26-
}
27-
28-
#[cfg(feature = "honggfuzz")]
29-
#[macro_use]
30-
extern crate honggfuzz;
31-
#[cfg(feature = "honggfuzz")]
3216
fn main() {
3317
loop {
3418
fuzz!(|data| {
@@ -44,9 +28,9 @@ mod tests {
4428
for (idx, c) in hex.as_bytes().iter().enumerate() {
4529
b <<= 4;
4630
match *c {
47-
b'A'...b'F' => b |= c - b'A' + 10,
48-
b'a'...b'f' => b |= c - b'a' + 10,
49-
b'0'...b'9' => b |= c - b'0',
31+
b'A'..=b'F' => b |= c - b'A' + 10,
32+
b'a'..=b'f' => b |= c - b'a' + 10,
33+
b'0'..=b'9' => b |= c - b'0',
5034
_ => panic!("Bad hex"),
5135
}
5236
if (idx & 1) == 1 {

fuzz/fuzz_targets/roundtrip_semantic.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
extern crate miniscript;
2-
31
use std::str::FromStr;
42

3+
use honggfuzz::fuzz;
54
use miniscript::policy;
65

76
type Policy = policy::Semantic<String>;
@@ -14,19 +13,6 @@ fn do_test(data: &[u8]) {
1413
}
1514
}
1615

17-
#[cfg(feature = "afl")]
18-
extern crate afl;
19-
#[cfg(feature = "afl")]
20-
fn main() {
21-
afl::read_stdio_bytes(|data| {
22-
do_test(&data);
23-
});
24-
}
25-
26-
#[cfg(feature = "honggfuzz")]
27-
#[macro_use]
28-
extern crate honggfuzz;
29-
#[cfg(feature = "honggfuzz")]
3016
fn main() {
3117
loop {
3218
fuzz!(|data| {

0 commit comments

Comments
 (0)