From c809268084895bd0c963b6f767b9fae2f4aaa926 Mon Sep 17 00:00:00 2001 From: evan-schott <53463459+evan-schott@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:38:54 -0800 Subject: [PATCH] add new tests for new import structure, as well as deprecating hardcoding stubs --- tests/tests/parser/program/import.leo | 10 ++++ tests/tests/parser/program/import_fail.leo | 10 ++++ tests/tests/parser/program/stub.leo | 60 --------------------- tests/tests/parser/program/stub_fail.leo | 51 +++++++++++++++--- tests/tests/parser/statement/definition.leo | 4 ++ 5 files changed, 68 insertions(+), 67 deletions(-) create mode 100644 tests/tests/parser/program/import.leo create mode 100644 tests/tests/parser/program/import_fail.leo delete mode 100644 tests/tests/parser/program/stub.leo diff --git a/tests/tests/parser/program/import.leo b/tests/tests/parser/program/import.leo new file mode 100644 index 0000000000..3f03d34e72 --- /dev/null +++ b/tests/tests/parser/program/import.leo @@ -0,0 +1,10 @@ +/* +namespace: Parse +expectation: Pass +*/ +import hello.aleo; +program test.aleo { + function main() { + let x:u8 = 1u8; + } +} diff --git a/tests/tests/parser/program/import_fail.leo b/tests/tests/parser/program/import_fail.leo new file mode 100644 index 0000000000..9c656ed691 --- /dev/null +++ b/tests/tests/parser/program/import_fail.leo @@ -0,0 +1,10 @@ +/* +namespace: Parse +expectation: Fail +*/ +import hello.leo; +program test.aleo { + function main() { + let x:u8 = 1u8; + } +} diff --git a/tests/tests/parser/program/stub.leo b/tests/tests/parser/program/stub.leo deleted file mode 100644 index a1257ab67f..0000000000 --- a/tests/tests/parser/program/stub.leo +++ /dev/null @@ -1,60 +0,0 @@ -/* -namespace: Parse -expectation: Pass -*/ - -stub credits.aleo { - import battleship.aleo; - import exchange.aleo; - record credits { - owner: address, - micrcredits: u64, - } - struct Row { - c1: u8, - c2: u8, - c3: u8 - } - mapping num_winners: u8 => u8; - - record board_state { - owner: address, - // The hits and misses registered on the opponent's board. - hits_and_misses: u64, - // The squares that have been played on the opponent's board. - played_tiles: u64, - // The ship bitstring representing all ship positions on your own board - ships: u64, - player_1: address, - player_2: address, - game_started: bool, - } - - transition mint(public a1: address, public a2: u64) -> credits; - - transition transfer_public(public a1: address, public a2: u64) -> exchange.aleo/tokens; - - transition transfer_private(a1: credits, a2: address, a3: u64) -> (credits, credits); - - transition transfer_private_to_public(a1: credits, public a2: address, public a3: u64) -> credits; - - transition transfer_public_to_private(public a1: address, public a2: u64) -> credits; - - transition join(a1: credits, a2: credits) -> credits; - - transition split(a1: credits, a2: u64) -> (credits, credits); - - function foo() { - let a:u8 = 1u8; - } - finalize foo() { - let c:u8 = 1u8; - } -} - -program test.aleo { - transition foo(arg1: address, arg1: u64, cred: credits.aleo/credits)->credits.aleo/credits { - credits.aleo/transfer_public(arg1, arg2); - credits.leo/transfer_public(arg1, arg2); - } -} \ No newline at end of file diff --git a/tests/tests/parser/program/stub_fail.leo b/tests/tests/parser/program/stub_fail.leo index 4bf2e8acfb..d063f26ad7 100644 --- a/tests/tests/parser/program/stub_fail.leo +++ b/tests/tests/parser/program/stub_fail.leo @@ -4,19 +4,56 @@ expectation: Fail */ stub credits.aleo { - transition split(a1: credits, a2: u64) -> (credits, credits) {} + import battleship.aleo; + import exchange.aleo; + record credits { + owner: address, + micrcredits: u64, + } + struct Row { + c1: u8, + c2: u8, + c3: u8 + } + mapping num_winners: u8 => u8; - function foo(); -} + record board_state { + owner: address, + // The hits and misses registered on the opponent's board. + hits_and_misses: u64, + // The squares that have been played on the opponent's board. + played_tiles: u64, + // The ship bitstring representing all ship positions on your own board + ships: u64, + player_1: address, + player_2: address, + game_started: bool, + } -stub big.leo { - transition split(a1: credits, a2: u64) -> (credits, credits) { - credits.aleo/split(a1, a2); + transition mint(public a1: address, public a2: u64) -> credits; + + transition transfer_public(public a1: address, public a2: u64) -> exchange.aleo/tokens; + + transition transfer_private(a1: credits, a2: address, a3: u64) -> (credits, credits); + + transition transfer_private_to_public(a1: credits, public a2: address, public a3: u64) -> credits; + + transition transfer_public_to_private(public a1: address, public a2: u64) -> credits; + + transition join(a1: credits, a2: credits) -> credits; + + transition split(a1: credits, a2: u64) -> (credits, credits); + + function foo() { + let a:u8 = 1u8; + } + finalize foo() { + let c:u8 = 1u8; } } program test.aleo { - transition foo(arg1: address, arg1: u64) { + transition foo(arg1: address, arg1: u64, cred: credits.aleo/credits)->credits.aleo/credits { credits.aleo/transfer_public(arg1, arg2); credits.leo/transfer_public(arg1, arg2); } diff --git a/tests/tests/parser/statement/definition.leo b/tests/tests/parser/statement/definition.leo index 18e1b363d7..1414287bef 100644 --- a/tests/tests/parser/statement/definition.leo +++ b/tests/tests/parser/statement/definition.leo @@ -20,6 +20,10 @@ let x: i8 = x(); let x: string = expr; +let x: credits = credits.aleo/mint_private(100u64); + +let x: credits.aleo/credits = credits.aleo/mint_private(100u64); + let x: u32 = expr;