git.delta.rocks / unique-network / refs/commits / 535a8e928ce8

difftreelog

tests: introduce feed alices + refactor tests to use the filename as donor key

Fahrrader2022-10-05parent: #8b875cb.patch.diff
in: master

64 files changed

modifiedtests/package.jsondiffbeforeafterboth
26 "scripts": {26 "scripts": {
27 "lint": "eslint --ext .ts,.js src/",27 "lint": "eslint --ext .ts,.js src/",
28 "fix": "eslint --ext .ts,.js src/ --fix",28 "fix": "eslint --ext .ts,.js src/ --fix",
29 "feedAlices": "ts-node ./src/util/playgrounds/feedAlices.ts",
30
29 "test": "mocha --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",31 "test": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",
30 "testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",32 "testStructure": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",
31 "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",33 "testEth": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",
32 "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",34 "testEthNesting": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",
33 "testEthFractionalizer": "mocha --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",35 "testEthFractionalizer": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",
34 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",36 "testEthMarketplace": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",
35 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",37 "testCollision": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
36 "loadTransfer": "ts-node src/transfer.nload.ts",38 "testEvent": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",
37 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",39 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",
40
38 "testEvent": "mocha --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",41 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",
42 "testEthTokenProperties": "mocha --timeout 9999999 -r ts-node/register ./**/eth/tokenProperties.test.ts",
39 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",43 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",
40 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",44 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",
41 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",
42 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",45 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",
43 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",46 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",
44 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",
45 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",47 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",
46 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",
47 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",48 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",
48 "testChangeCollectionOwner": "mocha --timeout 9999999 -r ts-node/register ./**/change-collection-owner.test.ts",49 "testChangeCollectionOwner": "mocha --timeout 9999999 -r ts-node/register ./**/change-collection-owner.test.ts",
49 "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts",50 "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts",
97 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",98 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",
98 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",99 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",
100
101 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",
102 "loadTransfer": "ts-node src/transfer.nload.ts",
103
99 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",104 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",
100 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",105 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
21 let donor: IKeyringPair;21 let donor: IKeyringPair;
2222
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async (_, privateKeyWrapper) => {24 await usingPlaygrounds(async (_, privateKey) => {
25 donor = privateKeyWrapper('//Alice');25 donor = await privateKey({filename: __filename});
26 });26 });
27 });27 });
2828
44 let donor: IKeyringPair;44 let donor: IKeyringPair;
4545
46 before(async () => {46 before(async () => {
47 await usingPlaygrounds(async (_, privateKeyWrapper) => {47 await usingPlaygrounds(async (_, privateKey) => {
48 donor = privateKeyWrapper('//Alice');48 donor = await privateKey({filename: __filename});
49 });49 });
50 });50 });
5151
modifiedtests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth
2424
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');27 const donor = await privateKey({filename: __filename});
28 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);28 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
29 });29 });
30 });30 });
modifiedtests/src/allowLists.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');28 const donor = await privateKey({filename: __filename});
29 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);29 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);
30 });30 });
31 });31 });
8787
88 before(async () => {88 before(async () => {
89 await usingPlaygrounds(async (helper, privateKey) => {89 await usingPlaygrounds(async (helper, privateKey) => {
90 const donor = privateKey('//Alice');90 const donor = await privateKey({filename: __filename});
91 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);91 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);
92 });92 });
93 });93 });
163163
164 before(async () => {164 before(async () => {
165 await usingPlaygrounds(async (helper, privateKey) => {165 await usingPlaygrounds(async (helper, privateKey) => {
166 const donor = privateKey('//Alice');166 const donor = await privateKey({filename: __filename});
167 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);167 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);
168 });168 });
169 });169 });
291291
292 before(async () => {292 before(async () => {
293 await usingPlaygrounds(async (helper, privateKey) => {293 await usingPlaygrounds(async (helper, privateKey) => {
294 const donor = privateKey('//Alice');294 const donor = await privateKey({filename: __filename});
295 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);295 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
296 });296 });
297 });297 });
modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
43 before(async function () {43 before(async function () {
44 await usingPlaygrounds(async (helper, privateKey) => {44 await usingPlaygrounds(async (helper, privateKey) => {
45 if (!getModuleNames(helper.api!).includes(Pallets.AppPromotion)) this.skip();45 if (!getModuleNames(helper.api!).includes(Pallets.AppPromotion)) this.skip();
46 alice = privateKey('//Alice');46 alice = await privateKey({filename: __filename});
47 palletAdmin = privateKey('//Charlie'); // TODO use custom address47 [palletAdmin] = await helper.arrange.createAccounts([100n], alice);
48 await helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));48 await helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));
49 nominal = helper.balance.getOneTokenNominal();49 nominal = helper.balance.getOneTokenNominal();
50 await helper.balance.transferToSubstrate(alice, palletAdmin.address, 1000n * nominal);50 await helper.balance.transferToSubstrate(alice, palletAdmin.address, 1000n * nominal);
modifiedtests/src/approve.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');28 const donor = await privateKey({filename: __filename});
29 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);29 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
30 });30 });
31 });31 });
104104
105 before(async () => {105 before(async () => {
106 await usingPlaygrounds(async (helper, privateKey) => {106 await usingPlaygrounds(async (helper, privateKey) => {
107 const donor = privateKey('//Alice');107 const donor = await privateKey({filename: __filename});
108 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);108 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
109 });109 });
110 });110 });
141141
142 before(async () => {142 before(async () => {
143 await usingPlaygrounds(async (helper, privateKey) => {143 await usingPlaygrounds(async (helper, privateKey) => {
144 const donor = privateKey('//Alice');144 const donor = await privateKey({filename: __filename});
145 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);145 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
146 });146 });
147 });147 });
184184
185 before(async () => {185 before(async () => {
186 await usingPlaygrounds(async (helper, privateKey) => {186 await usingPlaygrounds(async (helper, privateKey) => {
187 const donor = privateKey('//Alice');187 const donor = await privateKey({filename: __filename});
188 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);188 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
189 });189 });
190 });190 });
235235
236 before(async () => {236 before(async () => {
237 await usingPlaygrounds(async (helper, privateKey) => {237 await usingPlaygrounds(async (helper, privateKey) => {
238 const donor = privateKey('//Alice');238 const donor = await privateKey({filename: __filename});
239 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);239 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
240 });240 });
241 });241 });
265265
266 before(async () => {266 before(async () => {
267 await usingPlaygrounds(async (helper, privateKey) => {267 await usingPlaygrounds(async (helper, privateKey) => {
268 const donor = privateKey('//Alice');268 const donor = await privateKey({filename: __filename});
269 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);269 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
270 });270 });
271 });271 });
320320
321 before(async () => {321 before(async () => {
322 await usingPlaygrounds(async (helper, privateKey) => {322 await usingPlaygrounds(async (helper, privateKey) => {
323 const donor = privateKey('//Alice');323 const donor = await privateKey({filename: __filename});
324 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);324 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
325 });325 });
326 });326 });
357357
358 before(async () => {358 before(async () => {
359 await usingPlaygrounds(async (helper, privateKey) => {359 await usingPlaygrounds(async (helper, privateKey) => {
360 const donor = privateKey('//Alice');360 const donor = await privateKey({filename: __filename});
361 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);361 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
362 });362 });
363 });363 });
423423
424 before(async () => {424 before(async () => {
425 await usingPlaygrounds(async (helper, privateKey) => {425 await usingPlaygrounds(async (helper, privateKey) => {
426 const donor = privateKey('//Alice');426 const donor = await privateKey({filename: __filename});
427 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);427 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
428 });428 });
429 });429 });
474474
475 before(async () => {475 before(async () => {
476 await usingPlaygrounds(async (helper, privateKey) => {476 await usingPlaygrounds(async (helper, privateKey) => {
477 const donor = privateKey('//Alice');477 const donor = await privateKey({filename: __filename});
478 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);478 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
479 });479 });
480 });480 });
495495
496 before(async () => {496 before(async () => {
497 await usingPlaygrounds(async (helper, privateKey) => {497 await usingPlaygrounds(async (helper, privateKey) => {
498 const donor = privateKey('//Alice');498 const donor = await privateKey({filename: __filename});
499 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);499 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
500 });500 });
501 });501 });
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 donor = privateKey('//Alice');28 donor = await privateKey({filename: __filename});
29 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);29 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
30 });30 });
31 });31 });
8080
81 before(async () => {81 before(async () => {
82 await usingPlaygrounds(async (helper, privateKey) => {82 await usingPlaygrounds(async (helper, privateKey) => {
83 donor = privateKey('//Alice');83 donor = await privateKey({filename: __filename});
84 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);84 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
85 });85 });
86 });86 });
123123
124 before(async () => {124 before(async () => {
125 await usingPlaygrounds(async (helper, privateKey) => {125 await usingPlaygrounds(async (helper, privateKey) => {
126 donor = privateKey('//Alice');126 donor = await privateKey({filename: __filename});
127 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);127 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
128 });128 });
129 });129 });
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);27 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
28 });28 });
29 });29 });
4646
47 before(async () => {47 before(async () => {
48 await usingPlaygrounds(async (helper, privateKey) => {48 await usingPlaygrounds(async (helper, privateKey) => {
49 const donor = privateKey('//Alice');49 const donor = await privateKey({filename: __filename});
50 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);50 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
51 });51 });
52 });52 });
108108
109 before(async () => {109 before(async () => {
110 await usingPlaygrounds(async (helper, privateKey) => {110 await usingPlaygrounds(async (helper, privateKey) => {
111 const donor = privateKey('//Alice');111 const donor = await privateKey({filename: __filename});
112 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);112 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
113 });113 });
114 });114 });
modifiedtests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth
24 let alice: IKeyringPair;24 let alice: IKeyringPair;
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');27 const donor = await privateKey({filename: __filename});
28 [alice] = await helper.arrange.createAccounts([10n], donor);28 [alice] = await helper.arrange.createAccounts([10n], donor);
29 });29 });
30 });30 });
modifiedtests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth
23 let alice: IKeyringPair;23 let alice: IKeyringPair;
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([10n], donor);27 [alice] = await helper.arrange.createAccounts([10n], donor);
28 });28 });
29 });29 });
modifiedtests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth
23 let alice: IKeyringPair;23 let alice: IKeyringPair;
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([10n], donor);27 [alice] = await helper.arrange.createAccounts([10n], donor);
28 });28 });
29 });29 });
modifiedtests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth
23 let alice: IKeyringPair;23 let alice: IKeyringPair;
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([10n], donor);27 [alice] = await helper.arrange.createAccounts([10n], donor);
28 });28 });
29 });29 });
modifiedtests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth
23 let alice: IKeyringPair;23 let alice: IKeyringPair;
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([10n], donor);27 [alice] = await helper.arrange.createAccounts([10n], donor);
28 });28 });
29 });29 });
modifiedtests/src/check-event/transferEvent.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');28 const donor = await privateKey({filename: __filename});
29 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);29 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
30 });30 });
31 });31 });
modifiedtests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth
24 let bob: IKeyringPair;24 let bob: IKeyringPair;
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');27 const donor = await privateKey({filename: __filename});
28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
29 });29 });
30 });30 });
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
3737
38 before(async () => {38 before(async () => {
39 await usingPlaygrounds(async (helper, privateKey) => {39 await usingPlaygrounds(async (helper, privateKey) => {
40 const donor = privateKey('//Alice');40 const donor = await privateKey({filename: __filename});
41 [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);41 [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);
42 });42 });
43 });43 });
183183
184 before(async () => {184 before(async () => {
185 await usingPlaygrounds(async (helper, privateKey) => {185 await usingPlaygrounds(async (helper, privateKey) => {
186 const donor = privateKey('//Alice');186 const donor = await privateKey({filename: __filename});
187 [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);187 [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);
188 });188 });
189 });189 });
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
4949
50 before(async () => {50 before(async () => {
51 await usingPlaygrounds(async (helper, privateKey) => {51 await usingPlaygrounds(async (helper, privateKey) => {
52 const donor = privateKey('//Alice');52 const donor = await privateKey({filename: __filename});
53 [alice] = await helper.arrange.createAccounts([100n], donor);53 [alice] = await helper.arrange.createAccounts([100n], donor);
54 });54 });
55 });55 });
110110
111 before(async () => {111 before(async () => {
112 await usingPlaygrounds(async (helper, privateKey) => {112 await usingPlaygrounds(async (helper, privateKey) => {
113 const donor = privateKey('//Alice');113 const donor = await privateKey({filename: __filename});
114 [alice] = await helper.arrange.createAccounts([100n], donor);114 [alice] = await helper.arrange.createAccounts([100n], donor);
115 });115 });
116 });116 });
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
5050
51 before(async () => {51 before(async () => {
52 await usingPlaygrounds(async (helper, privateKey) => {52 await usingPlaygrounds(async (helper, privateKey) => {
53 const donor = privateKey('//Alice');53 const donor = await privateKey({filename: __filename});
54 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);54 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
55 });55 });
56 });56 });
179179
180 before(async () => {180 before(async () => {
181 await usingPlaygrounds(async (helper, privateKey) => {181 await usingPlaygrounds(async (helper, privateKey) => {
182 const donor = privateKey('//Alice');182 const donor = await privateKey({filename: __filename});
183 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);183 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
184 });184 });
185 });185 });
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
2222
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async (helper, privateKey) => {24 await usingPlaygrounds(async (helper, privateKey) => {
25 const donor = privateKey('//Alice');25 const donor = await privateKey({filename: __filename});
26 [alice] = await helper.arrange.createAccounts([100n], donor);26 [alice] = await helper.arrange.createAccounts([100n], donor);
27 });27 });
28 });28 });
168168
169 before(async () => {169 before(async () => {
170 await usingPlaygrounds(async (helper, privateKey) => {170 await usingPlaygrounds(async (helper, privateKey) => {
171 const donor = privateKey('//Alice');171 const donor = await privateKey({filename: __filename});
172 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);172 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
173 });173 });
174 });174 });
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');28 const donor = await privateKey({filename: __filename});
29 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);29 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
30 });30 });
31 });31 });
268268
269 before(async () => {269 before(async () => {
270 await usingPlaygrounds(async (helper, privateKey) => {270 await usingPlaygrounds(async (helper, privateKey) => {
271 const donor = privateKey('//Alice');271 const donor = await privateKey({filename: __filename});
272 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);272 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
273 });273 });
274 });274 });
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
5050
51 before(async () => {51 before(async () => {
52 await usingPlaygrounds(async (helper, privateKey) => {52 await usingPlaygrounds(async (helper, privateKey) => {
53 const donor = privateKey('//Alice');53 const donor = await privateKey({filename: __filename});
54 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);54 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
55 });55 });
56 });56 });
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
2222
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async (helper, privateKey) => {24 await usingPlaygrounds(async (helper, privateKey) => {
25 const donor = privateKey('//Alice');25 const donor = await privateKey({filename: __filename});
26 [alice] = await helper.arrange.createAccounts([100n], donor);26 [alice] = await helper.arrange.createAccounts([100n], donor);
27 });27 });
28 });28 });
6262
63 before(async () => {63 before(async () => {
64 await usingPlaygrounds(async (helper, privateKey) => {64 await usingPlaygrounds(async (helper, privateKey) => {
65 const donor = privateKey('//Alice');65 const donor = await privateKey({filename: __filename});
66 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);66 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
67 });67 });
68 });68 });
modifiedtests/src/enableDisableTransfer.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);27 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
28 });28 });
29 });29 });
6262
63 before(async () => {63 before(async () => {
64 await usingPlaygrounds(async (helper, privateKey) => {64 await usingPlaygrounds(async (helper, privateKey) => {
65 const donor = privateKey('//Alice');65 const donor = await privateKey({filename: __filename});
66 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);66 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
67 });67 });
68 });68 });
modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
2222
23 before(async function() {23 before(async function() {
24 await usingEthPlaygrounds(async (_helper, privateKey) => {24 await usingEthPlaygrounds(async (_helper, privateKey) => {
25 donor = privateKey('//Alice');25 donor = await privateKey({filename: __filename});
26 });26 });
27 });27 });
2828
7070
71 before(async function() {71 before(async function() {
72 await usingEthPlaygrounds(async (_helper, privateKey) => {72 await usingEthPlaygrounds(async (_helper, privateKey) => {
73 donor = privateKey('//Alice');73 donor = await privateKey({filename: __filename});
74 });74 });
75 });75 });
7676
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
2929
30 before(async function() {30 before(async function() {
31 await usingEthPlaygrounds(async (_helper, privateKey) => {31 await usingEthPlaygrounds(async (_helper, privateKey) => {
32 donor = privateKey('//Alice');32 donor = await privateKey({filename: __filename});
33 });33 });
34 });34 });
3535
8282
83 before(async () => {83 before(async () => {
84 await usingEthPlaygrounds(async (helper, privateKey) => {84 await usingEthPlaygrounds(async (helper, privateKey) => {
85 const donor = privateKey('//Alice');85 const donor = await privateKey({filename: __filename});
86 const [alice] = await helper.arrange.createAccounts([10n], donor);86 const [alice] = await helper.arrange.createAccounts([10n], donor);
87 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));87 ({collectionId: collection} = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}));
88 minter = helper.eth.createAccount();88 minter = helper.eth.createAccount();
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
3232
33 before(async function() {33 before(async function() {
34 await usingEthPlaygrounds(async (_helper, privateKey) => {34 await usingEthPlaygrounds(async (_helper, privateKey) => {
35 donor = privateKey('//Alice');35 donor = await privateKey({filename: __filename});
36 });36 });
37 });37 });
3838
144144
145 before(async function() {145 before(async function() {
146 await usingEthPlaygrounds(async (_helper, privateKey) => {146 await usingEthPlaygrounds(async (_helper, privateKey) => {
147 donor = privateKey('//Alice');147 donor = await privateKey({filename: __filename});
148 });148 });
149 });149 });
150150
272272
273 before(async function() {273 before(async function() {
274 await usingEthPlaygrounds(async (_helper, privateKey) => {274 await usingEthPlaygrounds(async (_helper, privateKey) => {
275 donor = privateKey('//Alice');275 donor = await privateKey({filename: __filename});
276 });276 });
277 });277 });
278278
314314
315 before(async function() {315 before(async function() {
316 await usingEthPlaygrounds(async (_helper, privateKey) => {316 await usingEthPlaygrounds(async (_helper, privateKey) => {
317 donor = privateKey('//Alice');317 donor = await privateKey({filename: __filename});
318 });318 });
319 });319 });
320320
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.
3
4// Unique Network is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Unique Network is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
16
1import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';17import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';
2import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';
723
8 before(async function() {24 before(async function() {
9 await usingEthPlaygrounds(async (_helper, privateKey) => {25 await usingEthPlaygrounds(async (_helper, privateKey) => {
10 donor = privateKey('//Alice');26 donor = await privateKey({filename: __filename});
11 [alice] = await _helper.arrange.createAccounts([10n], donor);27 [alice] = await _helper.arrange.createAccounts([10n], donor);
12 });28 });
13 });29 });
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
2424
25 before(async function() {25 before(async function() {
26 await usingEthPlaygrounds(async (_helper, privateKey) => {26 await usingEthPlaygrounds(async (_helper, privateKey) => {
27 donor = privateKey('//Alice');27 donor = await privateKey({filename: __filename});
28 });28 });
29 });29 });
3030
150150
151 before(async function() {151 before(async function() {
152 await usingEthPlaygrounds(async (_helper, privateKey) => {152 await usingEthPlaygrounds(async (_helper, privateKey) => {
153 donor = privateKey('//Alice');153 donor = await privateKey({filename: __filename});
154 });154 });
155 });155 });
156156
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
26 before(async function() {26 before(async function() {
27 await usingEthPlaygrounds(async (helper, privateKey) => {27 await usingEthPlaygrounds(async (helper, privateKey) => {
28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
29 donor = privateKey('//Alice');29 donor = await privateKey({filename: __filename});
30 });30 });
31 });31 });
3232
152 before(async function() {152 before(async function() {
153 await usingEthPlaygrounds(async (helper, privateKey) => {153 await usingEthPlaygrounds(async (helper, privateKey) => {
154 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);154 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
155 donor = privateKey('//Alice');155 donor = await privateKey({filename: __filename});
156 });156 });
157 });157 });
158158
modifiedtests/src/eth/crossTransfer.test.tsdiffbeforeafterboth
2626
27 before(async function() {27 before(async function() {
28 await usingEthPlaygrounds(async (helper, privateKey) => {28 await usingEthPlaygrounds(async (helper, privateKey) => {
29 donor = privateKey('//Alice');29 donor = await privateKey({filename: __filename});
30 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);30 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
31 });31 });
32 });32 });
6969
70 before(async function() {70 before(async function() {
71 await usingEthPlaygrounds(async (helper, privateKey) => {71 await usingEthPlaygrounds(async (helper, privateKey) => {
72 donor = privateKey('//Alice');72 donor = await privateKey({filename: __filename});
73 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);73 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
74 });74 });
75 });75 });
modifiedtests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth
85 before(async function() {85 before(async function() {
86 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {86 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {
87 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);87 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
88 donor = privateKey('//Alice');88 donor = await privateKey({filename: __filename});
89 });89 });
90 });90 });
9191
225 before(async function() {225 before(async function() {
226 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {226 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {
227 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);227 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
228 donor = privateKey('//Alice');228 donor = await privateKey({filename: __filename});
229 });229 });
230 });230 });
231231
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
2323
24 before(async function() {24 before(async function() {
25 await usingEthPlaygrounds(async (helper, privateKey) => {25 await usingEthPlaygrounds(async (helper, privateKey) => {
26 donor = privateKey('//Alice');26 donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([20n], donor);27 [alice] = await helper.arrange.createAccounts([20n], donor);
28 });28 });
29 });29 });
5555
56 before(async function() {56 before(async function() {
57 await usingEthPlaygrounds(async (helper, privateKey) => {57 await usingEthPlaygrounds(async (helper, privateKey) => {
58 donor = privateKey('//Alice');58 donor = await privateKey({filename: __filename});
59 [alice] = await helper.arrange.createAccounts([20n], donor);59 [alice] = await helper.arrange.createAccounts([20n], donor);
60 });60 });
61 });61 });
224224
225 before(async function() {225 before(async function() {
226 await usingEthPlaygrounds(async (helper, privateKey) => {226 await usingEthPlaygrounds(async (helper, privateKey) => {
227 donor = privateKey('//Alice');227 donor = await privateKey({filename: __filename});
228 [alice] = await helper.arrange.createAccounts([20n], donor);228 [alice] = await helper.arrange.createAccounts([20n], donor);
229 });229 });
230 });230 });
277277
278 before(async function() {278 before(async function() {
279 await usingEthPlaygrounds(async (helper, privateKey) => {279 await usingEthPlaygrounds(async (helper, privateKey) => {
280 donor = privateKey('//Alice');280 donor = await privateKey({filename: __filename});
281 [alice] = await helper.arrange.createAccounts([20n], donor);281 [alice] = await helper.arrange.createAccounts([20n], donor);
282 });282 });
283 });283 });
modifiedtests/src/eth/helpersSmoke.test.tsdiffbeforeafterboth
2222
23 before(async function() {23 before(async function() {
24 await usingEthPlaygrounds(async (_helper, privateKey) => {24 await usingEthPlaygrounds(async (_helper, privateKey) => {
25 donor = privateKey('//Alice');25 donor = await privateKey({filename: __filename});
26 });26 });
27 });27 });
28 28
modifiedtests/src/eth/migration.test.tsdiffbeforeafterboth
2222
23 before(async function() {23 before(async function() {
24 await usingEthPlaygrounds(async (_helper, privateKey) => {24 await usingEthPlaygrounds(async (_helper, privateKey) => {
25 superuser = privateKey('//Alice');25 superuser = await privateKey('//Alice');
26 });26 });
27 });27 });
28 28
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
2121
22 before(async function() {22 before(async function() {
23 await usingEthPlaygrounds(async (_, privateKey) => {23 await usingEthPlaygrounds(async (_, privateKey) => {
24 donor = privateKey('//Alice');24 donor = await privateKey({filename: __filename});
25 });25 });
26 });26 });
2727
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
2525
26 before(async function() {26 before(async function() {
27 await usingEthPlaygrounds(async (helper, privateKey) => {27 await usingEthPlaygrounds(async (helper, privateKey) => {
28 donor = privateKey('//Alice');28 donor = await privateKey({filename: __filename});
29 [alice] = await helper.arrange.createAccounts([10n], donor);29 [alice] = await helper.arrange.createAccounts([10n], donor);
30 });30 });
31 });31 });
7575
76 before(async function() {76 before(async function() {
77 await usingEthPlaygrounds(async (_helper, privateKey) => {77 await usingEthPlaygrounds(async (_helper, privateKey) => {
78 donor = privateKey('//Alice');78 donor = await privateKey({filename: __filename});
79 });79 });
80 });80 });
8181
137137
138 before(async function() {138 before(async function() {
139 await usingEthPlaygrounds(async (helper, privateKey) => {139 await usingEthPlaygrounds(async (helper, privateKey) => {
140 donor = privateKey('//Alice');140 donor = await privateKey({filename: __filename});
141 [alice] = await helper.arrange.createAccounts([10n], donor);141 [alice] = await helper.arrange.createAccounts([10n], donor);
142 });142 });
143 });143 });
318318
319 before(async function() {319 before(async function() {
320 await usingEthPlaygrounds(async (helper, privateKey) => {320 await usingEthPlaygrounds(async (helper, privateKey) => {
321 donor = privateKey('//Alice');321 donor = await privateKey({filename: __filename});
322 [alice] = await helper.arrange.createAccounts([10n], donor);322 [alice] = await helper.arrange.createAccounts([10n], donor);
323 });323 });
324 });324 });
371371
372 before(async function() {372 before(async function() {
373 await usingEthPlaygrounds(async (helper, privateKey) => {373 await usingEthPlaygrounds(async (helper, privateKey) => {
374 donor = privateKey('//Alice');374 donor = await privateKey({filename: __filename});
375 [alice] = await helper.arrange.createAccounts([20n], donor);375 [alice] = await helper.arrange.createAccounts([20n], donor);
376 });376 });
377 });377 });
496496
497 before(async function() {497 before(async function() {
498 await usingEthPlaygrounds(async (helper, privateKey) => {498 await usingEthPlaygrounds(async (helper, privateKey) => {
499 donor = privateKey('//Alice');499 donor = await privateKey({filename: __filename});
500 [alice] = await helper.arrange.createAccounts([20n], donor);500 [alice] = await helper.arrange.createAccounts([20n], donor);
501 });501 });
502 });502 });
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
2323
24 before(async function() {24 before(async function() {
25 await usingEthPlaygrounds(async (_, privateKey) => {25 await usingEthPlaygrounds(async (_, privateKey) => {
26 donor = privateKey('//Alice');26 donor = await privateKey({filename: __filename});
27 });27 });
28 });28 });
2929
68 expect(await contract.methods.getUnaccounted().call()).to.be.equal(weiCount.toString());68 expect(await contract.methods.getUnaccounted().call()).to.be.equal(weiCount.toString());
69 });69 });
7070
71 itEth('Balance can be retrieved from evm contract', async({helper, privateKey}) => {71 itEth('Balance can be retrieved from evm contract', async({helper}) => {
72 const FEE_BALANCE = 10n * helper.balance.getOneTokenNominal();72 const FEE_BALANCE = 10n * helper.balance.getOneTokenNominal();
73 const CONTRACT_BALANCE = 1n * helper.balance.getOneTokenNominal();73 const CONTRACT_BALANCE = 1n * helper.balance.getOneTokenNominal();
7474
8080
81 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), gas: helper.eth.DEFAULT_GAS});81 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), gas: helper.eth.DEFAULT_GAS});
8282
83 const receiver = privateKey(`//Receiver${Date.now()}`);83 const [receiver] = await helper.arrange.createAccounts([0n], donor);
8484
85 // First receive balance on eth balance of bob85 // First receive balance on eth balance of bob
86 {86 {
110110
111 before(async function() {111 before(async function() {
112 await usingEthPlaygrounds(async (_, privateKey) => {112 await usingEthPlaygrounds(async (_, privateKey) => {
113 donor = privateKey('//Alice');113 donor = await privateKey({filename: __filename});
114 });114 });
115 });115 });
116116
modifiedtests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth
3838
39 before(async function() {39 before(async function() {
40 await usingEthPlaygrounds(async (helper, privateKey) => {40 await usingEthPlaygrounds(async (helper, privateKey) => {
41 donor = privateKey('//Alice');41 donor = await privateKey({filename: __filename});
42 [alice] = await helper.arrange.createAccounts([10n], donor);42 [alice] = await helper.arrange.createAccounts([10n], donor);
43 });43 });
44 });44 });
7777
78 before(async function() {78 before(async function() {
79 await usingEthPlaygrounds(async (helper, privateKey) => {79 await usingEthPlaygrounds(async (helper, privateKey) => {
80 donor = privateKey('//Alice');80 donor = await privateKey({filename: __filename});
81 [alice] = await helper.arrange.createAccounts([10n], donor);81 [alice] = await helper.arrange.createAccounts([10n], donor);
82 });82 });
83 });83 });
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
3838
39 before(async function() {39 before(async function() {
40 await usingEthPlaygrounds(async (helper, privateKey) => {40 await usingEthPlaygrounds(async (helper, privateKey) => {
41 donor = privateKey('//Alice');41 donor = await privateKey({filename: __filename});
42 [alice] = await helper.arrange.createAccounts([10n], donor);42 [alice] = await helper.arrange.createAccounts([10n], donor);
43 });43 });
44 });44 });
9595
96 before(async function() {96 before(async function() {
97 await usingEthPlaygrounds(async (helper, privateKey) => {97 await usingEthPlaygrounds(async (helper, privateKey) => {
98 donor = privateKey('//Alice');98 donor = await privateKey({filename: __filename});
99 [alice] = await helper.arrange.createAccounts([10n], donor);99 [alice] = await helper.arrange.createAccounts([10n], donor);
100 });100 });
101 });101 });
139 });139 });
140140
141 //TODO: CORE-302 add eth methods141 //TODO: CORE-302 add eth methods
142 itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {142 itWeb3.skip('Can perform mintBulk()', async () => {
143 /*143 /*
144 const collection = await createCollectionExpectSuccess({144 const collection = await createCollectionExpectSuccess({
145 mode: {type: 'NFT'},145 mode: {type: 'NFT'},
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
25 await usingEthPlaygrounds(async (helper, privateKey) => {25 await usingEthPlaygrounds(async (helper, privateKey) => {
26 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);26 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
2727
28 donor = privateKey('//Alice');28 donor = await privateKey({filename: __filename});
29 });29 });
30 });30 });
3131
117 await usingEthPlaygrounds(async (helper, privateKey) => {117 await usingEthPlaygrounds(async (helper, privateKey) => {
118 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);118 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
119119
120 donor = privateKey('//Alice');120 donor = await privateKey({filename: __filename});
121 });121 });
122 });122 });
123123
329 await usingEthPlaygrounds(async (helper, privateKey) => {329 await usingEthPlaygrounds(async (helper, privateKey) => {
330 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);330 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
331331
332 donor = privateKey('//Alice');332 donor = await privateKey({filename: __filename});
333 });333 });
334 });334 });
335335
370 await usingEthPlaygrounds(async (helper, privateKey) => {370 await usingEthPlaygrounds(async (helper, privateKey) => {
371 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);371 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
372372
373 donor = privateKey('//Alice');373 donor = await privateKey({filename: __filename});
374 [alice] = await helper.arrange.createAccounts([20n], donor);374 [alice] = await helper.arrange.createAccounts([20n], donor);
375 });375 });
376 });376 });
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
28 await usingEthPlaygrounds(async (helper, privateKey) => {28 await usingEthPlaygrounds(async (helper, privateKey) => {
29 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);29 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
3030
31 donor = privateKey('//Alice');31 donor = await privateKey({filename: __filename});
32 [alice] = await helper.arrange.createAccounts([20n], donor);32 [alice] = await helper.arrange.createAccounts([20n], donor);
33 });33 });
34 });34 });
72 await usingEthPlaygrounds(async (helper, privateKey) => {72 await usingEthPlaygrounds(async (helper, privateKey) => {
73 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);73 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
7474
75 donor = privateKey('//Alice');75 donor = await privateKey({filename: __filename});
76 });76 });
77 });77 });
7878
136 await usingEthPlaygrounds(async (helper, privateKey) => {136 await usingEthPlaygrounds(async (helper, privateKey) => {
137 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);137 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
138138
139 donor = privateKey('//Alice');139 donor = await privateKey({filename: __filename});
140 [alice] = await helper.arrange.createAccounts([50n], donor);140 [alice] = await helper.arrange.createAccounts([50n], donor);
141 });141 });
142 });142 });
327 await usingEthPlaygrounds(async (helper, privateKey) => {327 await usingEthPlaygrounds(async (helper, privateKey) => {
328 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);328 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
329329
330 donor = privateKey('//Alice');330 donor = await privateKey({filename: __filename});
331 [alice] = await helper.arrange.createAccounts([50n], donor);331 [alice] = await helper.arrange.createAccounts([50n], donor);
332 });332 });
333 });333 });
382 await usingEthPlaygrounds(async (helper, privateKey) => {382 await usingEthPlaygrounds(async (helper, privateKey) => {
383 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);383 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
384384
385 donor = privateKey('//Alice');385 donor = await privateKey({filename: __filename});
386 [alice] = await helper.arrange.createAccounts([50n], donor);386 [alice] = await helper.arrange.createAccounts([50n], donor);
387 });387 });
388 });388 });
472 await usingEthPlaygrounds(async (helper, privateKey) => {472 await usingEthPlaygrounds(async (helper, privateKey) => {
473 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);473 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
474474
475 donor = privateKey('//Alice');475 donor = await privateKey({filename: __filename});
476 });476 });
477 });477 });
478478
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
1import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess} from '../util/helpers';1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.
3
4// Unique Network is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Unique Network is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
16
2import {cartesian, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';17import {itEth, usingEthPlaygrounds, expect, cartesian} from './util/playgrounds';
3import nonFungibleAbi from './nonFungibleAbi.json';
4import {expect} from 'chai';
5import {executeTransaction} from '../substrate/substrate-api';18import {IKeyringPair} from '@polkadot/types/types';
619
7describe('EVM token properties', () => {20describe('EVM token properties', () => {
21 let donor: IKeyringPair;
22 let alice: IKeyringPair;
23
24 before(async function() {
25 await usingEthPlaygrounds(async (helper, privateKey) => {
26 donor = await privateKey({filename: __filename});
27 [alice] = await helper.arrange.createAccounts([100n], donor);
28 });
29 });
30
8 itWeb3('Can be reconfigured', async({web3, api, privateKeyWrapper}) => {31 itEth('Can be reconfigured', async({helper}) => {
9 const alice = privateKeyWrapper('//Alice');
10 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);32 const caller = await helper.eth.createAccountWithBalance(donor);
11 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {33 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
12 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});34 const collection = await helper.nft.mintCollection(alice);
13 await addCollectionAdminExpectSuccess(alice, collection, {Ethereum: caller});35 await collection.addAdmin(alice, {Ethereum: caller});
14 36
15 const address = collectionIdToAddress(collection);37 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
16 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});38 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
17 39
18 await contract.methods.setTokenPropertyPermission('testKey', mutable, collectionAdmin, tokenOwner).send({from: caller});40 await contract.methods.setTokenPropertyPermission('testKey', mutable, collectionAdmin, tokenOwner).send({from: caller});
19 41
20 const state = (await api.query.common.collectionPropertyPermissions(collection)).toJSON();
21 expect(state).to.be.deep.equal({42 expect(await collection.getPropertyPermissions()).to.be.deep.equal([{
22 [web3.utils.toHex('testKey')]: {mutable, collectionAdmin, tokenOwner},43 key: 'testKey',
44 permission: {mutable, collectionAdmin, tokenOwner},
23 });45 }]);
24 }46 }
25 });47 });
48
26 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {49 itEth('Can be set', async({helper}) => {
27 const alice = privateKeyWrapper('//Alice');
28 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);50 const caller = await helper.eth.createAccountWithBalance(donor);
29 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});51 const collection = await helper.nft.mintCollection(alice);
30 const token = await createItemExpectSuccess(alice, collection, 'NFT');52 const token = await collection.mintToken(alice);
3153
32 await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{54 await collection.setTokenPropertyPermissions(alice, [{
33 key: 'testKey',55 key: 'testKey',
34 permission: {56 permission: {
35 collectionAdmin: true,57 collectionAdmin: true,
36 },58 },
37 }]));59 }]);
3860
39 await addCollectionAdminExpectSuccess(alice, collection, {Ethereum: caller});61 await collection.addAdmin(alice, {Ethereum: caller});
4062
41 const address = collectionIdToAddress(collection);63 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
42 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});64 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
4365
44 await contract.methods.setProperty(token, 'testKey', Buffer.from('testValue')).send({from: caller});66 await contract.methods.setProperty(token.tokenId, 'testKey', Buffer.from('testValue')).send({from: caller});
4567
46 const [{value}] = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toHuman()! as any;68 const [{value}] = await token.getProperties(['testKey']);
47 expect(value).to.equal('testValue');69 expect(value).to.equal('testValue');
48 });70 });
71
49 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {72 itEth('Can be deleted', async({helper}) => {
50 const alice = privateKeyWrapper('//Alice');
51 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);73 const caller = await helper.eth.createAccountWithBalance(donor);
52 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});74 const collection = await helper.nft.mintCollection(alice);
53 const token = await createItemExpectSuccess(alice, collection, 'NFT');75 const token = await collection.mintToken(alice);
5476
55 await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{77 await collection.setTokenPropertyPermissions(alice, [{
56 key: 'testKey',78 key: 'testKey',
57 permission: {79 permission: {
58 mutable: true,80 mutable: true,
59 collectionAdmin: true,81 collectionAdmin: true,
60 },82 },
61 }]));83 }]);
62 await executeTransaction(api, alice, api.tx.unique.setTokenProperties(collection, token, [{key: 'testKey', value: 'testValue'}]));84 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);
6385
64 await addCollectionAdminExpectSuccess(alice, collection, {Ethereum: caller});86 await collection.addAdmin(alice, {Ethereum: caller});
6587
66 const address = collectionIdToAddress(collection);88 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
67 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});89 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
6890
69 await contract.methods.deleteProperty(token, 'testKey').send({from: caller});91 await contract.methods.deleteProperty(token.tokenId, 'testKey').send({from: caller});
7092
71 const result = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toJSON()! as any;93 const result = await token.getProperties(['testKey']);
72 expect(result.length).to.equal(0);94 expect(result.length).to.equal(0);
73 });95 });
96
74 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {97 itEth('Can be read', async({helper}) => {
75 const alice = privateKeyWrapper('//Alice');
76 const caller = createEthAccount(web3);98 const caller = helper.eth.createAccount();
77 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});99 const collection = await helper.nft.mintCollection(alice);
78 const token = await createItemExpectSuccess(alice, collection, 'NFT');100 const token = await collection.mintToken(alice);
79101
80 await executeTransaction(api, alice, api.tx.unique.setTokenPropertyPermissions(collection, [{102 await collection.setTokenPropertyPermissions(alice, [{
81 key: 'testKey',103 key: 'testKey',
82 permission: {104 permission: {
83 collectionAdmin: true,105 collectionAdmin: true,
84 },106 },
85 }]));107 }]);
86 await executeTransaction(api, alice, api.tx.unique.setTokenProperties(collection, token, [{key: 'testKey', value: 'testValue'}]));108 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);
87109
88 const address = collectionIdToAddress(collection);110 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
89 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});111 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
90112
91 const value = await contract.methods.property(token, 'testKey').call();113 const value = await contract.methods.property(token.tokenId, 'testKey').call();
92 expect(value).to.equal(web3.utils.toHex('testValue'));114 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));
93 });115 });
94});116});
95117
modifiedtests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// SPDX-License-Identifier: Apache-2.02// SPDX-License-Identifier: Apache-2.0
33
4import * as path from 'path';
4import {IKeyringPair} from '@polkadot/types/types';5import {IKeyringPair} from '@polkadot/types/types';
56
6import config from '../../../config';7import config from '../../../config';
13import chai from 'chai';14import chai from 'chai';
14import chaiAsPromised from 'chai-as-promised';15import chaiAsPromised from 'chai-as-promised';
15import chaiLike from 'chai-like';16import chaiLike from 'chai-like';
16import {requirePalletsOrSkip} from '../../../util/playgrounds';17import {getTestSeed, requirePalletsOrSkip} from '../../../util/playgrounds';
18
17chai.use(chaiAsPromised);19chai.use(chaiAsPromised);
18chai.use(chaiLike);20chai.use(chaiLike);
19export const expect = chai.expect;21export const expect = chai.expect;
2022
21export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {23export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {
22 const silentConsole = new SilentConsole();24 const silentConsole = new SilentConsole();
23 silentConsole.enable();25 silentConsole.enable();
2426
28 await helper.connect(config.substrateUrl);30 await helper.connect(config.substrateUrl);
29 await helper.connectWeb3(config.substrateUrl);31 await helper.connectWeb3(config.substrateUrl);
30 const ss58Format = helper.chain.getChainProperties().ss58Format;32 const ss58Format = helper.chain.getChainProperties().ss58Format;
31 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);33 const privateKey = async (seed: string | {filename: string}) => {
34 if (typeof seed === 'string') {
35 return helper.util.fromSeed(seed, ss58Format);
36 }
37 else {
38 const actualSeed = getTestSeed(seed.filename);
39 let account = helper.util.fromSeed(actualSeed, ss58Format);
40 if (await helper.balance.getSubstrate(account.address) == 0n) {
41 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);
42 account = helper.util.fromSeed('//Alice', ss58Format);
43 }
44 return account;
45 }
46 };
32 await code(helper, privateKey);47 await code(helper, privateKey);
33 }48 }
34 finally {49 finally {
38 }53 }
39};54};
40 55
41export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {56export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
42 (opts.only ? it.only : 57 (opts.only ? it.only :
43 opts.skip ? it.skip : it)(name, async function() {58 opts.skip ? it.skip : it)(name, async function() {
44 await usingEthPlaygrounds(async (helper, privateKey) => {59 await usingEthPlaygrounds(async (helper, privateKey) => {
51 });66 });
52}67}
5368
54export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {69export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
55 return itEth(name, cb, {requiredPallets: required, ...opts});70 return itEth(name, cb, {requiredPallets: required, ...opts});
56}71}
5772
58itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {only: true});73itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {only: true});
59itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {skip: true});74itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {skip: true});
6075
61itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEthIfWithPallet(name, required, cb, {only: true});76itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {only: true});
62itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});77itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});
63itEth.ifWithPallets = itEthIfWithPallet;78itEth.ifWithPallets = itEthIfWithPallet;
79
80type ElementOf<A> = A extends readonly (infer T)[] ? T : never;
81// I want a fancier api, not a memory efficiency
82export function* cartesian<T extends Array<Array<any>>, R extends Array<any>>(internalRest: [...R], ...args: [...T]): Generator<[...R, ...{[K in keyof T]: ElementOf<T[K]>}]> {
83 if(args.length === 0) {
84 yield internalRest as any;
85 return;
86 }
87 for(const value of args[0]) {
88 yield* cartesian([...internalRest, value], ...args.slice(1)) as any;
89 }
90}
6491
modifiedtests/src/evmCoder.test.tsdiffbeforeafterboth
9292
93 before(async function() {93 before(async function() {
94 await usingEthPlaygrounds(async (_helper, privateKey) => {94 await usingEthPlaygrounds(async (_helper, privateKey) => {
95 donor = privateKey('//Alice');95 donor = await privateKey({filename: __filename});
96 });96 });
97 });97 });
98 98
modifiedtests/src/fungible.test.tsdiffbeforeafterboth
20const U128_MAX = (1n << 128n) - 1n;20const U128_MAX = (1n << 128n) - 1n;
2121
22describe('integration test: Fungible functionality:', () => {22describe('integration test: Fungible functionality:', () => {
23 let donor: IKeyringPair;
23 let alice: IKeyringPair;24 let alice: IKeyringPair;
24 let bob: IKeyringPair;25 let bob: IKeyringPair;
2526
26 before(async () => {27 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {28 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');29 donor = await privateKey({filename: __filename});
29 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);30 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
30 });31 });
31 });32 });
43 expect(aliceBalance).to.be.equal(U128_MAX);44 expect(aliceBalance).to.be.equal(U128_MAX);
44 });45 });
45 46
46 itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper, privateKey}) => {47 itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper}) => {
47 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};48 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
48 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));49 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
4950
50 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});51 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
5152
64 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);65 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);
65 expect(owners.length).to.be.equal(10);66 expect(owners.length).to.be.equal(10);
66 67
67 const eleven = privateKey('//ALice+11');68 const [eleven] = await helper.arrange.createAccounts([0n], donor);
68 expect(await collection.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;69 expect(await collection.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;
69 expect((await collection.getTop10Owners()).length).to.be.equal(10);70 expect((await collection.getTop10Owners()).length).to.be.equal(10);
70 });71 });
modifiedtests/src/getPropertiesRpc.test.tsdiffbeforeafterboth
6363
64 before(async () => {64 before(async () => {
65 await usingPlaygrounds(async (_, privateKey) => {65 await usingPlaygrounds(async (_, privateKey) => {
66 alice = privateKey('//Alice');66 alice = await privateKey({filename: __filename});
67 });67 });
68 });68 });
6969
modifiedtests/src/inflation.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (_, privateKey) => {25 await usingPlaygrounds(async (_, privateKey) => {
26 superuser = privateKey('//Alice');26 superuser = await privateKey('//Alice');
27 });27 });
28 });28 });
29 29
modifiedtests/src/limits.test.tsdiffbeforeafterboth
2222
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async (helper, privateKey) => {24 await usingPlaygrounds(async (helper, privateKey) => {
25 const donor = privateKey('//Alice');25 const donor = await privateKey({filename: __filename});
26 [alice] = await helper.arrange.createAccounts([10n], donor);26 [alice] = await helper.arrange.createAccounts([10n], donor);
27 });27 });
28 });28 });
60 await usingPlaygrounds(async (helper, privateKey) => {60 await usingPlaygrounds(async (helper, privateKey) => {
61 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);61 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
6262
63 const donor = privateKey('//Alice');63 const donor = await privateKey({filename: __filename});
64 [alice] = await helper.arrange.createAccounts([10n], donor);64 [alice] = await helper.arrange.createAccounts([10n], donor);
65 });65 });
66 });66 });
292292
293 before(async () => {293 before(async () => {
294 await usingPlaygrounds(async (helper, privateKey) => {294 await usingPlaygrounds(async (helper, privateKey) => {
295 const donor = privateKey('//Alice');295 const donor = await privateKey({filename: __filename});
296 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);296 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
297 });297 });
298 });298 });
333333
334 before(async () => {334 before(async () => {
335 await usingPlaygrounds(async (helper, privateKey) => {335 await usingPlaygrounds(async (helper, privateKey) => {
336 const donor = privateKey('//Alice');336 const donor = await privateKey({filename: __filename});
337 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);337 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
338 });338 });
339 });339 });
366 await usingPlaygrounds(async (helper, privateKey) => {366 await usingPlaygrounds(async (helper, privateKey) => {
367 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);367 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
368368
369 const donor = privateKey('//Alice');369 const donor = await privateKey({filename: __filename});
370 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);370 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
371 });371 });
372 });372 });
404404
405 before(async () => {405 before(async () => {
406 await usingPlaygrounds(async (helper, privateKey) => {406 await usingPlaygrounds(async (helper, privateKey) => {
407 const donor = privateKey('//Alice');407 const donor = await privateKey({filename: __filename});
408 [alice] = await helper.arrange.createAccounts([10n], donor);408 [alice] = await helper.arrange.createAccounts([10n], donor);
409 });409 });
410 });410 });
modifiedtests/src/nesting/graphs.test.tsdiffbeforeafterboth
4545
46 before(async () => {46 before(async () => {
47 await usingPlaygrounds(async (helper, privateKey) => {47 await usingPlaygrounds(async (helper, privateKey) => {
48 const donor = privateKey('//Alice');48 const donor = await privateKey({filename: __filename});
49 [alice] = await helper.arrange.createAccounts([10n], donor);49 [alice] = await helper.arrange.createAccounts([10n], donor);
50 });50 });
51 });51 });
modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);27 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
28 });28 });
29 });29 });
137137
138 before(async () => {138 before(async () => {
139 await usingPlaygrounds(async (helper, privateKey) => {139 await usingPlaygrounds(async (helper, privateKey) => {
140 const donor = privateKey('//Alice');140 const donor = await privateKey({filename: __filename});
141 [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);141 [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);
142 });142 });
143 });143 });
343343
344 before(async () => {344 before(async () => {
345 await usingPlaygrounds(async (helper, privateKey) => {345 await usingPlaygrounds(async (helper, privateKey) => {
346 const donor = privateKey('//Alice');346 const donor = await privateKey({filename: __filename});
347 [alice, bob] = await helper.arrange.createAccounts([100n, 50n], donor);347 [alice, bob] = await helper.arrange.createAccounts([100n, 50n], donor);
348 });348 });
349 });349 });
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
2626
27 before(async () => {27 before(async () => {
28 await usingPlaygrounds(async (helper, privateKey) => {28 await usingPlaygrounds(async (helper, privateKey) => {
29 const donor = privateKey('//Alice');29 const donor = await privateKey({filename: __filename});
30 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);30 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
31 });31 });
32 });32 });
141141
142 before(async () => {142 before(async () => {
143 await usingPlaygrounds(async (helper, privateKey) => {143 await usingPlaygrounds(async (helper, privateKey) => {
144 const donor = privateKey('//Alice');144 const donor = await privateKey({filename: __filename});
145 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);145 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
146 });146 });
147 });147 });
269269
270 before(async () => {270 before(async () => {
271 await usingPlaygrounds(async (helper, privateKey) => {271 await usingPlaygrounds(async (helper, privateKey) => {
272 const donor = privateKey('//Alice');272 const donor = await privateKey({filename: __filename});
273 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);273 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
274 });274 });
275 });275 });
332332
333 before(async () => {333 before(async () => {
334 await usingPlaygrounds(async (helper, privateKey) => {334 await usingPlaygrounds(async (helper, privateKey) => {
335 const donor = privateKey('//Alice');335 const donor = await privateKey({filename: __filename});
336 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);336 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
337 });337 });
338 });338 });
453453
454 before(async () => {454 before(async () => {
455 await usingPlaygrounds(async (helper, privateKey) => {455 await usingPlaygrounds(async (helper, privateKey) => {
456 const donor = privateKey('//Alice');456 const donor = await privateKey({filename: __filename});
457 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);457 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
458 });458 });
459459
777777
778 before(async () => {778 before(async () => {
779 await usingPlaygrounds(async (helper, privateKey) => {779 await usingPlaygrounds(async (helper, privateKey) => {
780 const donor = privateKey('//Alice');780 const donor = await privateKey({filename: __filename});
781 let dave: IKeyringPair;781 let dave: IKeyringPair;
782 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);782 [alice, bob, charlie, dave] = await helper.arrange.createAccounts([100n, 100n, 100n, 100n], donor);
783783
977 await usingPlaygrounds(async (helper, privateKey) => {977 await usingPlaygrounds(async (helper, privateKey) => {
978 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);978 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
979979
980 const donor = privateKey('//Alice');980 const donor = await privateKey({filename: __filename});
981 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);981 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
982 });982 });
983 });983 });
1002 ])).to.be.rejectedWith(/common\.NoPermission/);1002 ])).to.be.rejectedWith(/common\.NoPermission/);
1003 });1003 });
10041004
1005 itSub('Forbids mutating token property with tokenOwher==true when signer doesn\'t have all pieces', async ({helper}) => {1005 itSub('Forbids mutating token property with tokenOwner==true when signer doesn\'t have all pieces', async ({helper}) => {
1006 const token = await prepare(helper);1006 const token = await prepare(helper);
10071007
1008 await expect(token.collection.setTokenPropertyPermissions(alice, [{key: 'fractals', permission: {mutable:true, tokenOwner: true}}]))1008 await expect(token.collection.setTokenPropertyPermissions(alice, [{key: 'fractals', permission: {mutable:true, tokenOwner: true}}]))
modifiedtests/src/nesting/unnest.test.tsdiffbeforeafterboth
2222
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async (helper, privateKey) => {24 await usingPlaygrounds(async (helper, privateKey) => {
25 const donor = privateKey('//Alice');25 const donor = await privateKey({filename: __filename});
26 [alice] = await helper.arrange.createAccounts([50n], donor);26 [alice] = await helper.arrange.createAccounts([50n], donor);
27 });27 });
28 });28 });
9191
92 before(async () => {92 before(async () => {
93 await usingPlaygrounds(async (helper, privateKey) => {93 await usingPlaygrounds(async (helper, privateKey) => {
94 const donor = privateKey('//Alice');94 const donor = await privateKey({filename: __filename});
95 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);95 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
96 });96 });
97 });97 });
modifiedtests/src/nextSponsoring.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');28 const donor = await privateKey({filename: __filename});
29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);
30 });30 });
31 });31 });
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
20const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;20const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;
2121
22describe('integration test: Refungible functionality:', async () => {22describe('integration test: Refungible functionality:', async () => {
23 let donor: IKeyringPair;
23 let alice: IKeyringPair;24 let alice: IKeyringPair;
24 let bob: IKeyringPair;25 let bob: IKeyringPair;
2526
26 before(async function() {27 before(async function() {
27 await usingPlaygrounds(async (helper, privateKey) => {28 await usingPlaygrounds(async (helper, privateKey) => {
28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);29 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
2930
30 const donor = privateKey('//Alice');31 donor = await privateKey({filename: __filename});
31 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);32 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
32 });33 });
33 });34 });
61 .to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);62 .to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);
62 });63 });
63 64
64 itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper, privateKey}) => {65 itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper}) => {
65 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};66 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
66 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));67 const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
6768
68 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});69 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
6970
82 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);83 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);
83 expect(owners.length).to.be.equal(10);84 expect(owners.length).to.be.equal(10);
84 85
85 const eleven = privateKey('//ALice+11');86 const [eleven] = await helper.arrange.createAccounts([0n], donor);
86 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;87 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;
87 expect((await token.getTop10Owners()).length).to.be.equal(10);88 expect((await token.getTop10Owners()).length).to.be.equal(10);
88 });89 });
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);27 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);
28 });28 });
29 });29 });
6262
63 before(async () => {63 before(async () => {
64 await usingPlaygrounds(async (helper, privateKey) => {64 await usingPlaygrounds(async (helper, privateKey) => {
65 const donor = privateKey('//Alice');65 const donor = await privateKey({filename: __filename});
66 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);66 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);
67 });67 });
68 });68 });
modifiedtests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth
2424
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 donor = privateKey('//Alice');27 donor = await privateKey({filename: __filename});
28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
29 });29 });
30 });30 });
7878
79 before(async () => {79 before(async () => {
80 await usingPlaygrounds(async (helper, privateKey) => {80 await usingPlaygrounds(async (helper, privateKey) => {
81 const donor = privateKey('//Alice');81 const donor = await privateKey({filename: __filename});
82 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);82 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);
83 });83 });
84 });84 });
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 donor = privateKey('//Alice');28 donor = await privateKey({filename: __filename});
29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);
30 });30 });
31 });31 });
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
2929
30 before(async () => {30 before(async () => {
31 await usingPlaygrounds(async (helper, privateKey) => {31 await usingPlaygrounds(async (helper, privateKey) => {
32 const donor = privateKey('//Alice');32 const donor = await privateKey({filename: __filename});
33 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);33 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);
34 });34 });
35 });35 });
104104
105 before(async () => {105 before(async () => {
106 await usingPlaygrounds(async (helper, privateKey) => {106 await usingPlaygrounds(async (helper, privateKey) => {
107 const donor = privateKey('//Alice');107 const donor = await privateKey({filename: __filename});
108 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);108 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);
109 });109 });
110 });110 });
modifiedtests/src/setCollectionSponsor.test.tsdiffbeforeafterboth
2424
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');27 const donor = await privateKey({filename: __filename});
28 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);28 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);
29 });29 });
30 });30 });
9393
94 before(async () => {94 before(async () => {
95 await usingPlaygrounds(async (helper, privateKey) => {95 await usingPlaygrounds(async (helper, privateKey) => {
96 const donor = privateKey('//Alice');96 const donor = await privateKey({filename: __filename});
97 [alice, bob] = await helper.arrange.createAccounts([10n, 5n], donor);97 [alice, bob] = await helper.arrange.createAccounts([10n, 5n], donor);
98 });98 });
99 });99 });
modifiedtests/src/setPermissions.test.tsdiffbeforeafterboth
2323
24 before(async () => {24 before(async () => {
25 await usingPlaygrounds(async (helper, privateKey) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');26 const donor = await privateKey({filename: __filename});
27 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);27 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
28 });28 });
29 });29 });
7979
80 before(async () => {80 before(async () => {
81 await usingPlaygrounds(async (helper, privateKey) => {81 await usingPlaygrounds(async (helper, privateKey) => {
82 const donor = privateKey('//Alice');82 const donor = await privateKey({filename: __filename});
83 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);83 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);
84 });84 });
85 });85 });
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
19import {itSub, Pallets, usingPlaygrounds, expect} from './util/playgrounds';19import {itSub, Pallets, usingPlaygrounds, expect} from './util/playgrounds';
2020
21describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {21describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
22 let donor: IKeyringPair;
22 let alice: IKeyringPair;23 let alice: IKeyringPair;
23 let bob: IKeyringPair;24 let bob: IKeyringPair;
2425
25 before(async () => {26 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');28 donor = await privateKey({filename: __filename});
28 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);29 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
29 });30 });
30 });31 });
42 expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;43 expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;
43 });44 });
4445
45 itSub('Inability to pay fees error message is correct', async ({helper, privateKey}) => {46 itSub('Inability to pay fees error message is correct', async ({helper}) => {
46 const donor = privateKey('//Alice');
47 const [zero] = await helper.arrange.createAccounts([0n], donor);47 const [zero] = await helper.arrange.createAccounts([0n], donor);
4848
49 // console.error = () => {};49 // console.error = () => {};
117117
118 before(async () => {118 before(async () => {
119 await usingPlaygrounds(async (helper, privateKey) => {119 await usingPlaygrounds(async (helper, privateKey) => {
120 const donor = privateKey('//Alice');120 const donor = await privateKey({filename: __filename});
121 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);121 [alice, bob] = await helper.arrange.createAccounts([50n, 10n], donor);
122 });122 });
123 });123 });
256256
257 before(async function() {257 before(async function() {
258 await usingEthPlaygrounds(async (_, privateKey) => {258 await usingEthPlaygrounds(async (_, privateKey) => {
259 donor = privateKey('//Alice');259 donor = await privateKey({filename: __filename});
260 });260 });
261 });261 });
262 262
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
2424
25 before(async () => {25 before(async () => {
26 await usingPlaygrounds(async (helper, privateKey) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');27 const donor = await privateKey({filename: __filename});
28 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);28 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);
29 });29 });
30 });30 });
9191
92 before(async () => {92 before(async () => {
93 await usingPlaygrounds(async (helper, privateKey) => {93 await usingPlaygrounds(async (helper, privateKey) => {
94 const donor = privateKey('//Alice');94 const donor = await privateKey({filename: __filename});
95 [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);95 [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);
96 });96 });
97 });97 });
addedtests/src/util/playgrounds/feedAlices.tsdiffbeforeafterboth

no changes

modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// SPDX-License-Identifier: Apache-2.02// SPDX-License-Identifier: Apache-2.0
33
4import * as path from 'path';
5import * as crypto from 'crypto';
4import {IKeyringPair} from '@polkadot/types/types';6import {IKeyringPair} from '@polkadot/types/types';
5import chai from 'chai';7import chai from 'chai';
6import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';
12chai.use(chaiAsPromised);14chai.use(chaiAsPromised);
13export const expect = chai.expect;15export const expect = chai.expect;
1416
17const getTestHash = (filename: string) => {
18 return crypto.createHash('md5').update(path.basename(filename)).digest('hex');
19};
20
21export const getTestSeed = (filename: string) => {
22 return `//Alice+${getTestHash(filename)}`;
23};
24
25// todo:playgrounds normalize to seed and filename
15export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>, url: string = config.substrateUrl) => {26export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {
16 const silentConsole = new SilentConsole();27 const silentConsole = new SilentConsole();
17 silentConsole.enable();28 silentConsole.enable();
1829
21 try {32 try {
22 await helper.connect(url);33 await helper.connect(url);
23 const ss58Format = helper.chain.getChainProperties().ss58Format;34 const ss58Format = helper.chain.getChainProperties().ss58Format;
24 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);35 const privateKey = async (seed: string | {filename: string}) => {
36 if (typeof seed === 'string') {
37 return helper.util.fromSeed(seed, ss58Format);
38 }
39 else {
40 const actualSeed = getTestSeed(seed.filename);
41 let account = helper.util.fromSeed(actualSeed, ss58Format);
42 if (await helper.balance.getSubstrate(account.address) == 0n) {
43 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);
44 account = helper.util.fromSeed('//Alice', ss58Format);
45 }
46 return account;
47 }
48 };
25 await code(helper, privateKey);49 await code(helper, privateKey);
26 }50 }
27 finally {51 finally {
50 }74 }
51}75}
5276
53export async function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {77export async function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
54 (opts.only ? it.only : 78 (opts.only ? it.only :
55 opts.skip ? it.skip : it)(name, async function () {79 opts.skip ? it.skip : it)(name, async function () {
56 await usingPlaygrounds(async (helper, privateKey) => {80 await usingPlaygrounds(async (helper, privateKey) => {
62 });86 });
63 });87 });
64}88}
65export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {89export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
66 return itSub(name, cb, {requiredPallets: required, ...opts});90 return itSub(name, cb, {requiredPallets: required, ...opts});
67}91}
68itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSub(name, cb, {only: true});92itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});
69itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSub(name, cb, {skip: true});93itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {skip: true});
7094
71itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSubIfWithPallet(name, required, cb, {only: true});95itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {only: true});
72itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});96itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});
73itSub.ifWithPallets = itSubIfWithPallet;97itSub.ifWithPallets = itSubIfWithPallet;
7498