@acala-network/chopsticks-testing 0.9.2-3 → 0.9.2-5
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/index.js +1 -179
- package/dist/esm/index.js +1 -158
- package/dist/types/index.d.ts +2 -99
- package/package.json +2 -2
- package/dist/cjs/signFake.js +0 -40
- package/dist/esm/signFake.js +0 -22
- package/dist/types/signFake.d.ts +0 -6
package/dist/cjs/index.js
CHANGED
|
@@ -9,12 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
createConfig: function() {
|
|
13
|
-
return createConfig;
|
|
14
|
-
},
|
|
15
|
-
defer: function() {
|
|
16
|
-
return defer;
|
|
17
|
-
},
|
|
18
12
|
expectHex: function() {
|
|
19
13
|
return expectHex;
|
|
20
14
|
},
|
|
@@ -29,29 +23,11 @@ _export(exports, {
|
|
|
29
23
|
},
|
|
30
24
|
redact: function() {
|
|
31
25
|
return redact;
|
|
32
|
-
},
|
|
33
|
-
sendTransaction: function() {
|
|
34
|
-
return sendTransaction;
|
|
35
|
-
},
|
|
36
|
-
setupContext: function() {
|
|
37
|
-
return setupContext;
|
|
38
|
-
},
|
|
39
|
-
setupContextWithConfig: function() {
|
|
40
|
-
return setupContextWithConfig;
|
|
41
|
-
},
|
|
42
|
-
setupNetworks: function() {
|
|
43
|
-
return setupNetworks;
|
|
44
|
-
},
|
|
45
|
-
testingPairs: function() {
|
|
46
|
-
return testingPairs;
|
|
47
26
|
}
|
|
48
27
|
});
|
|
49
|
-
const _api = require("@polkadot/api");
|
|
50
|
-
const _chopsticks = require("@acala-network/chopsticks");
|
|
51
|
-
const _keyring = require("@polkadot/keyring");
|
|
52
28
|
const _vitest = require("vitest");
|
|
53
29
|
_export_star(require("./check.js"), exports);
|
|
54
|
-
_export_star(require("
|
|
30
|
+
_export_star(require("@acala-network/chopsticks-utils"), exports);
|
|
55
31
|
function _export_star(from, to) {
|
|
56
32
|
Object.keys(from).forEach(function(k) {
|
|
57
33
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -65,112 +41,6 @@ function _export_star(from, to) {
|
|
|
65
41
|
});
|
|
66
42
|
return from;
|
|
67
43
|
}
|
|
68
|
-
const createConfig = ({ endpoint, blockNumber, blockHash, wasmOverride, db, timeout, port, maxMemoryBlockCount, resume })=>{
|
|
69
|
-
// random port if not specified
|
|
70
|
-
port = port ?? Math.floor(Math.random() * 10000) + 10000;
|
|
71
|
-
const config = {
|
|
72
|
-
endpoint,
|
|
73
|
-
port,
|
|
74
|
-
block: blockNumber || blockHash,
|
|
75
|
-
'mock-signature-host': true,
|
|
76
|
-
'build-block-mode': _chopsticks.BuildBlockMode.Manual,
|
|
77
|
-
'max-memory-block-count': maxMemoryBlockCount ?? 100,
|
|
78
|
-
db,
|
|
79
|
-
'wasm-override': wasmOverride,
|
|
80
|
-
timeout,
|
|
81
|
-
resume: resume ?? false
|
|
82
|
-
};
|
|
83
|
-
return config;
|
|
84
|
-
};
|
|
85
|
-
const setupContext = async (option)=>{
|
|
86
|
-
return setupContextWithConfig(createConfig(option));
|
|
87
|
-
};
|
|
88
|
-
const setupContextWithConfig = async ({ timeout, ...config })=>{
|
|
89
|
-
const { chain, listenPort, close } = await (0, _chopsticks.setupWithServer)(config);
|
|
90
|
-
const url = `ws://localhost:${listenPort}`;
|
|
91
|
-
const ws = new _api.WsProvider(url, undefined, undefined, timeout);
|
|
92
|
-
const api = await _api.ApiPromise.create({
|
|
93
|
-
provider: ws,
|
|
94
|
-
noInitWarn: true
|
|
95
|
-
});
|
|
96
|
-
await api.isReady;
|
|
97
|
-
return {
|
|
98
|
-
url,
|
|
99
|
-
chain,
|
|
100
|
-
ws,
|
|
101
|
-
api,
|
|
102
|
-
dev: {
|
|
103
|
-
newBlock: (param)=>{
|
|
104
|
-
return ws.send('dev_newBlock', [
|
|
105
|
-
param
|
|
106
|
-
]);
|
|
107
|
-
},
|
|
108
|
-
setStorage: (values, blockHash)=>{
|
|
109
|
-
return ws.send('dev_setStorage', [
|
|
110
|
-
values,
|
|
111
|
-
blockHash
|
|
112
|
-
]);
|
|
113
|
-
},
|
|
114
|
-
timeTravel: (date)=>{
|
|
115
|
-
return ws.send('dev_timeTravel', [
|
|
116
|
-
date
|
|
117
|
-
]);
|
|
118
|
-
},
|
|
119
|
-
setHead: (hashOrNumber)=>{
|
|
120
|
-
return ws.send('dev_setHead', [
|
|
121
|
-
hashOrNumber
|
|
122
|
-
]);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
async teardown () {
|
|
126
|
-
await api.disconnect();
|
|
127
|
-
await close();
|
|
128
|
-
},
|
|
129
|
-
async pause () {
|
|
130
|
-
await ws.send('dev_setBlockBuildMode', [
|
|
131
|
-
_chopsticks.BuildBlockMode.Instant
|
|
132
|
-
]);
|
|
133
|
-
// log a bit later to ensure the message is visible
|
|
134
|
-
setTimeout(()=>console.log(`Test paused. Polkadot.js apps URL: https://polkadot.js.org/apps/?rpc=${url}`), 100);
|
|
135
|
-
return new Promise((_resolve)=>{}) // wait forever
|
|
136
|
-
;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
const setupNetworks = async (networkOptions)=>{
|
|
141
|
-
const ret = {};
|
|
142
|
-
let wasmOverriden = false;
|
|
143
|
-
for (const [name, options] of Object.entries(networkOptions)){
|
|
144
|
-
const config = typeof options === 'string' ? await (0, _chopsticks.fetchConfig)(options) : options ?? await (0, _chopsticks.fetchConfig)(name);
|
|
145
|
-
ret[name] = await setupContextWithConfig(config);
|
|
146
|
-
wasmOverriden ||= config['wasm-override'] != null;
|
|
147
|
-
}
|
|
148
|
-
const relaychainName = Object.keys(ret).filter((x)=>[
|
|
149
|
-
'polkadot',
|
|
150
|
-
'kusama'
|
|
151
|
-
].includes(x.toLocaleLowerCase()))[0];
|
|
152
|
-
const { [relaychainName]: relaychain, ...parachains } = ret;
|
|
153
|
-
if (relaychain) {
|
|
154
|
-
for (const parachain of Object.values(parachains)){
|
|
155
|
-
await (0, _chopsticks.connectVertical)(relaychain.chain, parachain.chain);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const parachainList = Object.values(parachains).map((i)=>i.chain);
|
|
159
|
-
if (parachainList.length > 0) {
|
|
160
|
-
await (0, _chopsticks.connectParachains)(parachainList);
|
|
161
|
-
}
|
|
162
|
-
if (wasmOverriden) {
|
|
163
|
-
// trigger runtime upgrade if needed (due to wasm override)
|
|
164
|
-
for (const chain of Object.values(ret)){
|
|
165
|
-
await chain.dev.newBlock();
|
|
166
|
-
}
|
|
167
|
-
// handle xcm version message if needed (due to wasm override triggered xcm version upgrade)
|
|
168
|
-
for (const chain of Object.values(ret)){
|
|
169
|
-
await chain.dev.newBlock();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return ret;
|
|
173
|
-
};
|
|
174
44
|
const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
|
|
175
45
|
const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
|
|
176
46
|
const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
|
|
@@ -245,51 +115,3 @@ const redact = async (data)=>{
|
|
|
245
115
|
};
|
|
246
116
|
return process(json);
|
|
247
117
|
};
|
|
248
|
-
function defer() {
|
|
249
|
-
const deferred = {};
|
|
250
|
-
deferred.promise = new Promise((resolve, reject)=>{
|
|
251
|
-
deferred.resolve = resolve;
|
|
252
|
-
deferred.reject = reject;
|
|
253
|
-
});
|
|
254
|
-
return deferred;
|
|
255
|
-
}
|
|
256
|
-
const sendTransaction = async (tx)=>{
|
|
257
|
-
const signed = await tx;
|
|
258
|
-
const deferred = defer();
|
|
259
|
-
await signed.send((status)=>{
|
|
260
|
-
console.log('tranaction status: ', status.status.toHuman());
|
|
261
|
-
if (status.isInBlock || status.isFinalized) {
|
|
262
|
-
deferred.resolve(status.events);
|
|
263
|
-
}
|
|
264
|
-
if (status.isError) {
|
|
265
|
-
deferred.reject(status.status);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
return {
|
|
269
|
-
events: deferred.promise
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
const testingPairs = (keyringType = 'ed25519', ss58Format)=>{
|
|
273
|
-
const keyringEth = (0, _keyring.createTestKeyring)({
|
|
274
|
-
type: 'ethereum'
|
|
275
|
-
});
|
|
276
|
-
// default to ed25519 because sr25519 signature is non-deterministic
|
|
277
|
-
const keyring = new _keyring.Keyring({
|
|
278
|
-
type: keyringType,
|
|
279
|
-
ss58Format
|
|
280
|
-
});
|
|
281
|
-
return {
|
|
282
|
-
alice: keyring.addFromUri('//Alice'),
|
|
283
|
-
bob: keyring.addFromUri('//Bob'),
|
|
284
|
-
charlie: keyring.addFromUri('//Charlie'),
|
|
285
|
-
dave: keyring.addFromUri('//Dave'),
|
|
286
|
-
eve: keyring.addFromUri('//Eve'),
|
|
287
|
-
alith: keyringEth.getPair('0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac'),
|
|
288
|
-
baltathar: keyringEth.getPair('0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0'),
|
|
289
|
-
charleth: keyringEth.getPair('0x798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc'),
|
|
290
|
-
dorothy: keyringEth.getPair('0x773539d4Ac0e786233D90A233654ccEE26a613D9'),
|
|
291
|
-
ethan: keyringEth.getPair('0xFf64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB'),
|
|
292
|
-
keyring,
|
|
293
|
-
keyringEth
|
|
294
|
-
};
|
|
295
|
-
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,115 +1,6 @@
|
|
|
1
|
-
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
2
|
-
import { BuildBlockMode, connectParachains, connectVertical, fetchConfig, setupWithServer } from '@acala-network/chopsticks';
|
|
3
|
-
import { Keyring, createTestKeyring } from '@polkadot/keyring';
|
|
4
1
|
import { expect } from 'vitest';
|
|
5
2
|
export * from './check.js';
|
|
6
|
-
export * from '
|
|
7
|
-
export const createConfig = ({ endpoint, blockNumber, blockHash, wasmOverride, db, timeout, port, maxMemoryBlockCount, resume })=>{
|
|
8
|
-
// random port if not specified
|
|
9
|
-
port = port ?? Math.floor(Math.random() * 10000) + 10000;
|
|
10
|
-
const config = {
|
|
11
|
-
endpoint,
|
|
12
|
-
port,
|
|
13
|
-
block: blockNumber || blockHash,
|
|
14
|
-
'mock-signature-host': true,
|
|
15
|
-
'build-block-mode': BuildBlockMode.Manual,
|
|
16
|
-
'max-memory-block-count': maxMemoryBlockCount ?? 100,
|
|
17
|
-
db,
|
|
18
|
-
'wasm-override': wasmOverride,
|
|
19
|
-
timeout,
|
|
20
|
-
resume: resume ?? false
|
|
21
|
-
};
|
|
22
|
-
return config;
|
|
23
|
-
};
|
|
24
|
-
export const setupContext = async (option)=>{
|
|
25
|
-
return setupContextWithConfig(createConfig(option));
|
|
26
|
-
};
|
|
27
|
-
export const setupContextWithConfig = async ({ timeout, ...config })=>{
|
|
28
|
-
const { chain, listenPort, close } = await setupWithServer(config);
|
|
29
|
-
const url = `ws://localhost:${listenPort}`;
|
|
30
|
-
const ws = new WsProvider(url, undefined, undefined, timeout);
|
|
31
|
-
const api = await ApiPromise.create({
|
|
32
|
-
provider: ws,
|
|
33
|
-
noInitWarn: true
|
|
34
|
-
});
|
|
35
|
-
await api.isReady;
|
|
36
|
-
return {
|
|
37
|
-
url,
|
|
38
|
-
chain,
|
|
39
|
-
ws,
|
|
40
|
-
api,
|
|
41
|
-
dev: {
|
|
42
|
-
newBlock: (param)=>{
|
|
43
|
-
return ws.send('dev_newBlock', [
|
|
44
|
-
param
|
|
45
|
-
]);
|
|
46
|
-
},
|
|
47
|
-
setStorage: (values, blockHash)=>{
|
|
48
|
-
return ws.send('dev_setStorage', [
|
|
49
|
-
values,
|
|
50
|
-
blockHash
|
|
51
|
-
]);
|
|
52
|
-
},
|
|
53
|
-
timeTravel: (date)=>{
|
|
54
|
-
return ws.send('dev_timeTravel', [
|
|
55
|
-
date
|
|
56
|
-
]);
|
|
57
|
-
},
|
|
58
|
-
setHead: (hashOrNumber)=>{
|
|
59
|
-
return ws.send('dev_setHead', [
|
|
60
|
-
hashOrNumber
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
async teardown () {
|
|
65
|
-
await api.disconnect();
|
|
66
|
-
await close();
|
|
67
|
-
},
|
|
68
|
-
async pause () {
|
|
69
|
-
await ws.send('dev_setBlockBuildMode', [
|
|
70
|
-
BuildBlockMode.Instant
|
|
71
|
-
]);
|
|
72
|
-
// log a bit later to ensure the message is visible
|
|
73
|
-
setTimeout(()=>console.log(`Test paused. Polkadot.js apps URL: https://polkadot.js.org/apps/?rpc=${url}`), 100);
|
|
74
|
-
return new Promise((_resolve)=>{}) // wait forever
|
|
75
|
-
;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
export const setupNetworks = async (networkOptions)=>{
|
|
80
|
-
const ret = {};
|
|
81
|
-
let wasmOverriden = false;
|
|
82
|
-
for (const [name, options] of Object.entries(networkOptions)){
|
|
83
|
-
const config = typeof options === 'string' ? await fetchConfig(options) : options ?? await fetchConfig(name);
|
|
84
|
-
ret[name] = await setupContextWithConfig(config);
|
|
85
|
-
wasmOverriden ||= config['wasm-override'] != null;
|
|
86
|
-
}
|
|
87
|
-
const relaychainName = Object.keys(ret).filter((x)=>[
|
|
88
|
-
'polkadot',
|
|
89
|
-
'kusama'
|
|
90
|
-
].includes(x.toLocaleLowerCase()))[0];
|
|
91
|
-
const { [relaychainName]: relaychain, ...parachains } = ret;
|
|
92
|
-
if (relaychain) {
|
|
93
|
-
for (const parachain of Object.values(parachains)){
|
|
94
|
-
await connectVertical(relaychain.chain, parachain.chain);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const parachainList = Object.values(parachains).map((i)=>i.chain);
|
|
98
|
-
if (parachainList.length > 0) {
|
|
99
|
-
await connectParachains(parachainList);
|
|
100
|
-
}
|
|
101
|
-
if (wasmOverriden) {
|
|
102
|
-
// trigger runtime upgrade if needed (due to wasm override)
|
|
103
|
-
for (const chain of Object.values(ret)){
|
|
104
|
-
await chain.dev.newBlock();
|
|
105
|
-
}
|
|
106
|
-
// handle xcm version message if needed (due to wasm override triggered xcm version upgrade)
|
|
107
|
-
for (const chain of Object.values(ret)){
|
|
108
|
-
await chain.dev.newBlock();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return ret;
|
|
112
|
-
};
|
|
3
|
+
export * from '@acala-network/chopsticks-utils';
|
|
113
4
|
const processCodecOrArray = (codec, fn)=>Array.isArray(codec) ? codec.map(fn) : fn(codec);
|
|
114
5
|
const toHuman = (codec)=>processCodecOrArray(codec, (c)=>c?.toHuman?.() ?? c);
|
|
115
6
|
const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
|
|
@@ -184,51 +75,3 @@ export const redact = async (data)=>{
|
|
|
184
75
|
};
|
|
185
76
|
return process(json);
|
|
186
77
|
};
|
|
187
|
-
export function defer() {
|
|
188
|
-
const deferred = {};
|
|
189
|
-
deferred.promise = new Promise((resolve, reject)=>{
|
|
190
|
-
deferred.resolve = resolve;
|
|
191
|
-
deferred.reject = reject;
|
|
192
|
-
});
|
|
193
|
-
return deferred;
|
|
194
|
-
}
|
|
195
|
-
export const sendTransaction = async (tx)=>{
|
|
196
|
-
const signed = await tx;
|
|
197
|
-
const deferred = defer();
|
|
198
|
-
await signed.send((status)=>{
|
|
199
|
-
console.log('tranaction status: ', status.status.toHuman());
|
|
200
|
-
if (status.isInBlock || status.isFinalized) {
|
|
201
|
-
deferred.resolve(status.events);
|
|
202
|
-
}
|
|
203
|
-
if (status.isError) {
|
|
204
|
-
deferred.reject(status.status);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
return {
|
|
208
|
-
events: deferred.promise
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
export const testingPairs = (keyringType = 'ed25519', ss58Format)=>{
|
|
212
|
-
const keyringEth = createTestKeyring({
|
|
213
|
-
type: 'ethereum'
|
|
214
|
-
});
|
|
215
|
-
// default to ed25519 because sr25519 signature is non-deterministic
|
|
216
|
-
const keyring = new Keyring({
|
|
217
|
-
type: keyringType,
|
|
218
|
-
ss58Format
|
|
219
|
-
});
|
|
220
|
-
return {
|
|
221
|
-
alice: keyring.addFromUri('//Alice'),
|
|
222
|
-
bob: keyring.addFromUri('//Bob'),
|
|
223
|
-
charlie: keyring.addFromUri('//Charlie'),
|
|
224
|
-
dave: keyring.addFromUri('//Dave'),
|
|
225
|
-
eve: keyring.addFromUri('//Eve'),
|
|
226
|
-
alith: keyringEth.getPair('0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac'),
|
|
227
|
-
baltathar: keyringEth.getPair('0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0'),
|
|
228
|
-
charleth: keyringEth.getPair('0x798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc'),
|
|
229
|
-
dorothy: keyringEth.getPair('0x773539d4Ac0e786233D90A233654ccEE26a613D9'),
|
|
230
|
-
ethan: keyringEth.getPair('0xFf64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB'),
|
|
231
|
-
keyring,
|
|
232
|
-
keyringEth
|
|
233
|
-
};
|
|
234
|
-
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,82 +1,7 @@
|
|
|
1
|
-
import { ApiPromise
|
|
2
|
-
import { StorageValues } from '@acala-network/chopsticks';
|
|
1
|
+
import { ApiPromise } from '@polkadot/api';
|
|
3
2
|
import { Codec } from '@polkadot/types/types';
|
|
4
|
-
import { Config } from '@acala-network/chopsticks/schema/index.js';
|
|
5
|
-
import { HexString } from '@polkadot/util/types';
|
|
6
|
-
import { Keyring } from '@polkadot/keyring';
|
|
7
|
-
import { SubmittableExtrinsic } from '@polkadot/api-base/types';
|
|
8
3
|
export * from './check.js';
|
|
9
|
-
export * from '
|
|
10
|
-
export type SetupOption = {
|
|
11
|
-
endpoint: string;
|
|
12
|
-
blockNumber?: number;
|
|
13
|
-
blockHash?: HexString;
|
|
14
|
-
wasmOverride?: string;
|
|
15
|
-
db?: string;
|
|
16
|
-
timeout?: number;
|
|
17
|
-
port?: number;
|
|
18
|
-
maxMemoryBlockCount?: number;
|
|
19
|
-
resume?: boolean | HexString | number;
|
|
20
|
-
};
|
|
21
|
-
export type SetupConfig = Config & {
|
|
22
|
-
timeout?: number;
|
|
23
|
-
};
|
|
24
|
-
export declare const createConfig: ({ endpoint, blockNumber, blockHash, wasmOverride, db, timeout, port, maxMemoryBlockCount, resume, }: SetupOption) => SetupConfig;
|
|
25
|
-
export declare const setupContext: (option: SetupOption) => Promise<{
|
|
26
|
-
url: string;
|
|
27
|
-
chain: import("@acala-network/chopsticks").Blockchain;
|
|
28
|
-
ws: WsProvider;
|
|
29
|
-
api: ApiPromise;
|
|
30
|
-
dev: {
|
|
31
|
-
newBlock: (param?: {
|
|
32
|
-
count?: number;
|
|
33
|
-
to?: number;
|
|
34
|
-
unsafeBlockHeight?: number;
|
|
35
|
-
}) => Promise<string>;
|
|
36
|
-
setStorage: (values: StorageValues, blockHash?: string) => Promise<any>;
|
|
37
|
-
timeTravel: (date: string | number) => Promise<number>;
|
|
38
|
-
setHead: (hashOrNumber: string | number) => Promise<any>;
|
|
39
|
-
};
|
|
40
|
-
teardown(): Promise<void>;
|
|
41
|
-
pause(): Promise<unknown>;
|
|
42
|
-
}>;
|
|
43
|
-
export declare const setupContextWithConfig: ({ timeout, ...config }: SetupConfig) => Promise<{
|
|
44
|
-
url: string;
|
|
45
|
-
chain: import("@acala-network/chopsticks").Blockchain;
|
|
46
|
-
ws: WsProvider;
|
|
47
|
-
api: ApiPromise;
|
|
48
|
-
dev: {
|
|
49
|
-
newBlock: (param?: {
|
|
50
|
-
count?: number;
|
|
51
|
-
to?: number;
|
|
52
|
-
unsafeBlockHeight?: number;
|
|
53
|
-
}) => Promise<string>;
|
|
54
|
-
setStorage: (values: StorageValues, blockHash?: string) => Promise<any>;
|
|
55
|
-
timeTravel: (date: string | number) => Promise<number>;
|
|
56
|
-
setHead: (hashOrNumber: string | number) => Promise<any>;
|
|
57
|
-
};
|
|
58
|
-
teardown(): Promise<void>;
|
|
59
|
-
pause(): Promise<unknown>;
|
|
60
|
-
}>;
|
|
61
|
-
export type NetworkContext = Awaited<ReturnType<typeof setupContext>>;
|
|
62
|
-
export declare const setupNetworks: (networkOptions: Partial<Record<string, Config | string | undefined>>) => Promise<Record<string, {
|
|
63
|
-
url: string;
|
|
64
|
-
chain: import("@acala-network/chopsticks").Blockchain;
|
|
65
|
-
ws: WsProvider;
|
|
66
|
-
api: ApiPromise;
|
|
67
|
-
dev: {
|
|
68
|
-
newBlock: (param?: {
|
|
69
|
-
count?: number;
|
|
70
|
-
to?: number;
|
|
71
|
-
unsafeBlockHeight?: number;
|
|
72
|
-
}) => Promise<string>;
|
|
73
|
-
setStorage: (values: StorageValues, blockHash?: string) => Promise<any>;
|
|
74
|
-
timeTravel: (date: string | number) => Promise<number>;
|
|
75
|
-
setHead: (hashOrNumber: string | number) => Promise<any>;
|
|
76
|
-
};
|
|
77
|
-
teardown(): Promise<void>;
|
|
78
|
-
pause(): Promise<unknown>;
|
|
79
|
-
}>>;
|
|
4
|
+
export * from '@acala-network/chopsticks-utils';
|
|
80
5
|
type CodecOrArray = Codec | Codec[];
|
|
81
6
|
export declare const expectJson: (codec: CodecOrArray) => import("@vitest/expect").Assertion<any>;
|
|
82
7
|
export declare const expectHex: (codec: CodecOrArray) => import("@vitest/expect").Assertion<any>;
|
|
@@ -89,25 +14,3 @@ export declare const matchSystemEvents: ({ api }: {
|
|
|
89
14
|
api: ApiPromise;
|
|
90
15
|
}, ...filters: EventFilter[]) => Promise<void>;
|
|
91
16
|
export declare const redact: (data: any | Promise<any>) => Promise<any>;
|
|
92
|
-
export declare function defer<T>(): {
|
|
93
|
-
resolve: (value: any) => void;
|
|
94
|
-
reject: (reason: any) => void;
|
|
95
|
-
promise: Promise<T>;
|
|
96
|
-
};
|
|
97
|
-
export declare const sendTransaction: (tx: Promise<SubmittableExtrinsic<'promise'>>) => Promise<{
|
|
98
|
-
events: Promise<Codec[]>;
|
|
99
|
-
}>;
|
|
100
|
-
export declare const testingPairs: (keyringType?: 'ed25519' | 'sr25519', ss58Format?: number) => {
|
|
101
|
-
alice: import("@polkadot/keyring/types").KeyringPair;
|
|
102
|
-
bob: import("@polkadot/keyring/types").KeyringPair;
|
|
103
|
-
charlie: import("@polkadot/keyring/types").KeyringPair;
|
|
104
|
-
dave: import("@polkadot/keyring/types").KeyringPair;
|
|
105
|
-
eve: import("@polkadot/keyring/types").KeyringPair;
|
|
106
|
-
alith: import("@polkadot/keyring/types").KeyringPair;
|
|
107
|
-
baltathar: import("@polkadot/keyring/types").KeyringPair;
|
|
108
|
-
charleth: import("@polkadot/keyring/types").KeyringPair;
|
|
109
|
-
dorothy: import("@polkadot/keyring/types").KeyringPair;
|
|
110
|
-
ethan: import("@polkadot/keyring/types").KeyringPair;
|
|
111
|
-
keyring: Keyring;
|
|
112
|
-
keyringEth: import("@polkadot/keyring/types").KeyringInstance;
|
|
113
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-testing",
|
|
3
|
-
"version": "0.9.2-
|
|
3
|
+
"version": "0.9.2-5",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@acala-network/chopsticks": "0.9.2-
|
|
15
|
+
"@acala-network/chopsticks-utils": "0.9.2-2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"vitest": "^0.34.0"
|
package/dist/cjs/signFake.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
signFake: function() {
|
|
13
|
-
return signFake;
|
|
14
|
-
},
|
|
15
|
-
signFakeWithApi: function() {
|
|
16
|
-
return signFakeWithApi;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const signFakeWithApi = async (api, tx, addr, options = {})=>{
|
|
20
|
-
const nonce = options.nonce ?? (await api.query.system.account(addr)).nonce;
|
|
21
|
-
signFake(tx, addr, {
|
|
22
|
-
nonce,
|
|
23
|
-
genesisHash: api.genesisHash,
|
|
24
|
-
runtimeVersion: api.runtimeVersion,
|
|
25
|
-
blockHash: api.genesisHash,
|
|
26
|
-
...options
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const signFake = (tx, addr, options)=>{
|
|
30
|
-
const mockSignature = new Uint8Array(64);
|
|
31
|
-
mockSignature.fill(0xcd);
|
|
32
|
-
mockSignature.set([
|
|
33
|
-
0xde,
|
|
34
|
-
0xad,
|
|
35
|
-
0xbe,
|
|
36
|
-
0xef
|
|
37
|
-
]);
|
|
38
|
-
tx.signFake(addr, options);
|
|
39
|
-
tx.signature.set(mockSignature);
|
|
40
|
-
};
|
package/dist/esm/signFake.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const signFakeWithApi = async (api, tx, addr, options = {})=>{
|
|
2
|
-
const nonce = options.nonce ?? (await api.query.system.account(addr)).nonce;
|
|
3
|
-
signFake(tx, addr, {
|
|
4
|
-
nonce,
|
|
5
|
-
genesisHash: api.genesisHash,
|
|
6
|
-
runtimeVersion: api.runtimeVersion,
|
|
7
|
-
blockHash: api.genesisHash,
|
|
8
|
-
...options
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
export const signFake = (tx, addr, options)=>{
|
|
12
|
-
const mockSignature = new Uint8Array(64);
|
|
13
|
-
mockSignature.fill(0xcd);
|
|
14
|
-
mockSignature.set([
|
|
15
|
-
0xde,
|
|
16
|
-
0xad,
|
|
17
|
-
0xbe,
|
|
18
|
-
0xef
|
|
19
|
-
]);
|
|
20
|
-
tx.signFake(addr, options);
|
|
21
|
-
tx.signature.set(mockSignature);
|
|
22
|
-
};
|
package/dist/types/signFake.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ApiPromise } from '@polkadot/api';
|
|
2
|
-
import { GenericExtrinsic } from '@polkadot/types';
|
|
3
|
-
import { SignatureOptions } from '@polkadot/types/types';
|
|
4
|
-
export type SignFakeOptions = Partial<SignatureOptions>;
|
|
5
|
-
export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<void>;
|
|
6
|
-
export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) => void;
|