MCPcopy Create free account
hub / github.com/DNAProject/DNA / test_native_ont

Method test_native_ont

wasmtest/contracts-cplus/test_native.cpp:18–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 public:
17 using contract::contract;
18 uint128_t test_native_ont(string &method, address &from, address &to, asset &amount, test_conext &tc) {
19 if (method == "balanceOf") {
20 asset balance = ont::balanceof(tc.admin);
21 check(balance == 1000000000, "init balance wrong");
22 } else if (method == "transfer") {
23 /*keep admin alway initbalance.*/
24 check(ont::transfer(tc.admin, to, amount), "transfer failed");
25 check(ont::balanceof(to) == amount, "transfer amount wrong");
26 check(ont::transfer(to, tc.admin, amount), "transfer failed");
27 check(ont::balanceof(to) == 0, "transfer amount wrong");
28 } else if (method == "approve") {
29 /*keep admin alway initbalance.*/
30 check(ont::approve(tc.admin, from, amount),"approve failed");
31 check(ont::allowance(tc.admin, from) == amount, "allowance amount wrong");
32 check(ont::transferfrom(from, tc.admin, to, amount),"transferfrom failed");
33 check(ont::allowance(tc.admin, from) == 0, "allowance amount wrong");
34 check(ont::balanceof(to) == amount, "transfer amount wrong");
35 check(ont::transfer(to, tc.admin, amount), "transfer failed");
36 check(ont::balanceof(to) == 0, "transfer amount wrong");
37 check(ont::balanceof(from) == 0, "transfer amount wrong");
38 }
39
40 return 1;
41 }
42
43 string testcase(void) {
44 return string(R"(

Callers

nothing calls this directly

Calls 3

allowanceFunction · 0.85
transferFunction · 0.70
approveFunction · 0.70

Tested by

no test coverage detected