Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Jan 21, 2023
1 parent bc13fce commit 7e45b46
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/code/contract_01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

var owner;
var value = 0;

function init(owner_) {
owner = owner_;
}

function add(count) public {
if(count > 10) {
fail("count > 10");
}
value += count;
}

function increment() public {
value++;
}

function get_value() public const {
return value;
}

function reset() public {
if(this.user != owner) {
fail("user != owner");
}
value = 0;
}

18 changes: 18 additions & 0 deletions test/code/contract_02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


function init() {}

function cross_add(value) public {
rcall("counter", "add", value);
}

function cross_increment() public {
rcall("counter", "increment");
}

function cross_read_update() public {
const value = rcall("counter", "get_value");
if(value % 2 != 0) {
rcall("counter", "increment");
}
}
9 changes: 9 additions & 0 deletions test/code/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ for(var i = 0, test = 0; i < 6; ++i, i = i + 1) {
for(const value of test) {
map = value;
}

var owner;

function check_owner() {
if (this.user != owner) {
fail("user != owner", 1);
}
var tmp = to_string_bech32(this.user);
}
9 changes: 9 additions & 0 deletions test/contracts/contract_02.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"__type": "mmx.contract.Executable",
"name": "contract_02",
"binary": "mmx1davfr6uds7hr3g7vzd4qqvzzduatkpautsdvm5s452xqjsgcwdfsrq2daz",
"init_args": [],
"depends": {
"counter": "mmx1euuy4wtcvd50nat7q2gdcr78g37j6g3r6g7yjk3z9twr2fz45lqq7p0f4z"
}
}

0 comments on commit 7e45b46

Please sign in to comment.