Skip to content

Commit

Permalink
Improve testing infrastructure (#2227)
Browse files Browse the repository at this point in the history
* wip

* re-enable get_process call for test programs

* remove local tests

* clean up

* remove rust version from cargo.toml
  • Loading branch information
Collin Chin authored Jan 4, 2023
1 parent ba5c4cf commit 5a7feb2
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 80 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ categories = [ "compilers", "cryptography", "web-programming" ]
include = [ "Cargo.toml", "leo", "README.md", "LICENSE.md" ]
license = "GPL-3.0"
edition = "2021"
rust-version = "1.65"

[workspace]
members = [
Expand Down
7 changes: 3 additions & 4 deletions compiler/compiler/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,10 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
std::fs::create_dir_all(build_directory).unwrap();

// Open the package at the temporary directory.
let _package = handler.extend_if_error(Package::<Testnet3>::open(&directory).map_err(LeoError::Anyhow))?;
let package = handler.extend_if_error(Package::<Testnet3>::open(&directory).map_err(LeoError::Anyhow))?;

// Commented out since it bottlenecks the test framework.
// // Get the program process and check all instructions.
// handler.extend_if_error(package.get_process().map_err(LeoError::Anyhow))?;
// Get the program process and check all instructions.
handler.extend_if_error(package.get_process().map_err(LeoError::Anyhow))?;
}

let initial_ast = hash_file("/tmp/output/test.initial_ast.json");
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/core/algorithms/pedersen128_commit.leo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program test.aleo {
u16_value: u16,
u32_value: u32,
u64_value: u64,
) -> group {
) -> bool {
let bool_value: bool = true;
// let string_value: string = "helloworld";

Expand All @@ -30,5 +30,5 @@ program test.aleo {
let i: group = Pedersen128::commit(u64_value, 1scalar);
// let j11: group = Pedersen128::commit(string_value, 1scalar);

return a + i;
return a == i;
}}
4 changes: 2 additions & 2 deletions tests/compiler/core/algorithms/pedersen64_commit.leo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program test.aleo {
u16_value: u16,
u32_value: u32,
u64_value: u64,
) -> group {
) -> bool {
let bool_value: bool = true;
// let string_value: string = "helloworld";

Expand All @@ -30,5 +30,5 @@ program test.aleo {
let i: group = Pedersen64::commit(u64_value, 1scalar);
// let j11: group = Pedersen64::commit(string_value, 1scalar);

return a + i;
return a == i;
}}
2 changes: 1 addition & 1 deletion tests/compiler/core/algorithms/pedersen_fail.leo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expectation: Fail

program test.aleo {
function main() -> bool {
let a: group = Pedersen64::hash(1u128);
let a: group = Pedersen64::hash(1u128); // Pedersen64 hash returns a field type

return true;
}}
6 changes: 5 additions & 1 deletion tests/compiler/finalize/mapping.leo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ namespace: Compile
expectation: Pass
*/

program test.aleo {
program test.aleo {
transition matches(addr: address) -> bool {
return self.caller == addr;
}

mapping balances: address => u128;

struct Token {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: 46d3cef7b6dd6e951fe93d550206bdd658d6d435f71c776a39ae3b443770d33d
initial_ast: 6af9e875a38f0b512b91aab4d1e603780820382abd651d509ad90f0375bf061f
unrolled_ast: 6af9e875a38f0b512b91aab4d1e603780820382abd651d509ad90f0375bf061f
ssa_ast: 11b9a590dd9823c00b607e8162ee79b720eb632a46a4760d9dd57b35e463e4f2
flattened_ast: 81fb5a95971a3ccb8182dbe23e501b12d71ea62e89067e166f3361fa0a757d1e
initial_ast: 652292056216286ad2a1bca48fbb0620c44997c4c4eb1c04759382edcc7630df
unrolled_ast: 652292056216286ad2a1bca48fbb0620c44997c4c4eb1c04759382edcc7630df
ssa_ast: 06b466fb0ef6236927ec91a74cbbe328288fe2d71095cf190689d542d9a82a22
flattened_ast: c816c5741ae200f3e868386376cb91528c6321deb84bea37cc3298b04fb1c633
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: 591fe9942b59bad76b636a1c9e6ebe93ad85df562b09b7a900acfe12a9caffe2
initial_ast: ad2bc892f24b971eff231aa2d53047e5129cdd510c689f21235d51601c04670b
unrolled_ast: ad2bc892f24b971eff231aa2d53047e5129cdd510c689f21235d51601c04670b
ssa_ast: 5fda4bee03a6d82641305659fb244ffd043c0f1f87114944c25677e7eebfc36b
flattened_ast: 1e32d226f9c5ee5a753d110feae1bfdee8098b3da5a37417f8e408dcee52a244
initial_ast: 4ebdf628f3e15cebb4752dbe2eba6414205cb7e8a471b1eec39936f2fdb819d7
unrolled_ast: 4ebdf628f3e15cebb4752dbe2eba6414205cb7e8a471b1eec39936f2fdb819d7
ssa_ast: 5076ba0487bca5767b51114261076956987412baaf43dfc802536237eaac0d42
flattened_ast: f88e612c473eecb18b17ec64f93cbd2a8260b7d2333bafa0200445ad0ea2c438
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372046]: Invalid type `u128`\n --> compiler-test:5:41\n |\n 5 | let a: group = Pedersen64::hash(1u128);\n | ^^^^^\nError [ETYC0372003]: Expected type `group` but type `field` was found\n --> compiler-test:5:24\n |\n 5 | let a: group = Pedersen64::hash(1u128);\n | ^^^^^^^^^^^^^^^^^^^^^^^\n"
- "Error [ETYC0372046]: Invalid type `u128`\n --> compiler-test:5:41\n |\n 5 | let a: group = Pedersen64::hash(1u128); // Pedersen64 hash returns a field type\n | ^^^^^\nError [ETYC0372003]: Expected type `group` but type `field` was found\n --> compiler-test:5:24\n |\n 5 | let a: group = Pedersen64::hash(1u128); // Pedersen64 hash returns a field type\n | ^^^^^^^^^^^^^^^^^^^^^^^\n"
8 changes: 4 additions & 4 deletions tests/expectations/compiler/finalize/mapping.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: no input
initial_ast: 9e439c79df1fb622da95a9d0b1ccfbdf88dd08004e5f33d335abbeb61e8988e1
unrolled_ast: 9e439c79df1fb622da95a9d0b1ccfbdf88dd08004e5f33d335abbeb61e8988e1
ssa_ast: 9e439c79df1fb622da95a9d0b1ccfbdf88dd08004e5f33d335abbeb61e8988e1
flattened_ast: 9e439c79df1fb622da95a9d0b1ccfbdf88dd08004e5f33d335abbeb61e8988e1
initial_ast: 80cf7756daec71329a98995706effec516428b8356521fcf788955e7100e0ff8
unrolled_ast: 80cf7756daec71329a98995706effec516428b8356521fcf788955e7100e0ff8
ssa_ast: ce22cc6ae931fe8de20ae6b43d2021c01b65c875297a2a83d469044af5d0545f
flattened_ast: 749019110e4f96a3fa08b505e84d195ab22b43b66708278fc7b49ec57968d818
56 changes: 0 additions & 56 deletions tests/expectations/parser/statement/console.out

This file was deleted.

0 comments on commit 5a7feb2

Please sign in to comment.