-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fuzz): arbitrary implementation for Cell and CellBuilder
- Loading branch information
1 parent
0013459
commit c51f801
Showing
8 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use libfuzzer_sys::{fuzz_target, Corpus}; | ||
|
||
use everscale_types::prelude::Boc; | ||
use everscale_types::cell::CellTreeStats; | ||
use everscale_types::prelude::*; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
fuzz_target!(|data: &[u8]| -> Corpus { | ||
if let Ok(cell) = Boc::decode(data) { | ||
_ = Boc::encode(cell.as_ref()); | ||
let res = Boc::encode(cell.as_ref()); | ||
let redecoded = Boc::decode(&res).unwrap(); | ||
assert_eq!(cell.as_ref(), redecoded.as_ref()); | ||
let l = call_all_cell_methods(&cell); | ||
let r = call_all_cell_methods(&redecoded); | ||
assert_eq!(l, r); | ||
return Corpus::Keep; | ||
} | ||
Corpus::Reject | ||
}); | ||
|
||
fn call_all_cell_methods(cell: &Cell) -> CellTreeStats { | ||
let hash = cell.hash(0); | ||
let hash = cell.hash(1); | ||
let hash = cell.hash(2); | ||
let hash = cell.hash(3); | ||
|
||
let _ = cell.virtualize(); | ||
cell.compute_unique_stats(usize::MAX).unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![no_main] | ||
use libfuzzer_sys::{fuzz_target, Corpus}; | ||
|
||
use everscale_types::prelude::{Cell, RawDict}; | ||
|
||
fuzz_target!(|data: Cell| -> Corpus { | ||
if let Ok(map) = data.parse::<RawDict<32>>() { | ||
_ = map.iter().count(); | ||
return Corpus::Keep; | ||
} | ||
Corpus::Reject | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![no_main] | ||
use libfuzzer_sys::{fuzz_target, Corpus}; | ||
|
||
use everscale_types::models::Message; | ||
use everscale_types::prelude::Cell; | ||
|
||
fuzz_target!(|cell: Cell| -> Corpus { | ||
if cell.parse::<Message>().is_ok() { | ||
return Corpus::Keep; | ||
} | ||
|
||
Corpus::Reject | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters