mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 10:12:21 +03:00
Add tests that should pass
This commit is contained in:
parent
ff5ce80be3
commit
0d64247b1e
17
tests/tests/compiler/finalize/decrement_via_get_set.leo
Normal file
17
tests/tests/compiler/finalize/decrement_via_get_set.leo
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
mapping amounts: address => u128;
|
||||
|
||||
transition decrease_self(amount: u128) {
|
||||
return then finalize(self.caller, amount);
|
||||
}
|
||||
|
||||
finalize decrease_self(addr: address, amount: u128) {
|
||||
let current_amount: u128 = Mapping::get_or(amounts, addr, 0u128);
|
||||
Mapping::set(amounts, addr, current_amount - amount);
|
||||
}
|
||||
}
|
37
tests/tests/compiler/finalize/finalize.leo
Normal file
37
tests/tests/compiler/finalize/finalize.leo
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
mapping account: address => u64;
|
||||
mapping values: u8 => u8;
|
||||
|
||||
transition mint_public(public receiver: address, public amount: u64) {
|
||||
return then finalize(receiver, amount);
|
||||
}
|
||||
|
||||
finalize mint_public (public receiver: address, public amount: u64) {
|
||||
let current_amount: u64 = Mapping::get_or(account, receiver, 0u64);
|
||||
Mapping::set(account, receiver, current_amount + amount);
|
||||
}
|
||||
|
||||
transition public_adder(public a: u8, public b: u8) {
|
||||
return then finalize(a, b);
|
||||
}
|
||||
|
||||
finalize public_adder(a: u8, b: u8) -> public u8 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
transition finalize_no_params() {
|
||||
return then finalize();
|
||||
}
|
||||
|
||||
finalize finalize_no_params() {
|
||||
let current_value: u8 = Mapping::get_or(values, 0u8, 0u8);
|
||||
Mapping::set(values, 0u8, current_value + 1u8);
|
||||
let current_amount: u64 = Mapping::get_or(account, self.caller, 0u64);
|
||||
Mapping::set(account, self.caller, current_amount + 1u64);
|
||||
}
|
||||
}
|
17
tests/tests/compiler/finalize/increment_via_get_set.leo
Normal file
17
tests/tests/compiler/finalize/increment_via_get_set.leo
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
mapping amounts: address => u128;
|
||||
|
||||
transition increase_self(amount: u128) {
|
||||
return then finalize(self.caller, amount);
|
||||
}
|
||||
|
||||
finalize increase_self(addr: address, amount: u128) {
|
||||
let current_amount: u128 = Mapping::get_or(amounts, addr, 0u128);
|
||||
Mapping::set(amounts, addr, current_amount + amount);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user