Skip to content

Commit

Permalink
fuzz check f64 can be serialized
Browse files Browse the repository at this point in the history
  • Loading branch information
skrrb committed Sep 12, 2023
1 parent 49e584c commit 4a6daab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ struct FuzzData {
}

impl FuzzData {
fn is_borsh_serializable(&self) -> bool {
self.instructions.iter().all(|ix| match ix {
FuzzInstruction::StubOracleSet { data, .. } => !data.price.is_nan(),
_ => true,
})
}

fn contains_place_order_ixs(&self) -> bool {
self.instructions.iter().any(|ix| {
matches!(
Expand Down Expand Up @@ -219,7 +226,7 @@ fuzz_target!(|fuzz_data: FuzzData| -> Corpus {
});

fn run_fuzz(fuzz_data: FuzzData) -> Corpus {
if !fuzz_data.contains_place_order_ixs() {
if !fuzz_data.is_borsh_serializable() || !fuzz_data.contains_place_order_ixs() {
return Corpus::Reject;
}

Expand Down

0 comments on commit 4a6daab

Please sign in to comment.