diff --git a/crates/aiken-lang/src/ast/well_known.rs b/crates/aiken-lang/src/ast/well_known.rs index 55b4d526..45248ef0 100644 --- a/crates/aiken-lang/src/ast/well_known.rs +++ b/crates/aiken-lang/src/ast/well_known.rs @@ -261,9 +261,11 @@ impl Type { }, ], }], - }.into(), + } + .into(), }, - }.into(), + } + .into(), ), }) } diff --git a/crates/aiken-lang/src/builtins.rs b/crates/aiken-lang/src/builtins.rs index a144edcf..69e8bb61 100644 --- a/crates/aiken-lang/src/builtins.rs +++ b/crates/aiken-lang/src/builtins.rs @@ -499,7 +499,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo { // fn(PRNG, Int) -> Option<(PRNG, a)> let scaled_fuzzer_value = Type::generic_var(id_gen.next()); prelude.types.insert( - well_known::SCALED_FUZZER.to_string(), + well_known::SCALED_FUZZER.to_string(), TypeConstructor { location: Span::empty(), parameters: vec![scaled_fuzzer_value.clone()], diff --git a/crates/aiken-lang/src/test_framework.rs b/crates/aiken-lang/src/test_framework.rs index bab7ee0e..c8129cd4 100644 --- a/crates/aiken-lang/src/test_framework.rs +++ b/crates/aiken-lang/src/test_framework.rs @@ -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))) => { @@ -504,13 +506,13 @@ impl PropertyTest { /// #[derive(Debug)] pub enum Prng { - Seeded { - choices: Vec, + Seeded { + choices: Vec, uplc: PlutusData, iteration: usize, }, - Replayed { - choices: Vec, + Replayed { + choices: Vec, uplc: PlutusData, iteration: usize, }, @@ -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, } @@ -591,7 +590,7 @@ impl Prng { let program_clone = program.clone(); let result = program.eval(ExBudget::max()); - + match result.result() { Ok(term) if matches!(term, Term::Constant(_)) => { // If we got a valid constant result, process it @@ -599,22 +598,19 @@ impl Prng { } _ => { // Use the cloned program for the second attempt - let program_with_iteration = Program::::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 { - traces: result.logs(), - uplc_error, - }) - } - _ => unreachable!("Fuzzer returned a malformed result? {result:#?}") + Err(uplc_error) => Err(FuzzerError { + traces: result.logs(), + uplc_error, + }), + _ => 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, iteration: usize) -> Option<(Self, PlutusData)> { + pub fn from_result( + result: Term, + 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 { diff --git a/crates/aiken-lang/src/tipo/infer.rs b/crates/aiken-lang/src/tipo/infer.rs index 78562a3b..f7acc510 100644 --- a/crates/aiken-lang/src/tipo/infer.rs +++ b/crates/aiken-lang/src/tipo/infer.rs @@ -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( } } } - _ => () + _ => (), } } @@ -947,4 +951,4 @@ fn put_params_in_scope<'a>( ArgName::Named { .. } | ArgName::Discarded { .. } => (), }; } -} \ No newline at end of file +} diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index 27030415..a8eff857 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -417,9 +417,8 @@ where error, path: options.blueprint_path, } - })?; - - Ok(()) + .into() + }) } CodeGenMode::Test { match_tests, diff --git a/crates/aiken-project/src/telemetry/terminal.rs b/crates/aiken-project/src/telemetry/terminal.rs index afd6685d..bdb19ddd 100644 --- a/crates/aiken-project/src/telemetry/terminal.rs +++ b/crates/aiken-project/src/telemetry/terminal.rs @@ -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()) ); } }