@acala-network/chopsticks-testing 0.9.1-2 → 0.9.1-3
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/dist/cjs/check.js +155 -83
- package/dist/cjs/index.js +157 -100
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/signFake.js +27 -9
- package/dist/esm/check.js +103 -119
- package/dist/esm/index.js +80 -55
- package/dist/esm/signFake.js +9 -4
- package/package.json +10 -4
- package/dist/esm/package.json +0 -1
package/dist/cjs/check.js
CHANGED
|
@@ -1,61 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
Checker: function() {
|
|
13
|
+
return Checker;
|
|
14
|
+
},
|
|
15
|
+
check: function() {
|
|
16
|
+
return check;
|
|
17
|
+
},
|
|
18
|
+
checkEvents: function() {
|
|
19
|
+
return checkEvents;
|
|
20
|
+
},
|
|
21
|
+
checkHrmp: function() {
|
|
22
|
+
return checkHrmp;
|
|
23
|
+
},
|
|
24
|
+
checkSystemEvents: function() {
|
|
25
|
+
return checkSystemEvents;
|
|
26
|
+
},
|
|
27
|
+
checkUmp: function() {
|
|
28
|
+
return checkUmp;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _vitest = require("vitest");
|
|
32
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
33
|
+
if (privateCollection.has(obj)) {
|
|
34
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
38
|
+
if (descriptor.get) {
|
|
39
|
+
return descriptor.get.call(receiver);
|
|
40
|
+
}
|
|
41
|
+
return descriptor.value;
|
|
42
|
+
}
|
|
43
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
44
|
+
if (descriptor.set) {
|
|
45
|
+
descriptor.set.call(receiver, value);
|
|
46
|
+
} else {
|
|
47
|
+
if (!descriptor.writable) {
|
|
48
|
+
throw new TypeError("attempted to set read only private field");
|
|
49
|
+
}
|
|
50
|
+
descriptor.value = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
54
|
+
if (!privateMap.has(receiver)) {
|
|
55
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
56
|
+
}
|
|
57
|
+
return privateMap.get(receiver);
|
|
58
|
+
}
|
|
59
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
60
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
61
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
62
|
+
}
|
|
63
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
64
|
+
_check_private_redeclaration(obj, privateMap);
|
|
65
|
+
privateMap.set(obj, value);
|
|
66
|
+
}
|
|
67
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
68
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
69
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
73
|
+
if (!privateSet.has(receiver)) {
|
|
74
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
31
75
|
}
|
|
76
|
+
return fn;
|
|
77
|
+
}
|
|
78
|
+
function _class_private_method_init(obj, privateSet) {
|
|
79
|
+
_check_private_redeclaration(obj, privateSet);
|
|
80
|
+
privateSet.add(obj);
|
|
81
|
+
}
|
|
82
|
+
const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
|
|
83
|
+
const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
|
|
84
|
+
const toHex = (codec)=>processCodecOrArray(codec, (c)=>c?.toHex?.() ?? c);
|
|
85
|
+
const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
|
|
86
|
+
var _value = /*#__PURE__*/ new WeakMap(), _pipeline = /*#__PURE__*/ new WeakMap(), _format = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _redactOptions = /*#__PURE__*/ new WeakMap(), _redact = /*#__PURE__*/ new WeakSet();
|
|
87
|
+
class Checker {
|
|
32
88
|
toHuman() {
|
|
33
|
-
|
|
89
|
+
_class_private_field_set(this, _format, 'human');
|
|
34
90
|
return this;
|
|
35
91
|
}
|
|
36
92
|
toHex() {
|
|
37
|
-
|
|
93
|
+
_class_private_field_set(this, _format, 'hex');
|
|
38
94
|
return this;
|
|
39
95
|
}
|
|
40
96
|
toJson() {
|
|
41
|
-
|
|
97
|
+
_class_private_field_set(this, _format, 'json');
|
|
42
98
|
return this;
|
|
43
99
|
}
|
|
44
100
|
message(message) {
|
|
45
|
-
|
|
101
|
+
_class_private_field_set(this, _message, message);
|
|
46
102
|
return this;
|
|
47
103
|
}
|
|
48
104
|
filterEvents(...filters) {
|
|
49
105
|
this.toHuman();
|
|
50
|
-
|
|
51
|
-
let data = value.map(({ event: { index: _, ...event } })
|
|
106
|
+
_class_private_field_get(this, _pipeline).push((value)=>{
|
|
107
|
+
let data = value.map(({ event: { index: _, ...event } })=>event);
|
|
52
108
|
if (filters.length > 0) {
|
|
53
|
-
data = data.filter((evt)
|
|
54
|
-
return filters.some((filter)
|
|
109
|
+
data = data.filter((evt)=>{
|
|
110
|
+
return filters.some((filter)=>{
|
|
55
111
|
if (typeof filter === 'string') {
|
|
56
112
|
return evt.section === filter;
|
|
57
|
-
}
|
|
58
|
-
else if ('method' in filter) {
|
|
113
|
+
} else if ('method' in filter) {
|
|
59
114
|
const { section, method } = filter;
|
|
60
115
|
return evt.section === section && evt.method === method;
|
|
61
116
|
}
|
|
@@ -66,23 +121,26 @@ class Checker {
|
|
|
66
121
|
});
|
|
67
122
|
return this;
|
|
68
123
|
}
|
|
69
|
-
redact(options = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
124
|
+
redact(options = {
|
|
125
|
+
number: 2,
|
|
126
|
+
hash: true
|
|
127
|
+
}) {
|
|
128
|
+
_class_private_field_set(this, _redactOptions, {
|
|
129
|
+
..._class_private_field_get(this, _redactOptions),
|
|
130
|
+
...options
|
|
131
|
+
});
|
|
74
132
|
return this;
|
|
75
133
|
}
|
|
76
134
|
map(fn) {
|
|
77
|
-
|
|
135
|
+
_class_private_field_get(this, _pipeline).push(fn);
|
|
78
136
|
return this;
|
|
79
137
|
}
|
|
80
138
|
pipe(fn) {
|
|
81
139
|
return fn ? fn(this) : this;
|
|
82
140
|
}
|
|
83
141
|
async value() {
|
|
84
|
-
let value = await
|
|
85
|
-
switch
|
|
142
|
+
let value = await _class_private_field_get(this, _value);
|
|
143
|
+
switch(_class_private_field_get(this, _format)){
|
|
86
144
|
case 'human':
|
|
87
145
|
value = toHuman(value);
|
|
88
146
|
break;
|
|
@@ -93,31 +151,51 @@ class Checker {
|
|
|
93
151
|
value = toJson(value);
|
|
94
152
|
break;
|
|
95
153
|
}
|
|
96
|
-
for (const fn of
|
|
154
|
+
for (const fn of _class_private_field_get(this, _pipeline)){
|
|
97
155
|
value = await fn(value);
|
|
98
156
|
}
|
|
99
|
-
value =
|
|
157
|
+
value = _class_private_method_get(this, _redact, redact).call(this, value);
|
|
100
158
|
return value;
|
|
101
159
|
}
|
|
102
160
|
async toMatchSnapshot(msg) {
|
|
103
|
-
return (0,
|
|
161
|
+
return (0, _vitest.expect)(await this.value()).toMatchSnapshot(msg ?? _class_private_field_get(this, _message));
|
|
162
|
+
}
|
|
163
|
+
constructor(value, message){
|
|
164
|
+
_class_private_method_init(this, _redact);
|
|
165
|
+
_class_private_field_init(this, _value, {
|
|
166
|
+
writable: true,
|
|
167
|
+
value: void 0
|
|
168
|
+
});
|
|
169
|
+
_class_private_field_init(this, _pipeline, {
|
|
170
|
+
writable: true,
|
|
171
|
+
value: []
|
|
172
|
+
});
|
|
173
|
+
_class_private_field_init(this, _format, {
|
|
174
|
+
writable: true,
|
|
175
|
+
value: 'json'
|
|
176
|
+
});
|
|
177
|
+
_class_private_field_init(this, _message, {
|
|
178
|
+
writable: true,
|
|
179
|
+
value: void 0
|
|
180
|
+
});
|
|
181
|
+
_class_private_field_init(this, _redactOptions, {
|
|
182
|
+
writable: true,
|
|
183
|
+
value: void 0
|
|
184
|
+
});
|
|
185
|
+
_class_private_field_set(this, _value, value);
|
|
186
|
+
_class_private_field_set(this, _message, message);
|
|
104
187
|
}
|
|
105
188
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!__classPrivateFieldGet(this, _Checker_redactOptions, "f")) {
|
|
189
|
+
function redact(value) {
|
|
190
|
+
if (!_class_private_field_get(this, _redactOptions)) {
|
|
109
191
|
return value;
|
|
110
192
|
}
|
|
111
|
-
const redactNumber =
|
|
112
|
-
const precision = redactNumber
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const redactHash = __classPrivateFieldGet(this, _Checker_redactOptions, "f").hash === true;
|
|
118
|
-
const redactHex = __classPrivateFieldGet(this, _Checker_redactOptions, "f").hex === true;
|
|
119
|
-
const redactAddress = __classPrivateFieldGet(this, _Checker_redactOptions, "f").address === true;
|
|
120
|
-
const processNumber = (value) => {
|
|
193
|
+
const redactNumber = _class_private_field_get(this, _redactOptions).number === true || typeof _class_private_field_get(this, _redactOptions).number === 'number';
|
|
194
|
+
const precision = redactNumber ? typeof _class_private_field_get(this, _redactOptions).number === 'number' ? _class_private_field_get(this, _redactOptions).number : 0 : 0;
|
|
195
|
+
const redactHash = _class_private_field_get(this, _redactOptions).hash === true;
|
|
196
|
+
const redactHex = _class_private_field_get(this, _redactOptions).hex === true;
|
|
197
|
+
const redactAddress = _class_private_field_get(this, _redactOptions).address === true;
|
|
198
|
+
const processNumber = (value)=>{
|
|
121
199
|
if (precision > 0) {
|
|
122
200
|
const rounded = parseFloat(value.toPrecision(precision));
|
|
123
201
|
if (rounded === value) {
|
|
@@ -127,7 +205,7 @@ _Checker_value = new WeakMap(), _Checker_pipeline = new WeakMap(), _Checker_form
|
|
|
127
205
|
}
|
|
128
206
|
return '(number)';
|
|
129
207
|
};
|
|
130
|
-
const process = (obj)
|
|
208
|
+
const process = (obj)=>{
|
|
131
209
|
if (obj == null) {
|
|
132
210
|
return obj;
|
|
133
211
|
}
|
|
@@ -159,13 +237,16 @@ _Checker_value = new WeakMap(), _Checker_pipeline = new WeakMap(), _Checker_form
|
|
|
159
237
|
return obj;
|
|
160
238
|
}
|
|
161
239
|
if (typeof obj === 'object') {
|
|
162
|
-
return Object.fromEntries(Object.entries(obj).map(([k, v])
|
|
240
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v])=>[
|
|
241
|
+
k,
|
|
242
|
+
process(v)
|
|
243
|
+
]));
|
|
163
244
|
}
|
|
164
245
|
return obj;
|
|
165
246
|
};
|
|
166
247
|
return process(value);
|
|
167
|
-
}
|
|
168
|
-
const check = (value, msg)
|
|
248
|
+
}
|
|
249
|
+
const check = (value, msg)=>{
|
|
169
250
|
if (value instanceof Checker) {
|
|
170
251
|
if (msg) {
|
|
171
252
|
return value.message(msg);
|
|
@@ -174,19 +255,10 @@ const check = (value, msg) => {
|
|
|
174
255
|
}
|
|
175
256
|
return new Checker(value, msg);
|
|
176
257
|
};
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.redact();
|
|
185
|
-
exports.checkSystemEvents = checkSystemEvents;
|
|
186
|
-
const checkUmp = ({ api }) => (0, exports.check)(api.query.parachainSystem.upwardMessages(), 'ump').map((value) => api.createType('Vec<XcmVersionedXcm>', value).toJSON());
|
|
187
|
-
exports.checkUmp = checkUmp;
|
|
188
|
-
const checkHrmp = ({ api }) => (0, exports.check)(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value) => value.map(({ recipient, data }) => ({
|
|
189
|
-
data: api.createType('(XcmpMessageFormat, XcmVersionedXcm)', data),
|
|
190
|
-
recipient,
|
|
191
|
-
})));
|
|
192
|
-
exports.checkHrmp = checkHrmp;
|
|
258
|
+
const checkEvents = ({ events }, ...filters)=>check(events, 'events').filterEvents(...filters).redact();
|
|
259
|
+
const checkSystemEvents = ({ api }, ...filters)=>check(api.query.system.events(), 'system events').filterEvents(...filters).redact();
|
|
260
|
+
const checkUmp = ({ api })=>check(api.query.parachainSystem.upwardMessages(), 'ump').map((value)=>api.createType('Vec<XcmVersionedXcm>', value).toJSON());
|
|
261
|
+
const checkHrmp = ({ api })=>check(api.query.parachainSystem.hrmpOutboundMessages(), 'hrmp').map((value)=>value.map(({ recipient, data })=>({
|
|
262
|
+
data: api.createType('(XcmpMessageFormat, XcmVersionedXcm)', data),
|
|
263
|
+
recipient
|
|
264
|
+
})));
|