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, value,
choices: next_prng.choices(), choices: next_prng.choices(),
cache: Cache::new(move |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, Err(..) => Status::Invalid,
Ok(None) => Status::Invalid, Ok(None) => Status::Invalid,
Ok(Some((_, value))) => { Ok(Some((_, value))) => {
@ -556,10 +558,7 @@ impl Prng {
choices: vec![], choices: vec![],
uplc: Data::constr( uplc: Data::constr(
Prng::SEEDED, Prng::SEEDED,
vec![ vec![Data::bytestring(digest.to_vec()), Data::bytestring(vec![])],
Data::bytestring(digest.to_vec()),
Data::bytestring(vec![]),
],
), ),
iteration: 0, iteration: 0,
} }
@ -599,22 +598,19 @@ impl Prng {
} }
_ => { _ => {
// Use the cloned program for the second attempt // Use the cloned program for the second attempt
let program_with_iteration = Program::<NamedDeBruijn>::try_from( let program_with_iteration = program_clone
program_clone.apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64))) .apply_data(Data::integer(num_bigint::BigInt::from(iteration as i64)));
).unwrap();
let mut result = program_with_iteration.eval(ExBudget::max()); let mut result = program_with_iteration.eval(ExBudget::max());
match result.result() { match result.result() {
Ok(term) if matches!(term, Term::Constant(_)) => { Ok(term) if matches!(term, Term::Constant(_)) => {
Ok(Prng::from_result(term, iteration)) Ok(Prng::from_result(term, iteration))
} }
Err(uplc_error) => { Err(uplc_error) => Err(FuzzerError {
Err(FuzzerError {
traces: result.logs(), traces: result.logs(),
uplc_error, 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 /// 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 /// values to replay). In such case, the replayed sequence is simply invalid and the fuzzer
/// aborted altogether with 'None'. /// 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. /// Interpret the given 'PlutusData' as one of two Prng constructors.
fn as_prng(cst: &PlutusData, iteration: usize) -> Prng { fn as_prng(cst: &PlutusData, iteration: usize) -> Prng {
if let PlutusData::Constr(Constr { tag, fields, .. }) = cst { 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)>) // Check if this is a ScaledFuzzer (fn(PRNG, Int) -> Option<(PRNG, a)>)
if args.len() == 2 { if args.len() == 2 {
match ret.borrow() { match ret.borrow() {
Type::App { module, name, args: ret_args, .. } Type::App {
if module.is_empty() && name == "Option" && ret_args.len() == 1 => { 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 let Type::Tuple { elems, .. } = ret_args[0].borrow() {
if elems.len() == 2 { if elems.len() == 2 {
let wrapped = &elems[1]; let wrapped = &elems[1];
@ -879,7 +883,7 @@ fn infer_scaled_fuzzer(
} }
} }
} }
_ => () _ => (),
} }
} }

View File

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

View File

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