-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8632c37
commit 89754c9
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,54 @@ | ||
```k | ||
module MX-RUST-TESTING-PARSING-SYNTAX | ||
imports INT-SYNTAX | ||
imports MX-TEST-EXECUTION-PARSING-SYNTAX | ||
imports RUST-EXECUTION-TEST-PARSING-SYNTAX | ||
imports RUST-SHARED-SYNTAX | ||
imports RUST-VALUE-SYNTAX | ||
imports STRING-SYNTAX | ||
syntax MxRustTest ::= ExecutionTest | ||
syntax ExecutionItem ::= "set_named" String | ||
| "push_named" String | ||
| "get_bigint_from_struct" | ||
| "check_eq" Int | ||
| TestInstruction | ||
endmodule | ||
module MX-RUST-TEST | ||
imports private COMMON-K-CELL | ||
imports private MX-RUST-EXECUTION-TEST-CONFIGURATION | ||
imports private MX-RUST-TESTING-PARSING-SYNTAX | ||
imports private RUST-EXECUTION-CONFIGURATION | ||
rule | ||
<k> set_named Name:String => .K ... </k> | ||
<test-stack> ListItem(Value) => .List ... </test-stack> | ||
<test-named> M:Map => M[Name <- Value] </test-named> | ||
rule | ||
<k> push_named Name:String => .K ... </k> | ||
<test-stack> .List => ListItem(Value) ... </test-stack> | ||
<test-named> Name |-> Value ... </test-named> | ||
rule | ||
<k> | ||
ptrValue | ||
( _ | ||
, struct | ||
( #token("BigUint", "Identifier") | ||
, #token("mx_biguint_id", "Identifier"):Identifier |-> BigUintIdId _:Map | ||
) | ||
) | ||
~> get_bigint_from_struct ; Test:ExecutionTest | ||
=> push mxIntValue(MInt2Unsigned(BigUintId)) | ||
~> get_big_int | ||
~> Test | ||
... | ||
</k> | ||
<values> BigUintIdId |-> i32(BigUintId:MInt{32}) ... </values> | ||
endmodule | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
addAccount("Owner"); | ||
setCallee("Owner"); | ||
new Storage; | ||
set_named "self"; | ||
push_named "self"; | ||
push 10u64; | ||
call Storage.set_no_arg; | ||
push_named "self"; | ||
call Storage.get_no_arg; | ||
get_bigint_from_struct; | ||
check_eq mxIntValue(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![no_std] | ||
|
||
#[allow(unused_imports)] | ||
use multiversx_sc::imports::*; | ||
|
||
#[multiversx_sc::contract] | ||
pub trait Storage { | ||
#[view(noArg)] | ||
#[storage_mapper("no_arg")] | ||
fn no_arg_storage(&self) -> SingleValueMapper<BigUint>; | ||
|
||
#[view(getName)] | ||
#[storage_mapper("name")] | ||
fn one_arg_storage(&self, key: u64) -> SingleValueMapper<BigUint>; | ||
|
||
#[init] | ||
fn init(&self) {} | ||
|
||
#[upgrade] | ||
fn upgrade(&self) {} | ||
|
||
fn set_no_arg(&self, value: u64) { | ||
self.no_arg_storage().set(BigUint::from(value)) | ||
} | ||
|
||
fn get_no_arg(&self) -> BigUint { | ||
self.no_arg_storage().get() | ||
} | ||
} |