Update tests and fix

This commit is contained in:
Pranav Gaddamadugu 2024-05-13 11:09:15 -07:00
parent c378e090d7
commit d2b1d055ce
21 changed files with 92 additions and 99 deletions

View File

@ -7,14 +7,14 @@ program lottery.aleo {
owner: address, owner: address,
} }
transition play() -> Ticket { async transition play() -> (Ticket, Future) {
let ticket: Ticket = Ticket { let ticket: Ticket = Ticket {
owner: self.caller, owner: self.caller,
}; };
return ticket then finalize(); return (ticket, finalize_play());
} }
finalize play() { async function finalize_play() {
// Check that the lottery has not expired. // Check that the lottery has not expired.
assert(block.height <= 1000u32); assert(block.height <= 1000u32);

View File

@ -13,12 +13,12 @@ program token.aleo {
/* Mint */ /* Mint */
// The function `mint_public` issues the specified token amount for the token receiver publicly on the network. // The function `mint_public` issues the specified token amount for the token receiver publicly on the network.
transition mint_public(public receiver: address, public amount: u64) { async transition mint_public(public receiver: address, public amount: u64) -> Future {
// Mint the tokens publicly by invoking the computation on-chain. // Mint the tokens publicly by invoking the computation on-chain.
return then finalize(receiver, amount); return finalize_mint_public(receiver, amount);
} }
finalize mint_public(public receiver: address, public amount: u64) { async function finalize_mint_public(public receiver: address, public amount: u64) {
// Increments `account[receiver]` by `amount`. // Increments `account[receiver]` by `amount`.
// If `account[receiver]` does not exist, it will be created. // If `account[receiver]` does not exist, it will be created.
// If `account[receiver] + amount` overflows, `mint_public` is reverted. // If `account[receiver] + amount` overflows, `mint_public` is reverted.
@ -35,12 +35,12 @@ program token.aleo {
} }
/* Transfer */ /* Transfer */
transition transfer_public(public receiver: address, public amount: u64) { async transition transfer_public(public receiver: address, public amount: u64) -> Future {
// Transfer the tokens publicly, by invoking the computation on-chain. // Transfer the tokens publicly, by invoking the computation on-chain.
return then finalize(self.caller, receiver, amount); return finalize_transfer_public(self.caller, receiver, amount);
} }
finalize transfer_public(public sender: address, public receiver: address, public amount: u64) { async function finalize_transfer_public(public sender: address, public receiver: address, public amount: u64) {
// Decrements `account[sender]` by `amount`. // Decrements `account[sender]` by `amount`.
// If `account[sender]` does not exist, it will be created. // If `account[sender]` does not exist, it will be created.
// If `account[sender] - amount` underflows, `transfer_public` is reverted. // If `account[sender] - amount` underflows, `transfer_public` is reverted.
@ -78,7 +78,7 @@ program token.aleo {
// The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver. // The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver.
// This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount. // This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount.
transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> token { async transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> (token, Future) {
// Checks the given token record has a sufficient token amount. // Checks the given token record has a sufficient token amount.
// This `sub` operation is safe, and the proof will fail if an underflow occurs. // This `sub` operation is safe, and the proof will fail if an underflow occurs.
// `difference` holds the change amount for the caller. // `difference` holds the change amount for the caller.
@ -92,10 +92,10 @@ program token.aleo {
// Output the sender's change record. // Output the sender's change record.
// Increment the token amount publicly for the token receiver. // Increment the token amount publicly for the token receiver.
return remaining then finalize(receiver, amount); return (remaining, finalize_transfer_private_to_public(receiver, amount));
} }
finalize transfer_private_to_public(public receiver: address, public amount: u64) { async function finalize_transfer_private_to_public(public receiver: address, public amount: u64) {
// Increments `account[receiver]` by `amount`. // Increments `account[receiver]` by `amount`.
// If `account[receiver]` does not exist, it will be created. // If `account[receiver]` does not exist, it will be created.
// If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted. // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted.
@ -105,7 +105,7 @@ program token.aleo {
// The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver. // The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver.
// This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount. // This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount.
transition transfer_public_to_private(public receiver: address, public amount: u64) -> token { async transition transfer_public_to_private(public receiver: address, public amount: u64) -> (token, Future) {
// Produces a token record for the token receiver. // Produces a token record for the token receiver.
let transferred: token = token { let transferred: token = token {
owner: receiver, owner: receiver,
@ -114,10 +114,10 @@ program token.aleo {
// Output the receiver's record. // Output the receiver's record.
// Decrement the token amount of the caller publicly. // Decrement the token amount of the caller publicly.
return transferred then finalize(self.caller, amount); return (transferred, finalize_transfer_public_to_private(self.caller, amount));
} }
finalize transfer_public_to_private(public sender: address, public amount: u64) { async function finalize_transfer_public_to_private(public sender: address, public amount: u64) {
// Decrements `account[sender]` by `amount`. // Decrements `account[sender]` by `amount`.
// If `account[sender]` does not exist, it will be created. // If `account[sender]` does not exist, it will be created.
// If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted. // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted.

View File

@ -83,7 +83,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
} }
// If the variable exists and its in an async function, then check that it is in the current scope. // If the variable exists and its in an async function, then check that it is in the current scope.
if self.scope_state.is_async // Note that this unwrap is safe because the scope state is initalized before traversing the function.
if self.scope_state.variant.unwrap().is_async_function()
&& self.scope_state.is_conditional && self.scope_state.is_conditional
&& self && self
.symbol_table .symbol_table

View File

@ -41,8 +41,6 @@ pub struct ScopeState {
pub(crate) is_call: bool, pub(crate) is_call: bool,
/// Location of most recent external call that produced a future. /// Location of most recent external call that produced a future.
pub(crate) call_location: Option<Location>, pub(crate) call_location: Option<Location>,
/// Whether currently traversing an async function.
pub(crate) is_async: bool,
} }
impl ScopeState { impl ScopeState {
@ -60,7 +58,6 @@ impl ScopeState {
is_conditional: false, is_conditional: false,
is_call: false, is_call: false,
call_location: None, call_location: None,
is_async: false,
} }
} }

View File

@ -3,16 +3,16 @@ namespace: Compile
expectation: Pass expectation: Pass
outputs: outputs:
- - compile: - - compile:
- initial_symbol_table: f159adcd5ea24c580a6b8535b217667a40173809e5802a0b03db3dc5b9bec9aa - initial_symbol_table: 9093a20a62879f03d6a7a4dc24b051778d2c543d1df6a59af8c423d047ec2e13
type_checked_symbol_table: 9fd0ee7288d5151305f4cd3820594bd9db7accb589bc936e186709af1df6de21 type_checked_symbol_table: 639ed2aefe557daf6c3433d645bec25030a82e3296f26ac46961f451d2bb28ae
unrolled_symbol_table: 9fd0ee7288d5151305f4cd3820594bd9db7accb589bc936e186709af1df6de21 unrolled_symbol_table: 639ed2aefe557daf6c3433d645bec25030a82e3296f26ac46961f451d2bb28ae
initial_ast: 21db64864f84959ad71dace62a2487285c3b6bb74818536b83a54b63a2bd8d82 initial_ast: da0a545e9de3b8cdec100132e7d9886d08b7e69217d129229e8a86489199ec21
unrolled_ast: 21db64864f84959ad71dace62a2487285c3b6bb74818536b83a54b63a2bd8d82 unrolled_ast: da0a545e9de3b8cdec100132e7d9886d08b7e69217d129229e8a86489199ec21
ssa_ast: d4e2a516deaa30f8663bb3cd1501c52e3cc781b330dbb149ee3bad0692a8cb59 ssa_ast: f76c8e4b70096ec05a1583648b295127d0a60d8b9973a1d5c7dff53782282c1d
flattened_ast: 175fbd23f91421e3d47440c8a7e00fb9e3a2bef1147e061cd8a3f2bd0c978098 flattened_ast: d743a19b1faa6b66b90bd8496249cc5b94e9ba8260ad7ce95da721b68e59c3a9
destructured_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 destructured_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4
inlined_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 inlined_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4
dce_ast: a23caa23b3ac10d6c2a1b119af502a9ec4380cf521eb65da2c9e2a5f19d44172 dce_ast: d36731bec3ce6fd1c46b5660340e8e396fb874b0c3d3f6ae407e5f55aeb07aa4
bytecode: d9e6c28f9e5527abe9cdb07b9d35375901446415f5d645b0363597200ee45be7 bytecode: d9e6c28f9e5527abe9cdb07b9d35375901446415f5d645b0363597200ee45be7
errors: "" errors: ""
warnings: "" warnings: ""

View File

@ -3,16 +3,16 @@ namespace: Compile
expectation: Pass expectation: Pass
outputs: outputs:
- - compile: - - compile:
- initial_symbol_table: 02b83350abcecb36109bf268cf52b9fc867ab1893c49badf31ff527156528943 - initial_symbol_table: ef5cbe43fd02c4bdf9de14a42e77c7f1635e0ee8df54b45b71d9a82bae42e8eb
type_checked_symbol_table: 1ace971bd20adb9ce07f802070f05c51733af791ef32c7b1130d4a4b2182768d type_checked_symbol_table: 85e41486c103f9351c482a271ae2cc9e89eb37b36a50f786bff51feaf6537034
unrolled_symbol_table: 1ace971bd20adb9ce07f802070f05c51733af791ef32c7b1130d4a4b2182768d unrolled_symbol_table: 85e41486c103f9351c482a271ae2cc9e89eb37b36a50f786bff51feaf6537034
initial_ast: 6dc0a710ab752f571f4dae9fdb172a7fa1c43e3af3858cbc8cf96c5d510a0c3a initial_ast: ad760a62ddcf6370800d4319ce4b0c48832cdf7442c2ad6b2fc244b7d9c8bbd7
unrolled_ast: 6dc0a710ab752f571f4dae9fdb172a7fa1c43e3af3858cbc8cf96c5d510a0c3a unrolled_ast: ad760a62ddcf6370800d4319ce4b0c48832cdf7442c2ad6b2fc244b7d9c8bbd7
ssa_ast: e09d30595377e81788433b702f76f1338ff4bb720f8564e2560e5f78ebd18bc0 ssa_ast: 5f2251b6411d4843954be231b25beee450771b068de30ca66cdcbd0f6b371357
flattened_ast: 16df732ae63243e249201817b30ae02b8a190072d39894648607970eb2b09192 flattened_ast: aba52a6d70cd6fc0ae608ca6853b8e41b720ce3ff7b4d67274c92e35d2269749
destructured_ast: b2f615fbb0825b50c961b4014e2e2d60117b543cab0d2e1acd4f3237c878e95e destructured_ast: c2c04fdc548c372848fb69f8201af5a5657d8acbceb2ef7bea7a109ece2e9851
inlined_ast: d3f7291df3faf6f8a4893b91133fe183d44c35f3d9c4b9d270d71f943482f965 inlined_ast: 663c8ee124bbb7a55247b2f5ce18443687e3262f9874bad35f21f65dbbf09a83
dce_ast: d3f7291df3faf6f8a4893b91133fe183d44c35f3d9c4b9d270d71f943482f965 dce_ast: 663c8ee124bbb7a55247b2f5ce18443687e3262f9874bad35f21f65dbbf09a83
bytecode: ae04a04e7ffb01dfdd0ae0249f31649302bc120ea928c5ace16bc0879140e1f9 bytecode: ae04a04e7ffb01dfdd0ae0249f31649302bc120ea928c5ace16bc0879140e1f9
errors: "" errors: ""
warnings: "" warnings: ""

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: outputs:
- "Error [EPAR0370005]: expected ; -- found 'then'\n --> compiler-test:5:22\n |\n 5 | return a + b then finalize(a, b);\n | ^^^^" - "Error [ETYC0372110]: A `transition` cannot return a future.\n --> compiler-test:4:35\n |\n 4 | function foo(a: u8, b: u8) -> Future {\n | ^^^^^^\n |\n = Use an `async transition` instead.\nError [ETYC0372042]: Only `inline` can be called from a `function` or `inline`.\n --> compiler-test:5:16\n |\n 5 | return finalize_bar(a, b);\n | ^^^^^^^^^^^^^^^^^^\nError [ETYC0372101]: Can only make an async call from an async transition.\n --> compiler-test:5:16\n |\n 5 | return finalize_bar(a, b);\n | ^^^^^^^^^^^^^^^^^^\n |\n = Move the async call inside of the async transition block.\nError [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:12:5\n |\n 12 | async function finalize_bar(a: u8, b: u8) -> u8 {\n 13 | return a + b;\n 14 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372110]: A `transition` cannot return a future.\n --> compiler-test:17:61\n |\n 17 | function mint_public(receiver: address, amount: u64) -> Future {\n | ^^^^^^\n |\n = Use an `async transition` instead.\nError [ETYC0372042]: Only `inline` can be called from a `function` or `inline`.\n --> compiler-test:18:16\n |\n 18 | return finalize_mint(receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372101]: Can only make an async call from an async transition.\n --> compiler-test:18:16\n |\n 18 | return finalize_mint(receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Move the async call inside of the async transition block.\nError [ETYC0372005]: Unknown variable `account`\n --> compiler-test:22:22\n |\n 22 | Mapping::set(account, receiver, amount);\n | ^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: outputs:
- "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:8:21\n |\n 8 | return then finalize(receiver, amount);\n | ^^^^^^^^" - "Error [EAST0372006]: function `finalize_no_params` shadowed by\n --> compiler-test:27:5\n |\n 27 | async function finalize_no_params() {\n 28 | increment(values, 0u8, 1u8);\n 29 | increment(account, self.caller, 1u64);\n 30 | }\n | ^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_use, set, remove, contains}` for manipulating on-chain mappings."

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: outputs:
- "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:7:21\n |\n 7 | return then finalize(receiver, amount);\n | ^^^^^^^^" - "Error [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372032]: An input to an async function must be public.\n --> compiler-test:10:76\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n | ^^^^^^\n |\n = Use a `public` modifier to the input variable declaration or remove the visibility modifier entirely.\nError [ETYC0372038]: A returned value cannot be a constant.\n --> compiler-test:10:101\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n | ^^^\nError [ETYC0372036]: Function must return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | }\n | ^\nError [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:18:5\n |\n 18 | async function finalize_mint_public2(public receiver: address, amount: u64) -> u64 {\n 19 | Mapping::set(account, receiver, amount);\n 20 | return amount + amount;\n 21 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\n"

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: outputs:
- "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:7:21\n |\n 7 | return then finalize(receiver, amount);\n | ^^^^^^^^" - "Error [ETYC0372106]: An async function is not allowed to return a value.\n --> compiler-test:10:5\n |\n 10 | async function finalize_mint_public(public receiver: address, public amount: u64) -> u64 {\n 11 | Mapping::set(account, receiver, amount);\n 12 | return 1u8 + 2u8;\n 13 | }\n | ^\n |\n = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written.\nError [ETYC0372003]: Expected type `u64` but type `u8` was found\n --> compiler-test:12:16\n |\n 12 | return 1u8 + 2u8;\n | ^^^\nError [ETYC0372003]: Expected type `u64` but type `u8` was found\n --> compiler-test:12:22\n |\n 12 | return 1u8 + 2u8;\n | ^^^\n"

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: outputs:
- "Error [EPAR0370005]: expected ; -- found 'finalize'\n --> compiler-test:11:21\n |\n 11 | return then finalize();\n | ^^^^^^^^" - "Error [ETYC0372109]: Cannot re-assign to `try_get_token` from a conditional scope to an outer scope in an async function.\n --> compiler-test:16:13\n |\n 16 | let try_get_token: TokenInfo = Mapping::get_or_use(\n | ^^^^^^^^^^^^^\n |\n = This is a fundamental restriction that can often be avoided by using a ternary operator `?` or re-declaring the variable in the current scope. In the future, ARC XXXX (https://github.com/AleoHQ/ARCs) will support more complex assignments in async functions.\n"

View File

@ -4,15 +4,15 @@ expectation: Pass
outputs: outputs:
- - compile: - - compile:
- initial_symbol_table: 56c4eea018bad5b00fa3584917fe6327a28220606b7ef3392dd4f52510eb836d - initial_symbol_table: 56c4eea018bad5b00fa3584917fe6327a28220606b7ef3392dd4f52510eb836d
type_checked_symbol_table: 9aef8c132cabed231ccd4e6f52d22aeeb6ab58e8b4a6c1495ed006b362dc9300 type_checked_symbol_table: a53c4315ffbe58449d9ef772a8fab06c43082a1d24d3eb4240fd8c3be3ac0ad1
unrolled_symbol_table: 9aef8c132cabed231ccd4e6f52d22aeeb6ab58e8b4a6c1495ed006b362dc9300 unrolled_symbol_table: a53c4315ffbe58449d9ef772a8fab06c43082a1d24d3eb4240fd8c3be3ac0ad1
initial_ast: 673ddb7aefe2c0b9730729803ed75d8872403283c84d98a54d7fc6523ded8910 initial_ast: 31d6210343f8a439e9a731aa2b344a0a35bb4828fcbfb5b7f3d3c532aa0d49e0
unrolled_ast: 673ddb7aefe2c0b9730729803ed75d8872403283c84d98a54d7fc6523ded8910 unrolled_ast: 31d6210343f8a439e9a731aa2b344a0a35bb4828fcbfb5b7f3d3c532aa0d49e0
ssa_ast: 16e3251569666681488bebdd375c59699798513d504a0b425276804e48a4bb05 ssa_ast: ed0d528c739439b087da26d083d1a1c6705e5e9b020f6dbb6d1510929df3079f
flattened_ast: b5c04913c1c93e7d83d43110ff20867d47638939ae3f9c14c72c20093d3541d8 flattened_ast: 6022517c96f9f27f698a3763e2745248829606c98f0089a6ec969c21e46c17e8
destructured_ast: 3cae3c5514a1f66dd417a45e5459abaf68f6ca1c16c0869144b275b7f3ddf35d destructured_ast: d3da411156bdf490343160266cbc638347e8699097e129137eaf2eb328d5227c
inlined_ast: 9a915933070f37ae3a89bca25e56d4a085b05fea61ea7e7cc2a524b498b1dc1d inlined_ast: ab6e5a75c050c438cf92aeb65992405668b7587c04c088d5b158a9bbecf31c55
dce_ast: 9a915933070f37ae3a89bca25e56d4a085b05fea61ea7e7cc2a524b498b1dc1d dce_ast: ab6e5a75c050c438cf92aeb65992405668b7587c04c088d5b158a9bbecf31c55
bytecode: d6edcce70bf27b2fad397a62ae0bee08448a0c157d89e49867d843d83a04bfb7 bytecode: d6edcce70bf27b2fad397a62ae0bee08448a0c157d89e49867d843d83a04bfb7
errors: "" errors: ""
warnings: "" warnings: ""

View File

@ -16,14 +16,13 @@ outputs:
variant: Function variant: Function
identifier: "{\"id\":\"2\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":34,\\\"hi\\\":38}\"}" identifier: "{\"id\":\"2\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":34,\\\"hi\\\":38}\"}"
input: input:
- Internal: - identifier: "{\"id\":\"3\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":39,\\\"hi\\\":40}\"}"
identifier: "{\"id\":\"3\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":39,\\\"hi\\\":40}\"}" mode: None
mode: None type_: Address
type_: Address span:
span: lo: 39
lo: 39 hi: 40
hi: 40 id: 4
id: 4
output: [] output: []
output_type: Unit output_type: Unit
block: block:

View File

@ -25,14 +25,13 @@ outputs:
variant: Transition variant: Transition
identifier: "{\"id\":\"4\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":70,\\\"hi\\\":74}\"}" identifier: "{\"id\":\"4\",\"name\":\"main\",\"span\":\"{\\\"lo\\\":70,\\\"hi\\\":74}\"}"
input: input:
- Internal: - identifier: "{\"id\":\"5\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":75,\\\"hi\\\":76}\"}"
identifier: "{\"id\":\"5\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":75,\\\"hi\\\":76}\"}" mode: None
mode: None type_: Address
type_: Address span:
span: lo: 75
lo: 75 hi: 76
hi: 76 id: 6
id: 6
output: [] output: []
output_type: Unit output_type: Unit
block: block:

View File

@ -4,8 +4,8 @@ expectation: Fail
*/ */
program test.aleo { program test.aleo {
function foo(a: u8, b: u8) -> u8 { function foo(a: u8, b: u8) -> Future {
return a + b then finalize(a, b); return finalize_bar(a, b);
} }
function bar(a: u8, b: u8) -> u8 { function bar(a: u8, b: u8) -> u8 {

View File

@ -8,26 +8,26 @@ program test.aleo {
mapping values: u8 => u8; mapping values: u8 => u8;
async transition mint_public(public receiver: address, public amount: u64) -> Future { async transition mint_public(public receiver: address, public amount: u64) -> Future {
return then finalize(receiver, amount); return finalize_mint_public(receiver, amount);
} }
finalize mint_public (public receiver: address, public amount: u64) { async function finalize_mint_public(public receiver: address, public amount: u64) {
increment(account, receiver, amount); increment(account, receiver, amount);
} }
transition public_adder(public a: u8, public b: u8) { async transition public_adder(public a: u8, public b: u8) -> Future {
return then finalize(a, b); return finalize_public_adder(a, b);
} }
finalize public_adder(a: u8, b: u8) -> public u8 { async function finalize_public_adder(a: u8, b: u8) -> public u8 {
return a + b; return a + b;
} }
transition finalize_no_params() { async transition finalize_no_params() -> Future {
return then finalize(); return finalize_no_params();
} }
finalize finalize_no_params() { async function finalize_no_params() {
increment(values, 0u8, 1u8); increment(values, 0u8, 1u8);
increment(account, self.caller, 1u64); increment(account, self.caller, 1u64);
} }

View File

@ -6,19 +6,19 @@ expectation: Fail
program test.aleo { program test.aleo {
mapping account: address => u64; mapping account: address => u64;
transition mint_public(public receiver: address, public amount: u64) { async transition mint_public(public receiver: address, public amount: u64) -> Future {
return then finalize(receiver, amount); return finalize_mint_public(receiver, amount);
} }
finalize mint_public (public receiver: address, constant amount: u64) -> constant u64 { async function finalize_mint_public(public receiver: address, constant amount: u64) -> constant u64 {
Mapping::set(account, receiver, amount); Mapping::set(account, receiver, amount);
} }
transition mint_public2(public receiver: address, public amount: u64) { async transition mint_public2(public receiver: address, public amount: u64) -> Future {
return then finalize(receiver, amount); return finalize_mint_public2(receiver, amount);
} }
finalize mint_public2(public receiver: address, amount: u64) -> u64 { async function finalize_mint_public2(public receiver: address, amount: u64) -> u64 {
Mapping::set(account, receiver, amount); Mapping::set(account, receiver, amount);
return amount + amount; return amount + amount;
} }

View File

@ -6,11 +6,11 @@ expectation: Fail
program test.aleo { program test.aleo {
mapping account: address => u64; mapping account: address => u64;
transition mint_public(public receiver: address, public amount: u64) { async transition mint_public(public receiver: address, public amount: u64) -> Future {
return then finalize(receiver, amount); return finalize_mint_public(receiver, amount);
} }
finalize mint_public(public receiver: address, public amount: u64) -> u64 { async function finalize_mint_public(public receiver: address, public amount: u64) -> u64 {
Mapping::set(account, receiver, amount); Mapping::set(account, receiver, amount);
return 1u8 + 2u8; return 1u8 + 2u8;
} }

View File

@ -12,12 +12,12 @@ program test.aleo {
mapping token_name_to_info: field => TokenInfo; mapping token_name_to_info: field => TokenInfo;
transition add_new_liquidity_token_2 () { async transition add_new_liquidity_token_2() -> Future {
return then finalize(); return finalize_add_new_liquidity_token_2();
} }
finalize add_new_liquidity_token_2() { async function finalize_add_new_liquidity_token_2() {
let try_get_token: TokenInfo = Mapping::get_or_use( let try_get_token: TokenInfo = Mapping::get_or_use(
token_name_to_info, token_name_to_info,
0field, 0field,

View File

@ -44,11 +44,8 @@ program test.aleo {
0field, 0field,
TokenInfo { id: 0u64 } TokenInfo { id: 0u64 }
); );
if try_get_token.id == 0u64 { try_get_token = (try_get_token.id == 0u64) ? TokenInfo { id: 10u64 } : try_get_token;
try_get_token = TokenInfo { id: 10u64 }; return;
} else {
return;
}
} }
} }

View File

@ -6,11 +6,11 @@ expectation: Fail
program relay.aleo { program relay.aleo {
mapping users: address => bool; mapping users: address => bool;
transition send(addr: address) { transition send(addr: address) -> Future {
let a: mapping = relay.aleo/users; let a: mapping = relay.aleo/users;
return then finalize(addr); return finalize_send(addr);
} }
async function finalize_send(addr: address) { async function finalize_send(addr: address) {
let a:bool = Mapping::get(relay.aleo/users, addr); let a:bool = Mapping::get(relay.aleo/users, addr);
} }
} }