2020-08-18 13:50:26 +03:00
|
|
|
// Copyright (C) 2019-2020 Aleo Systems Inc.
|
|
|
|
// This file is part of the Leo library.
|
|
|
|
|
|
|
|
// The Leo library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// The Leo library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
2020-08-13 01:35:32 +03:00
|
|
|
use leo_input::LeoInputParser;
|
|
|
|
use leo_state::verify_record_commitment;
|
|
|
|
use leo_typed::Input;
|
2020-08-13 05:04:41 +03:00
|
|
|
|
|
|
|
use snarkos_dpc::base_dpc::instantiated::*;
|
|
|
|
|
2020-08-13 01:35:32 +03:00
|
|
|
use rand::SeedableRng;
|
|
|
|
use rand_xorshift::XorShiftRng;
|
|
|
|
|
2020-08-21 13:28:44 +03:00
|
|
|
// TODO (Collin): Update input to reflect new parameter ordering.
|
2020-08-13 01:35:32 +03:00
|
|
|
#[test]
|
2020-08-21 13:28:44 +03:00
|
|
|
#[ignore]
|
2020-08-13 01:35:32 +03:00
|
|
|
fn test_verify_record_from_file() {
|
|
|
|
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
|
|
|
|
|
|
|
// Generate parameters for the record commitment scheme
|
|
|
|
let system_parameters = InstantiatedDPC::generate_system_parameters(&mut rng).unwrap();
|
|
|
|
|
|
|
|
// Load test record state file from `inputs/test.state`
|
2020-08-13 05:04:41 +03:00
|
|
|
let file_bytes = include_bytes!("inputs/test_record.state");
|
2020-08-13 01:35:32 +03:00
|
|
|
let file_string = String::from_utf8_lossy(file_bytes);
|
|
|
|
let file = LeoInputParser::parse_file(&file_string).unwrap();
|
|
|
|
|
|
|
|
let mut program_input = Input::new();
|
|
|
|
program_input.parse_state(file).unwrap();
|
|
|
|
|
|
|
|
let typed_record = program_input.get_record();
|
|
|
|
|
|
|
|
// check record state is correct by verifying commitment
|
2020-08-13 05:15:55 +03:00
|
|
|
let _values = verify_record_commitment(&system_parameters, typed_record).unwrap();
|
2020-08-13 01:35:32 +03:00
|
|
|
}
|