-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathcall-raw.mo
99 lines (79 loc) · 2.03 KB
/
call-raw.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import P "mo:⛔";
actor self {
public shared func sint() : async Int {
return 2;
};
public shared func snat() : async Nat {
return 2;
};
public shared func stext() : async Text {
return "hello";
};
public shared func stuple() : async (Nat, Bool, Char) {
return (1, true, 'a');
};
public shared func unit() : async () {
P.debugPrint("unit!");
};
public shared func int(n : Int) : async Int {
P.debugPrint(debug_show("int",n));
return n;
};
public shared func text(t : Text) : async Text {
P.debugPrint(debug_show("text", t));
return t;
};
public shared func tuple(n: Nat, b: Bool, c: Char) : async (Nat, Bool, Char) {
P.debugPrint(debug_show("text", (n, b, c)));
return (n, b, c);
};
public shared func trapInt(n : Int) : async Int {
P.trap("ohoh");
};
public shared func go() : async () {
let p = P.principalOfActor(self);
do {
let arg : Blob = "DIDL\00\00";
let res = await P.call_raw(p,"unit", arg);
assert (res == arg);
};
do {
let arg : Blob = "DIDL\00\01\7c\01";
let res = await P.call_raw(p,"int", arg);
assert (res == arg);
};
do {
let arg : Blob = "DIDL\00\01\7c\02";
let res = await P.call_raw(p,"int", arg);
assert (res == arg);
};
do {
let arg : Blob = "DIDL\00\01\71\05\68\65\6c\6c\6f";
let res = await P.call_raw(p,"text", arg);
assert (res == arg);
};
do {
let arg : Blob = "DIDL\00\03\7d\7e\79\01\01\61\00\00\00";
let res = await P.call_raw(p,"tuple", arg);
assert (res == arg);
};
do {
let arg : Blob = "DIDL\00\01\7c\01";
try {
let res = await P.call_raw(p,"trapInt", arg);
assert false;
}
catch e {
P.debugPrint(P.errorMessage(e));
}
};
}
};
//SKIP run
//SKIP run-low
//SKIP run-ir
//CALL ingress sint 0x4449444C0000
//CALL ingress snat 0x4449444C0000
//CALL ingress stext 0x4449444C0000
//CALL ingress stuple 0x4449444C0000
//CALL ingress go 0x4449444C0000