git.delta.rocks / unique-network / refs/commits / b6e3ded7aa81

difftreelog

Split tests to sequential and parallel, remove Alice and friends

Max Andreev2022-11-01parent: #26798c3.patch.diff
in: master

14 files changed

addedtests/src/eth/createFTCollection.seqtest.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
31 });31 });
32 });32 });
3333
34 itEth('Create collection', async ({helper}) => {
35 const owner = await helper.eth.createAccountWithBalance(donor);
36
37 const name = 'CollectionEVM';
38 const description = 'Some description';
39 const prefix = 'token prefix';
40
41 // todo:playgrounds this might fail when in async environment.
42 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
43
44 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);
45
46 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
47 const data = (await helper.ft.getData(collectionId))!;
48
49 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
50 expect(collectionId).to.be.eq(collectionCountAfter);
51 expect(data.name).to.be.eq(name);
52 expect(data.description).to.be.eq(description);
53 expect(data.raw.tokenPrefix).to.be.eq(prefix);
54 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});
55 });
56
57 // todo:playgrounds this test will fail when in async environment.
58 itEth('Check collection address exist', async ({helper}) => {
59 const owner = await helper.eth.createAccountWithBalance(donor);
60
61 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
62 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
63 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
64
65 expect(await collectionHelpers.methods
66 .isCollectionExist(expectedCollectionAddress)
67 .call()).to.be.false;
68
69
70 await helper.eth.createFungibleCollection(owner, 'A', DECIMALS, 'A', 'A');
71
72
73 expect(await collectionHelpers.methods
74 .isCollectionExist(expectedCollectionAddress)
75 .call()).to.be.true;
76 });
77
78 itEth('Set sponsorship', async ({helper}) => {34 itEth('Set sponsorship', async ({helper}) => {
79 const owner = await helper.eth.createAccountWithBalance(donor);35 const owner = await helper.eth.createAccountWithBalance(donor);
addedtests/src/eth/createNFTCollection.seqtest.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
28 });28 });
29 });29 });
30
31 itEth('Create collection', async ({helper}) => {
32 const owner = await helper.eth.createAccountWithBalance(donor);
33
34 const name = 'CollectionEVM';
35 const description = 'Some description';
36 const prefix = 'token prefix';
37
38 // todo:playgrounds this might fail when in async environment.
39 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
40 const {collectionId, collectionAddress, events} = await helper.eth.createNFTCollection(owner, name, description, prefix);
41
42 expect(events).to.be.deep.equal([
43 {
44 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',
45 event: 'CollectionCreated',
46 args: {
47 owner: owner,
48 collectionId: collectionAddress,
49 },
50 },
51 ]);
52
53 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
54
55 const collection = helper.nft.getCollectionObject(collectionId);
56 const data = (await collection.getData())!;
57
58 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
59 expect(collectionId).to.be.eq(collectionCountAfter);
60 expect(data.name).to.be.eq(name);
61 expect(data.description).to.be.eq(description);
62 expect(data.raw.tokenPrefix).to.be.eq(prefix);
63 expect(data.raw.mode).to.be.eq('NFT');
64
65 const options = await collection.getOptions();
66
67 expect(options.tokenPropertyPermissions).to.be.empty;
68 });
6930
70 itEth('Create collection with properties', async ({helper}) => {31 itEth('Create collection with properties', async ({helper}) => {
71 const owner = await helper.eth.createAccountWithBalance(donor);32 const owner = await helper.eth.createAccountWithBalance(donor);
109 ]);70 ]);
110 });71 });
111
112 // this test will occasionally fail when in async environment.
113 itEth.skip('Check collection address exist', async ({helper}) => {
114 const owner = await helper.eth.createAccountWithBalance(donor);
115
116 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
117 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
118 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
119
120 expect(await collectionHelpers.methods
121 .isCollectionExist(expectedCollectionAddress)
122 .call()).to.be.false;
123
124 await collectionHelpers.methods
125 .createNFTCollection('A', 'A', 'A')
126 .send({value: Number(2n * helper.balance.getOneTokenNominal())});
127
128 expect(await collectionHelpers.methods
129 .isCollectionExist(expectedCollectionAddress)
130 .call()).to.be.true;
131 });
13272
133 itEth('Set sponsorship', async ({helper}) => {73 itEth('Set sponsorship', async ({helper}) => {
134 const owner = await helper.eth.createAccountWithBalance(donor);74 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
148 }148 }
149 });149 });
150150
151 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {151 itEth('Can perform burnFromCross()', async ({helper}) => {
152 const alice = await privateKey('//Alice');
153 const sender = await helper.eth.createAccountWithBalance(alice, 100n);152 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
154153
155 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);154 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
156155
261 });260 });
262261
263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {262 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
264 const alice = await privateKey('//Alice');
265 const sender = await helper.eth.createAccountWithBalance(alice, 100n);263 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
266264
267 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);265 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
268266
455 });453 });
456454
457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {455 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {
458 const alice = await privateKey('//Alice');
459 const sender = await helper.eth.createAccountWithBalance(alice, 100n);456 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
460457
461 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);458 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
462459
addedtests/src/eth/migration.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/eth/migration.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
139describe('NFT: Plain calls', () => {139describe('NFT: Plain calls', () => {
140 let donor: IKeyringPair;140 let donor: IKeyringPair;
141 let alice: IKeyringPair;141 let alice: IKeyringPair;
142 let bob: IKeyringPair;
143 let charlie: IKeyringPair;
142144
143 before(async function() {145 before(async function() {
144 await usingEthPlaygrounds(async (helper, privateKey) => {146 await usingEthPlaygrounds(async (helper, privateKey) => {
145 donor = await privateKey({filename: __filename});147 donor = await privateKey({filename: __filename});
146 [alice] = await helper.arrange.createAccounts([10n], donor);148 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
147 });149 });
148 });150 });
149151
247 });249 });
248250
249 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {251 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
250 const alice = await privateKey('//Alice');
251 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});252 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
252253
253 const owner = await privateKey('//Bob');254 const owner = bob;
254 const spender = await helper.eth.createAccountWithBalance(alice, 100n);255 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
255256
256 const token = await collection.mintToken(alice, {Substrate: owner.address});257 const token = await collection.mintToken(alice, {Substrate: owner.address});
257258
277 });278 });
278279
279 itEth('Can perform approveCross()', async ({helper, privateKey}) => {280 itEth('Can perform approveCross()', async ({helper, privateKey}) => {
280 const alice = await privateKey('//Alice');
281 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});281 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
282282
283 const owner = await helper.eth.createAccountWithBalance(alice, 100n);283 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
284 const receiver = await privateKey('//Charlie');284 const receiver = charlie;
285285
286 const token = await collection.mintToken(alice, {Ethereum: owner});286 const token = await collection.mintToken(alice, {Ethereum: owner});
287287
373describe('NFT: Fees', () => {373describe('NFT: Fees', () => {
374 let donor: IKeyringPair;374 let donor: IKeyringPair;
375 let alice: IKeyringPair;375 let alice: IKeyringPair;
376 let bob: IKeyringPair;
377 let charlie: IKeyringPair;
376378
377 before(async function() {379 before(async function() {
378 await usingEthPlaygrounds(async (helper, privateKey) => {380 await usingEthPlaygrounds(async (helper, privateKey) => {
379 donor = await privateKey({filename: __filename});381 donor = await privateKey({filename: __filename});
380 [alice] = await helper.arrange.createAccounts([10n], donor);382 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
381 });383 });
382 });384 });
383385
410 });412 });
411413
412 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {414 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
413 const alice = await privateKey('//Alice');415 const collectionMinter = alice;
416 const owner = bob;
417 const receiver = charlie;
414 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});418 const collection = await helper.nft.mintCollection(collectionMinter, {name: 'A', description: 'B', tokenPrefix: 'C'});
415419
416 const owner = await privateKey('//Bob');
417 const spender = await helper.eth.createAccountWithBalance(alice, 100n);420 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
418 const receiver = await privateKey('//Charlie');
419421
420 const token = await collection.mintToken(alice, {Substrate: owner.address});422 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});
421423
422 const address = helper.ethAddress.fromCollectionId(collection.collectionId);424 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
423 const contract = helper.ethNativeContract.collection(address, 'nft');425 const contract = helper.ethNativeContract.collection(address, 'nft');
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
104104
105describe('Refungible: Plain calls', () => {105describe('Refungible: Plain calls', () => {
106 let donor: IKeyringPair;106 let donor: IKeyringPair;
107 let alice: IKeyringPair;
108 let bob: IKeyringPair;
109 let charlie: IKeyringPair;
107110
108 before(async function() {111 before(async function() {
109 await usingEthPlaygrounds(async (helper, privateKey) => {112 await usingEthPlaygrounds(async (helper, privateKey) => {
110 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);113 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
111114
112 donor = await privateKey({filename: __filename});115 donor = await privateKey({filename: __filename});
116 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
113 });117 });
114 });118 });
115119
228 });232 });
229233
230 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {234 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {
231 const alice = await privateKey('//Alice');
232 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});235 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
233236
234 const owner = await helper.eth.createAccountWithBalance(alice, 100n);237 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
235 const spender = await helper.eth.createAccountWithBalance(alice, 100n);238 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
236239
237 const token = await collection.mintToken(alice, 100n, {Ethereum: owner});240 const token = await collection.mintToken(alice, 100n, {Ethereum: owner});
238241
262 });265 });
263266
264 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {267 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
265 const alice = await privateKey('//Alice');
266 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});268 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
267269
268 const owner = await privateKey('//Bob');270 const owner = bob;
269 const spender = await helper.eth.createAccountWithBalance(alice, 100n);271 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
270272
271 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});273 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
272274
295 });297 });
296298
297 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {299 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
298 const alice = await privateKey('//Alice');
299 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});300 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
300301
301 const owner = await privateKey('//Bob');302 const owner = bob;
302 const spender = await helper.eth.createAccountWithBalance(alice, 100n);303 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
303 const receiver = await privateKey('//Charlie');304 const receiver = charlie;
304305
305 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});306 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
306307
modifiedtests/src/eth/scheduling.test.tsdiffbeforeafterboth
26 });26 });
27 });27 });
2828
29 itEth.ifWithPallets('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {29 itEth.ifWithPallets.only('Successfully schedules and periodically executes an EVM contract', [Pallets.Scheduler], async ({helper, privateKey}) => {
30 const alice = await privateKey('//Alice');30 const donor = await privateKey({filename: __filename});
31 const [alice] = await helper.arrange.createAccounts([1000n], donor);
3132
32 const scheduledId = await helper.arrange.makeScheduledId();33 const scheduledId = await helper.arrange.makeScheduledId();
3334
addedtests/src/inflation.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/inflation.test.tsdiffbeforeafterboth

no changes

addedtests/src/scheduler.seqtest.tsdiffbeforeafterboth

no changes

deletedtests/src/scheduler.test.tsdiffbeforeafterboth

no changes