@layerzerolabs/layerzero-v2-ton 3.0.28 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +2 -1
- package/tests/baseSerdeTest.fc +117 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/layerzero-v2-ton",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.29",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"src/jettons/zro/*.fc",
|
|
37
37
|
"tests/testMain.fc",
|
|
38
38
|
"tests/baseContractTest.fc",
|
|
39
|
+
"tests/baseSerdeTest.fc",
|
|
39
40
|
"src/multisig/bocs/MultiSig.compiled.json",
|
|
40
41
|
"src/multisig/bocs/MultiSigOrder.compiled.json"
|
|
41
42
|
],
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#include "./testMain.fc";
|
|
2
|
+
#include "../src/funC++/classlib.fc";
|
|
3
|
+
#include "../src/funC++/stringlib.fc";
|
|
4
|
+
|
|
5
|
+
cell baseTest::prepare(tuple args) impure {
|
|
6
|
+
return cl::nullObject();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
;;; ===============================TEST HANDLERS===============================
|
|
10
|
+
|
|
11
|
+
;; int TEST_SUCCESS or TEST_FAILURE, slice (optional) error_message
|
|
12
|
+
(int, slice) test::build::equal(cell $newObject, cell $buildObject) impure {
|
|
13
|
+
if ($newObject.cl::hash() != $buildObject.cl::hash()) {
|
|
14
|
+
~strdump("::new output does not match ::build");
|
|
15
|
+
int wrongField = compareObjectFields($newObject, $buildObject);
|
|
16
|
+
if (wrongField == INVALID_CLASS_MEMBER) {
|
|
17
|
+
return (
|
|
18
|
+
TEST_FAILED,
|
|
19
|
+
"Object and expected object not of the same type"
|
|
20
|
+
);
|
|
21
|
+
} elseif (wrongField != -1) {
|
|
22
|
+
return (
|
|
23
|
+
TEST_FAILED,
|
|
24
|
+
"malformed field ".str::concatInt(wrongField)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return (TEST_SUCCESS, "");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(int, slice) test::getBool::equal(cell $obj, (cell -> int) getter, int field) impure {
|
|
32
|
+
int expected = $obj.cl::get<bool>(field);
|
|
33
|
+
int actual = getter($obj);
|
|
34
|
+
if (expected != actual) {
|
|
35
|
+
return (TEST_FAILED, "expected: ".str::concatInt(expected).str::concat(" != actual: ").str::concatInt(actual));
|
|
36
|
+
}
|
|
37
|
+
return (TEST_SUCCESS, "");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
(int, slice) test::getData::equal(cell $obj, (cell -> int) getter, int field) impure {
|
|
41
|
+
int width = _getTypeWidth(typeofField($obj, field));
|
|
42
|
+
int expected = $obj.cl::get<uint>(field, width);
|
|
43
|
+
int actual = getter($obj);
|
|
44
|
+
if (expected != actual) {
|
|
45
|
+
return (TEST_FAILED, "expected: ".str::concatInt(expected).str::concat(" != actual: ").str::concatInt(actual));
|
|
46
|
+
}
|
|
47
|
+
return (TEST_SUCCESS, "");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
(int, slice) test::getRef::equal(cell $obj, (cell -> cell) getter, int fieldId) impure {
|
|
51
|
+
cell expected = $obj.cl::get<cellRef>(fieldId);
|
|
52
|
+
cell actual = getter($obj);
|
|
53
|
+
if (expected.cell_hash() != actual.cell_hash()) {
|
|
54
|
+
return (TEST_FAILED, "expected != actual");
|
|
55
|
+
}
|
|
56
|
+
return (TEST_SUCCESS, "");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(int, slice) test::multiget::equal(cell $object, tuple keys, tuple expected) impure {
|
|
60
|
+
tuple actual = empty_tuple();
|
|
61
|
+
int idx = 0;
|
|
62
|
+
|
|
63
|
+
while (idx < keys.tlen()) {
|
|
64
|
+
int key = keys.int_at(idx);
|
|
65
|
+
int typeOfKey = typeofField($object, key);
|
|
66
|
+
int fieldBits = _getTypeWidth(typeOfKey);
|
|
67
|
+
if (typeOfKey == cl::t::bool) {
|
|
68
|
+
actual~tpush($object.cl::get<bool>(key));
|
|
69
|
+
} elseif (typeOfKey <= cl::t::uint256) {
|
|
70
|
+
actual~tpush($object.cl::get<uint>(key, fieldBits));
|
|
71
|
+
} else {
|
|
72
|
+
actual~tpush($object.cl::get<cellRef>(key));
|
|
73
|
+
}
|
|
74
|
+
idx += 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (expected.tlen() != actual.tlen()) {
|
|
78
|
+
return (TEST_FAILED, "expected length: ".str::concatInt(expected.tlen()).str::concat(" != actual length: ").str::concatInt(actual.tlen()));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
int idx = 0;
|
|
82
|
+
while (idx < expected.tlen()) {
|
|
83
|
+
if (expected.at(idx).is_cell() & actual.at(idx).is_cell()) {
|
|
84
|
+
if (expected.at(idx).cell_hash() != actual.at(idx).cell_hash()) {
|
|
85
|
+
return (TEST_FAILED, "expected cell != actual cell");
|
|
86
|
+
}
|
|
87
|
+
} elseif (expected.at(idx).is_int() & actual.at(idx).is_int()) {
|
|
88
|
+
if (expected.at(idx) != actual.at(idx)) {
|
|
89
|
+
return (TEST_FAILED, "expected: ".str::concatInt(expected.at(idx)).str::concat(" != actual: ").str::concatInt(actual.at(idx)));
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
return (TEST_FAILED, "type mismatch at idx ".str::concatInt(idx));
|
|
93
|
+
}
|
|
94
|
+
idx += 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (TEST_SUCCESS, "");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
(int, slice) test::set::equal(cell $expected, cell $actual) impure {
|
|
101
|
+
if ($expected.cl::hash() != $actual.cl::hash()) {
|
|
102
|
+
~strdump("::set output does not match ::get");
|
|
103
|
+
int wrongField = compareObjectFields($expected, $actual);
|
|
104
|
+
if (wrongField == INVALID_CLASS_MEMBER) {
|
|
105
|
+
return (
|
|
106
|
+
TEST_FAILED,
|
|
107
|
+
"Object and expected object not of the same type"
|
|
108
|
+
);
|
|
109
|
+
} elseif (wrongField != -1) {
|
|
110
|
+
return (
|
|
111
|
+
TEST_FAILED,
|
|
112
|
+
"malformed field ".str::concatInt(wrongField)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return (TEST_SUCCESS, "");
|
|
117
|
+
}
|