Skip to content

Commit

Permalink
expect node
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-o-how committed Sep 23, 2024
1 parent 7f6b27b commit 6cb546e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 3 additions & 7 deletions crates/chia-consensus/fuzz/fuzz_targets/solution-generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ fuzz_target!(|data: &[u8]| {
spend.solution.to_vec(),
));
// Check if puzzle or solution are atoms which can represented in a smaller form
let Ok(node) = node_from_bytes(&mut a, spend.puzzle_reveal.as_ref()) else {
return;
};
let node = node_from_bytes(&mut a, spend.puzzle_reveal.as_ref()).expect("node");
if node.is_atom() {
let puz = node_to_bytes(&a, node).expect("bytes");
discrepancy += spend.puzzle_reveal.as_ref().len() - puz.len();
}
let Ok(node) = node_from_bytes(&mut a, spend.solution.as_ref()) else {
return;
};
let node = node_from_bytes(&mut a, spend.solution.as_ref()).expect("node");
if node.is_atom() {
let sol = node_to_bytes(&a, node).expect("bytes");
discrepancy += spend.solution.as_ref().len() - sol.len();
Expand All @@ -45,7 +41,7 @@ fuzz_target!(|data: &[u8]| {
return;
};

if result.len() != calculate_generator_length(spends) - discrepancy {
if result.len() != calculate_generator_length(spends.clone()) - discrepancy {
panic!("Debug spends: {:?}", spends);
}

Expand Down
1 change: 1 addition & 0 deletions crates/chia-consensus/src/gen/solution_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ mod tests {

#[rstest]
#[case(hex!("f800000000").as_ref(), SOLUTION1.as_ref())]
#[case(hex!("fffffe0000ff41ff013a").as_ref(), SOLUTION1.as_ref())]
#[case(PUZZLE1.as_ref(), hex!("00").as_ref())]
fn test_length_calculator_edge_case(#[case] puzzle: &[u8], #[case] solution: &[u8]) {
let mut spends: Vec<(Coin, &[u8], &[u8])> = Vec::new();
Expand Down

0 comments on commit 6cb546e

Please sign in to comment.