Formatting

This commit is contained in:
Riley-Kilgore 2024-12-04 06:45:27 -08:00 committed by Riley
parent 699628df62
commit d353e07ea1
6 changed files with 37 additions and 34 deletions

View File

@ -261,9 +261,11 @@ impl Type {
},
],
}],
}.into(),
}
.into(),
},
}.into(),
}
.into(),
),
})
}

View File

@ -385,7 +385,9 @@ impl PropertyTest {
value,
choices: next_prng.choices(),
cache: Cache::new(move |choices| {
match Prng::from_choices(choices, iteration).sample(&self.fuzzer.program, iteration) {
match Prng::from_choices(choices, iteration)
.sample(&self.fuzzer.program, iteration)
{
Err(..) => Status::Invalid,
Ok(None) => Status::Invalid,
Ok(Some((_, value))) => {
@ -556,10 +558,7 @@ impl Prng {
choices: vec![],
uplc: Data::constr(
Prng::SEEDED,
vec![
Data::bytestring(digest.to_vec()),
Data::bytestring(vec![]),
],
vec![Data::bytestring(digest.to_vec()), Data::bytestring(vec![])],
),
iteration: 0,
}
@ -599,22 +598,19 @@ impl Prng {
}
_ => {
// Use the cloned program for the second attempt
let program_with_iteration = Program::<NamedDeBruijn>::try_from(
program_clone.apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64)))
).unwrap();
let program_with_iteration = program_clone
.apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64)));
let mut result = program_with_iteration.eval(ExBudget::max());
match result.result() {
Ok(term) if matches!(term, Term::Constant(_)) => {
Ok(Prng::from_result(term, iteration))
}
Err(uplc_error) => {
Err(FuzzerError {
Err(uplc_error) => Err(FuzzerError {
traces: result.logs(),
uplc_error,
})
}
_ => unreachable!("Fuzzer returned a malformed result? {result:#?}")
}),
_ => unreachable!("Fuzzer returned a malformed result? {result:#?}"),
}
}
}
@ -630,7 +626,10 @@ impl Prng {
/// made during shrinking aren't breaking underlying invariants (if only, because we run out of
/// values to replay). In such case, the replayed sequence is simply invalid and the fuzzer
/// aborted altogether with 'None'.
pub fn from_result(result: Term<NamedDeBruijn>, iteration: usize) -> Option<(Self, PlutusData)> {
pub fn from_result(
result: Term<NamedDeBruijn>,
iteration: usize,
) -> Option<(Self, PlutusData)> {
/// Interpret the given 'PlutusData' as one of two Prng constructors.
fn as_prng(cst: &PlutusData, iteration: usize) -> Prng {
if let PlutusData::Constr(Constr { tag, fields, .. }) = cst {

View File

@ -861,8 +861,12 @@ fn infer_scaled_fuzzer(
// Check if this is a ScaledFuzzer (fn(PRNG, Int) -> Option<(PRNG, a)>)
if args.len() == 2 {
match ret.borrow() {
Type::App { module, name, args: ret_args, .. }
if module.is_empty() && name == "Option" && ret_args.len() == 1 => {
Type::App {
module,
name,
args: ret_args,
..
} if module.is_empty() && name == "Option" && ret_args.len() == 1 => {
if let Type::Tuple { elems, .. } = ret_args[0].borrow() {
if elems.len() == 2 {
let wrapped = &elems[1];
@ -879,7 +883,7 @@ fn infer_scaled_fuzzer(
}
}
}
_ => ()
_ => (),
}
}

View File

@ -417,9 +417,8 @@ where
error,
path: options.blueprint_path,
}
})?;
Ok(())
.into()
})
}
CodeGenMode::Test {
match_tests,

View File

@ -230,8 +230,7 @@ impl EventListener for Terminal {
" Complete"
.if_supports_color(Stderr, |s| s.bold())
.if_supports_color(Stderr, |s| s.green()),
"benchmark results written to CSV"
.if_supports_color(Stderr, |s| s.bold())
"benchmark results written to CSV".if_supports_color(Stderr, |s| s.bold())
);
}
}