enforce aleo prefix and character length

This commit is contained in:
collin 2020-08-03 23:22:11 -07:00
parent 2c3c852ff4
commit a0d294591e
4 changed files with 16 additions and 5 deletions

View File

@ -206,7 +206,7 @@ group_tuple = {"(" ~ value_number ~ "," ~ value_number ~ ")"}
group_single_or_tuple = {value_number | group_tuple}
// Declared in values/address.rs
address = @{ (LOWERCASE_LETTER | ASCII_DIGIT)+ }
address = @{ "aleo" ~ ASCII_DIGIT ~ (LOWERCASE_LETTER | ASCII_DIGIT){58} }
// Declared in values/address_value.rs
value_address = { type_address ~ "(" ~ address ~ ")" }

View File

@ -0,0 +1,3 @@
function main() {
let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88);
}

View File

@ -13,11 +13,19 @@ fn test_valid() {
}
#[test]
fn test_invalid() {
let bytes = include_bytes!("invalid.leo");
let program = parse_program(bytes).unwrap();
fn test_invalid_prefix() {
let bytes = include_bytes!("invalid_prefix.leo");
let syntax_error = parse_program(bytes).is_err();
let _output = expect_compiler_error(program);
assert!(syntax_error);
}
#[test]
fn test_invalid_length() {
let bytes = include_bytes!("invalid_length.leo");
let syntax_error = parse_program(bytes).is_err();
assert!(syntax_error);
}
#[test]