mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
clippy: assorted fixes to tests and benches
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
bbcafd16de
commit
98baae93c1
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use leo_ast::{errors::ParserError, files::File, LeoAst};
|
||||
use leo_ast::LeoAst;
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -17,8 +17,8 @@
|
||||
use crate::{assert_satisfied, expect_compiler_error, generate_main_input, parse_program};
|
||||
use leo_typed::InputValue;
|
||||
|
||||
static TEST_ADDRESS_1: &'static str = "aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8";
|
||||
static TEST_ADDRESS_2: &'static str = "aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r";
|
||||
static TEST_ADDRESS_1: &str = "aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8";
|
||||
static TEST_ADDRESS_2: &str = "aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r";
|
||||
|
||||
#[test]
|
||||
fn test_valid() {
|
||||
|
@ -43,7 +43,7 @@ fn fail_boolean_statement(program: EdwardsTestCompiler) {
|
||||
CompilerError::FunctionError(FunctionError::StatementError(StatementError::ExpressionError(
|
||||
ExpressionError::BooleanError(BooleanError::Error(_)),
|
||||
))) => {}
|
||||
_ => panic!("Expected boolean error, got {}"),
|
||||
e => panic!("Expected boolean error, got {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// allow the use of EdwardsTestCompiler::parse_program_from_string for tests
|
||||
#![allow(deprecated)]
|
||||
|
||||
pub mod address;
|
||||
pub mod array;
|
||||
pub mod boolean;
|
||||
|
@ -44,7 +44,7 @@ const NEW_PROJECT_FORMAT: &str = "[project]";
|
||||
|
||||
/// Create a manifest file with outdated formatting.
|
||||
fn create_outdated_manifest_file(path: PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
let mut path = path;
|
||||
if path.is_dir() {
|
||||
path.push(PathBuf::from(MANIFEST_FILENAME));
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#![allow(clippy::module_inception)]
|
||||
|
||||
pub mod initialize;
|
||||
pub mod manifest;
|
||||
|
||||
@ -59,7 +61,7 @@ pub(crate) fn test_dir() -> PathBuf {
|
||||
let id = NEXT_ID.fetch_add(1, Ordering::Relaxed);
|
||||
TEST_ID.with(|n| *n.borrow_mut() = Some(id));
|
||||
|
||||
let path: PathBuf = TEST_DIR.join(&format!("t{}", id)).into();
|
||||
let path: PathBuf = TEST_DIR.join(&format!("t{}", id));
|
||||
|
||||
if path.exists() {
|
||||
if let Err(e) = fs::remove_dir_all(&path) {
|
||||
|
@ -111,8 +111,8 @@ fn test_generate_values_from_dpc() {
|
||||
.unwrap();
|
||||
|
||||
// Set the input records for our transaction to be the initial dummy records.
|
||||
let old_records = vec![old_record.clone(); NUM_INPUT_RECORDS];
|
||||
let old_account_private_keys = vec![dummy_account.private_key.clone(); NUM_INPUT_RECORDS];
|
||||
let old_records = vec![old_record; NUM_INPUT_RECORDS];
|
||||
let old_account_private_keys = vec![dummy_account.private_key; NUM_INPUT_RECORDS];
|
||||
|
||||
// Construct new records.
|
||||
|
||||
@ -128,12 +128,12 @@ fn test_generate_values_from_dpc() {
|
||||
|
||||
// Set the new record's program to be the "always-accept" program.
|
||||
|
||||
let new_record_owners = vec![new_account.address.clone(); NUM_OUTPUT_RECORDS];
|
||||
let new_record_owners = vec![new_account.address; NUM_OUTPUT_RECORDS];
|
||||
let new_is_dummy_flags = vec![false; NUM_OUTPUT_RECORDS];
|
||||
let new_values = vec![10; NUM_OUTPUT_RECORDS];
|
||||
let new_payloads = vec![RecordPayload::default(); NUM_OUTPUT_RECORDS];
|
||||
let new_birth_program_ids = vec![noop_program_id.clone(); NUM_OUTPUT_RECORDS];
|
||||
let new_death_program_ids = vec![noop_program_id.clone(); NUM_OUTPUT_RECORDS];
|
||||
let new_death_program_ids = vec![noop_program_id; NUM_OUTPUT_RECORDS];
|
||||
let memo = [0u8; 32];
|
||||
|
||||
let context = <InstantiatedDPC as DPCScheme<L>>::execute_offline(
|
||||
@ -158,13 +158,13 @@ fn test_generate_values_from_dpc() {
|
||||
|
||||
let root = local_data.local_data_merkle_tree.root();
|
||||
|
||||
let serial_number = local_data.old_serial_numbers[0].clone();
|
||||
let serial_number = local_data.old_serial_numbers[0];
|
||||
let serial_number_bytes = to_bytes![serial_number].unwrap();
|
||||
|
||||
let memorandum = local_data.memorandum;
|
||||
let network_id = local_data.network_id;
|
||||
let input_bytes = to_bytes![serial_number, record.commitment(), memorandum, network_id].unwrap();
|
||||
let leaf_randomness = local_data.local_data_commitment_randomizers[0].clone();
|
||||
let leaf_randomness = local_data.local_data_commitment_randomizers[0];
|
||||
|
||||
let old_record_leaf = <LocalDataCommitment as CommitmentScheme>::commit(
|
||||
&system_parameters.local_data_commitment,
|
||||
|
@ -14,11 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use leo_ast::{errors::ParserError, files::File, LeoAst};
|
||||
use leo_ast::LeoAst;
|
||||
use leo_typed::LeoTypedAst;
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) {
|
||||
let typed_ast = LeoTypedAst::new("leo_typed_tree", &ast);
|
||||
|
@ -27,9 +27,7 @@ fn to_typed_ast(program_filepath: &PathBuf) -> LeoTypedAst {
|
||||
let ast = LeoAst::new(&program_filepath, &program_string).unwrap();
|
||||
|
||||
// Parse the abstract syntax tree and constructs a typed syntax tree.
|
||||
let typed_ast = LeoTypedAst::new("leo_typed_tree", &ast);
|
||||
|
||||
typed_ast
|
||||
LeoTypedAst::new("leo_typed_tree", &ast)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user