mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 01:01:53 +03:00
use include_str in program state tests
This commit is contained in:
parent
dbae691e49
commit
b2246f1151
@ -18,32 +18,32 @@ use crate::{assert_satisfied, parse_program_with_state, parse_state};
|
||||
|
||||
#[test]
|
||||
fn test_basic() {
|
||||
let bytes = include_bytes!("input/basic.state");
|
||||
let state_string = include_str!("input/basic.state");
|
||||
|
||||
parse_state(bytes).unwrap();
|
||||
parse_state(state_string).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_token_withdraw() {
|
||||
let bytes = include_bytes!("input/token_withdraw.state");
|
||||
let state_string = include_str!("input/token_withdraw.state");
|
||||
|
||||
parse_state(bytes).unwrap();
|
||||
parse_state(state_string).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_access_state() {
|
||||
let program_bytes = include_bytes!("access_state.leo");
|
||||
let state_bytes = include_bytes!("input/token_withdraw.state");
|
||||
let program_string = include_str!("access_state.leo");
|
||||
let state_string = include_str!("input/token_withdraw.state");
|
||||
|
||||
let program = parse_program_with_state(program_bytes, state_bytes).unwrap();
|
||||
let program = parse_program_with_state(program_string, state_string).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_access_all() {
|
||||
let program_bytes = include_bytes!("access_all.leo");
|
||||
let state_bytes = include_bytes!("input/token_withdraw.state");
|
||||
let program_bytes = include_str!("access_all.leo");
|
||||
let state_bytes = include_str!("input/token_withdraw.state");
|
||||
|
||||
let program = parse_program_with_state(program_bytes, state_bytes).unwrap();
|
||||
|
||||
@ -52,27 +52,27 @@ fn test_access_all() {
|
||||
|
||||
#[test]
|
||||
fn test_visibility_fail() {
|
||||
let state_bytes = include_bytes!("input/visibility_fail.state");
|
||||
let state_string = include_str!("input/visibility_fail.state");
|
||||
|
||||
let is_err = parse_state(state_bytes).is_err();
|
||||
let is_err = parse_state(state_string).is_err();
|
||||
|
||||
assert!(is_err);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_section_undefined() {
|
||||
let state_bytes = include_bytes!("input/section_undefined.state");
|
||||
let state_string = include_str!("input/section_undefined.state");
|
||||
|
||||
let is_err = parse_state(state_bytes).is_err();
|
||||
let is_err = parse_state(state_string).is_err();
|
||||
|
||||
assert!(is_err);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_section_invalid() {
|
||||
let state_bytes = include_bytes!("input/section_invalid.state");
|
||||
let state_string = include_str!("input/section_invalid.state");
|
||||
|
||||
let is_err = parse_state(state_bytes).is_err();
|
||||
let is_err = parse_state(state_string).is_err();
|
||||
|
||||
assert!(is_err);
|
||||
}
|
||||
|
@ -83,9 +83,8 @@ pub(crate) fn parse_input(bytes: &[u8]) -> Result<EdwardsTestCompiler, CompilerE
|
||||
Ok(compiler)
|
||||
}
|
||||
|
||||
pub(crate) fn parse_state(bytes: &[u8]) -> Result<EdwardsTestCompiler, CompilerError> {
|
||||
pub(crate) fn parse_state(state_string: &str) -> Result<EdwardsTestCompiler, CompilerError> {
|
||||
let mut compiler = new_compiler();
|
||||
let state_string = String::from_utf8_lossy(bytes);
|
||||
let path = PathBuf::new();
|
||||
|
||||
compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?;
|
||||
@ -124,17 +123,17 @@ pub fn parse_program_with_input(
|
||||
}
|
||||
|
||||
pub fn parse_program_with_state(
|
||||
program_bytes: &[u8],
|
||||
state_bytes: &[u8],
|
||||
program_string: &str,
|
||||
state_string: &str,
|
||||
) -> Result<EdwardsTestCompiler, CompilerError> {
|
||||
let mut compiler = new_compiler();
|
||||
|
||||
let program_string = String::from_utf8_lossy(program_bytes);
|
||||
let state_string = String::from_utf8_lossy(state_bytes);
|
||||
// let program_string = String::from_utf8_lossy(program_bytes);
|
||||
// let state_string = String::from_utf8_lossy(state_bytes);
|
||||
let path = PathBuf::new();
|
||||
|
||||
compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?;
|
||||
compiler.parse_program_from_string(&program_string)?;
|
||||
compiler.parse_input(EMPTY_FILE, &path, state_string, &path)?;
|
||||
compiler.parse_program_from_string(program_string)?;
|
||||
|
||||
Ok(compiler)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user