···
1
1
#![no_main]
2
2
3
3
-
use jetstream::exports::Did;
4
4
-
use bincode::config::{Configuration, BigEndian, Fixint, Limit, standard};
3
3
+
use bincode::config::{Configuration, LittleEndian, Varint, Limit, standard};
5
4
use bincode::serde::decode_from_slice;
6
5
use cardinality_estimator::CardinalityEstimator;
7
6
use libfuzzer_sys::fuzz_target;
8
7
9
9
-
#[cfg(not(target_env = "msvc"))]
10
10
-
use tikv_jemallocator::Jemalloc;
11
11
-
12
12
-
#[cfg(not(target_env = "msvc"))]
13
13
-
#[global_allocator]
14
14
-
static GLOBAL: Jemalloc = Jemalloc;
15
15
-
16
16
-
type C = Configuration<BigEndian, Fixint, Limit<1048576>>;
17
17
-
static BINCODE_CONF: C =
18
18
-
standard()
19
19
-
.with_big_endian()
20
20
-
.with_fixed_int_encoding()
21
21
-
.with_limit::<1048576>();
8
8
+
type C = Configuration<LittleEndian, Varint, Limit<1048576>>;
9
9
+
static BINCODE_CONF: C = standard().with_limit::<1048576>();
22
10
23
11
fuzz_target!(|data: &[u8]| {
24
24
-
if let Ok((estimator, _n)) = decode_from_slice::<CardinalityEstimator<Did>, C>(
12
12
+
if let Ok((mut estimator, _n)) = decode_from_slice::<CardinalityEstimator<String>, C>(
25
13
data,
26
14
BINCODE_CONF,
27
15
) {
28
28
-
estimator.estimate();
16
16
+
// crash happens *much* faster if we just do kinda anything with the estimator
17
17
+
estimator.insert(&"asdf".to_string());
18
18
+
assert!(estimator.estimate() > 0);
29
19
}
30
20
});