git.delta.rocks / unique-network / refs/commits / 3d7ffe75f2a8

difftreelog

fix skip refungible and scheduler tests on qtz/unq

Daniel Shiposha2022-08-09parent: #5eadf5f.patch.diff
in: master

43 files changed

modifiedtests/src/approve.test.tsdiffbeforeafterboth
32 getCreatedCollectionCount,32 getCreatedCollectionCount,
33 transferFromExpectSuccess,33 transferFromExpectSuccess,
34 transferFromExpectFail,34 transferFromExpectFail,
35 requirePallets,
36 Pallets
35} from './util/helpers';37} from './util/helpers';
3638
37chai.use(chaiAsPromised);39chai.use(chaiAsPromised);
49 });51 });
50 });52 });
53
54 it('[nft] Execute the extrinsic and check approvedList', async () => {
55 const nftCollectionId = await createCollectionExpectSuccess();
56 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
57 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
58 });
59
60 it('[fungible] Execute the extrinsic and check approvedList', async () => {
61 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
62 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
63 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
64 });
65
66 it('[refungible] Execute the extrinsic and check approvedList', async function() {
67 await requirePallets(this, [Pallets.ReFungible]);
68
69 const reFungibleCollectionId =
70 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
71 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
72 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
73 });
74
75 it('[nft] Remove approval by using 0 amount', async () => {
76 const nftCollectionId = await createCollectionExpectSuccess();
77 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
78 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 1);
79 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 0);
80 });
5181
52 it('Execute the extrinsic and check approvedList', async () => {82 it('[fungible] Remove approval by using 0 amount', async () => {
53 const nftCollectionId = await createCollectionExpectSuccess();
54 // nft
55 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
56 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
57 // fungible
58 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});83 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
59 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');84 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
60 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);85 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 1);
61 // reFungible
62 const reFungibleCollectionId =
63 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
64 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
65 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);86 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 0);
66 });87 });
6788
68 it('Remove approval by using 0 amount', async () => {89 it('[refungible] Remove approval by using 0 amount', async function() {
69 const nftCollectionId = await createCollectionExpectSuccess();
70 // nft
71 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
72 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 1);90 await requirePallets(this, [Pallets.ReFungible]);
73 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 0);91
74 // fungible
75 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
76 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
77 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 1);
78 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 0);
79 // reFungible
80 const reFungibleCollectionId =92 const reFungibleCollectionId =
81 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});93 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
82 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');94 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
117 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);129 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
118 });130 });
119131
120 it('ReFungible up to an approved amount', async () => {132 it('ReFungible up to an approved amount', async function() {
133 await requirePallets(this, [Pallets.ReFungible]);
134
121 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});135 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
122 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);136 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
151 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'Fungible');165 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'Fungible');
152 });166 });
153167
154 it('ReFungible up to an approved amount', async () => {168 it('ReFungible up to an approved amount', async function() {
169 await requirePallets(this, [Pallets.ReFungible]);
170
155 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});171 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
156 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);172 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
188 await transferFromExpectFail(collectionId, itemId, charlie, bob, alice, 1);204 await transferFromExpectFail(collectionId, itemId, charlie, bob, alice, 1);
189 });205 });
190206
191 it('ReFungible up to an approved amount', async () => {207 it('ReFungible up to an approved amount', async function() {
208 await requirePallets(this, [Pallets.ReFungible]);
209
192 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});210 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
193 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);211 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
250 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, bob, charlie, 1);268 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, bob, charlie, 1);
251 });269 });
252270
253 it('ReFungible', async () => {271 it('ReFungible', async function() {
272 await requirePallets(this, [Pallets.ReFungible]);
273
254 const reFungibleCollectionId =274 const reFungibleCollectionId =
255 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});275 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
285 await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, charlie, 11);305 await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, charlie, 11);
286 });306 });
287307
288 it('ReFungible', async () => {308 it('ReFungible', async function() {
309 await requirePallets(this, [Pallets.ReFungible]);
310
289 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});311 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
290 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');312 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
325 await transferFromExpectSuccess(collectionId, itemId, bob, dave, alice, 1, 'Fungible');347 await transferFromExpectSuccess(collectionId, itemId, bob, dave, alice, 1, 'Fungible');
326 });348 });
327349
328 it('ReFungible up to an approved amount', async () => {350 it('ReFungible up to an approved amount', async function() {
351 await requirePallets(this, [Pallets.ReFungible]);
352
329 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});353 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
330 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});354 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
422 });446 });
423 });447 });
424448
425 it('Approve for a collection that does not exist', async () => {449 it('[nft] Approve for a collection that does not exist', async () => {
426 await usingApi(async (api: ApiPromise) => {450 await usingApi(async (api: ApiPromise) => {
427 // nft
428 const nftCollectionCount = await getCreatedCollectionCount(api);451 const nftCollectionCount = await getCreatedCollectionCount(api);
429 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);452 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
430 // fungible
431 const fungibleCollectionCount = await getCreatedCollectionCount(api);
432 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
433 // reFungible
434 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
435 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
436 });453 });
437 });454 });
455
456 it('[fungible] Approve for a collection that does not exist', async () => {
457 await usingApi(async (api: ApiPromise) => {
458 const fungibleCollectionCount = await getCreatedCollectionCount(api);
459 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
460 });
461 });
462
463 it('[refungible] Approve for a collection that does not exist', async function() {
464 await requirePallets(this, [Pallets.ReFungible]);
465
466 await usingApi(async (api: ApiPromise) => {
467 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
468 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
469 });
470 });
471
472 it('[nft] Approve for a collection that was destroyed', async () => {
473 const nftCollectionId = await createCollectionExpectSuccess();
474 await destroyCollectionExpectSuccess(nftCollectionId);
475 await approveExpectFail(nftCollectionId, 1, alice, bob);
476 });
438477
439 it('Approve for a collection that was destroyed', async () => {478 it('Approve for a collection that was destroyed', async () => {
440 // nft
441 const nftCollectionId = await createCollectionExpectSuccess();
442 await destroyCollectionExpectSuccess(nftCollectionId);
443 await approveExpectFail(nftCollectionId, 1, alice, bob);
444 // fungible
445 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});479 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
446 await destroyCollectionExpectSuccess(fungibleCollectionId);480 await destroyCollectionExpectSuccess(fungibleCollectionId);
447 await approveExpectFail(fungibleCollectionId, 0, alice, bob);481 await approveExpectFail(fungibleCollectionId, 0, alice, bob);
448 // reFungible
449 const reFungibleCollectionId =
450 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
451 await destroyCollectionExpectSuccess(reFungibleCollectionId);
452 await approveExpectFail(reFungibleCollectionId, 1, alice, bob);
453 });482 });
483
484 it('[refungible] Approve for a collection that was destroyed', async function() {
485 await requirePallets(this, [Pallets.ReFungible]);
486
487 const reFungibleCollectionId =
488 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
489 await destroyCollectionExpectSuccess(reFungibleCollectionId);
490 await approveExpectFail(reFungibleCollectionId, 1, alice, bob);
491 });
492
493 it('[nft] Approve transfer of a token that does not exist', async () => {
494 const nftCollectionId = await createCollectionExpectSuccess();
495 await approveExpectFail(nftCollectionId, 2, alice, bob);
496 });
454497
455 it('Approve transfer of a token that does not exist', async () => {498 it('[refungible] Approve transfer of a token that does not exist', async function() {
456 // nft
457 const nftCollectionId = await createCollectionExpectSuccess();
458 await approveExpectFail(nftCollectionId, 2, alice, bob);499 await requirePallets(this, [Pallets.ReFungible]);
459 // reFungible500
460 const reFungibleCollectionId =501 const reFungibleCollectionId =
461 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});502 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
462 await approveExpectFail(reFungibleCollectionId, 2, alice, bob);503 await approveExpectFail(reFungibleCollectionId, 2, alice, bob);
463 });504 });
505
506 it('[nft] Approve using the address that does not own the approved token', async () => {
507 const nftCollectionId = await createCollectionExpectSuccess();
508 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
509 await approveExpectFail(nftCollectionId, newNftTokenId, bob, alice);
510 });
511
512 it('[fungible] Approve using the address that does not own the approved token', async () => {
513 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
514 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
515 await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice);
516 });
464517
465 it('Approve using the address that does not own the approved token', async () => {518 it('[refungible] Approve using the address that does not own the approved token', async function() {
466 const nftCollectionId = await createCollectionExpectSuccess();
467 // nft
468 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
469 await approveExpectFail(nftCollectionId, newNftTokenId, bob, alice);
470 // fungible
471 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});519 await requirePallets(this, [Pallets.ReFungible]);
472 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');520
473 await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice);
474 // reFungible
475 const reFungibleCollectionId =521 const reFungibleCollectionId =
476 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});522 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
477 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');523 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
478 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, alice);524 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, alice);
479 });525 });
480526
481 it('should fail if approved more ReFungibles than owned', async () => {527 it('should fail if approved more ReFungibles than owned', async function() {
528 await requirePallets(this, [Pallets.ReFungible]);
529
482 const nftCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});530 const nftCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
483 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'ReFungible');531 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'ReFungible');
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
25 getBalance,25 getBalance,
26 setCollectionLimitsExpectSuccess,26 setCollectionLimitsExpectSuccess,
27 isTokenExists,27 isTokenExists,
28 requirePallets,
29 Pallets
28} from './util/helpers';30} from './util/helpers';
2931
30import chai from 'chai';32import chai from 'chai';
80 });82 });
81 });83 });
8284
83 it('Burn item in ReFungible collection', async () => {85 it('Burn item in ReFungible collection', async function() {
86 await requirePallets(this, [Pallets.ReFungible]);
87
84 const createMode = 'ReFungible';88 const createMode = 'ReFungible';
85 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});89 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
99 });103 });
100 });104 });
101105
102 it('Burn owned portion of item in ReFungible collection', async () => {106 it('Burn owned portion of item in ReFungible collection', async function() {
107 await requirePallets(this, [Pallets.ReFungible]);
108
103 const createMode = 'ReFungible';109 const createMode = 'ReFungible';
104 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});110 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
189 });195 });
190196
191 // TODO: burnFrom197 // TODO: burnFrom
192 it('Burn item in ReFungible collection', async () => {198 it('Burn item in ReFungible collection', async function() {
199 await requirePallets(this, [Pallets.ReFungible]);
200
193 const createMode = 'ReFungible';201 const createMode = 'ReFungible';
194 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});202 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
33 addCollectionAdminExpectSuccess,33 addCollectionAdminExpectSuccess,
34 getCreatedCollectionCount,34 getCreatedCollectionCount,
35 UNIQUE,35 UNIQUE,
36 requirePallets,
37 Pallets
36} from './util/helpers';38} from './util/helpers';
37import {IKeyringPair} from '@polkadot/types/types';39import {IKeyringPair} from '@polkadot/types/types';
3840
124 });126 });
125 });127 });
126128
127 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {129 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async function() {
130 await requirePallets(this, [Pallets.ReFungible]);
131
128 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});132 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
129 await setCollectionSponsorExpectSuccess(collectionId, bob.address);133 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
252 });256 });
253 });257 });
254258
255 it('ReFungible: Sponsoring is rate limited', async () => {259 it('ReFungible: Sponsoring is rate limited', async function() {
260 await requirePallets(this, [Pallets.ReFungible]);
261
256 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});262 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
257 await setCollectionSponsorExpectSuccess(collectionId, bob.address);263 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';18import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';
19import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';19import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess, requirePallets, Pallets} from './util/helpers';
2020
21describe('integration test: ext. createCollection():', () => {21describe('integration test: ext. createCollection():', () => {
22 it('Create new NFT collection', async () => {22 it('Create new NFT collection', async () => {
34 it('Create new Fungible collection', async () => {34 it('Create new Fungible collection', async () => {
35 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});35 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
36 });36 });
37 it('Create new ReFungible collection', async () => {37 it('Create new ReFungible collection', async function() {
38 await requirePallets(this, [Pallets.ReFungible]);
39
38 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
39 });41 });
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
29 itApi,29 itApi,
30 normalizeAccountId,30 normalizeAccountId,
31 getCreateItemResult,31 getCreateItemResult,
32 requirePallets,
33 Pallets
32} from './util/helpers';34} from './util/helpers';
3335
34const expect = chai.expect;36const expect = chai.expect;
79 }81 }
8082
81 });83 });
82 it('Create new item in ReFungible collection', async () => {84 it('Create new item in ReFungible collection', async function() {
85 await requirePallets(this, [Pallets.ReFungible]);
86
83 const createMode = 'ReFungible';87 const createMode = 'ReFungible';
84 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});88 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
96 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);100 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
97 await createItemExpectSuccess(bob, newCollectionID, createMode);101 await createItemExpectSuccess(bob, newCollectionID, createMode);
98 });102 });
99 it('Create new item in ReFungible collection with collection admin permissions', async () => {103 it('Create new item in ReFungible collection with collection admin permissions', async function() {
104 await requirePallets(this, [Pallets.ReFungible]);
105
100 const createMode = 'ReFungible';106 const createMode = 'ReFungible';
101 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});107 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
175 });181 });
176 });182 });
177183
178 it('Check total pieces of ReFungible token', async () => {184 it('Check total pieces of ReFungible token', async function() {
185 await requirePallets(this, [Pallets.ReFungible]);
186
179 await usingApi(async api => {187 await usingApi(async api => {
180 const createMode = 'ReFungible';188 const createMode = 'ReFungible';
219 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});227 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
220 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;228 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;
221 });229 });
222 it('Regular user cannot create new item in ReFungible collection', async () => {230 it('Regular user cannot create new item in ReFungible collection', async function() {
231 await requirePallets(this, [Pallets.ReFungible]);
232
223 const createMode = 'ReFungible';233 const createMode = 'ReFungible';
224 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});234 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
296 });306 });
297 });307 });
298308
299 it('Check total pieces for invalid Refungible token', async () => {309 it('Check total pieces for invalid Refungible token', async function() {
310 await requirePallets(this, [Pallets.ReFungible]);
311
300 await usingApi(async api => {312 await usingApi(async api => {
301 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});313 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
33 createCollectionWithPropsExpectSuccess,33 createCollectionWithPropsExpectSuccess,
34 createMultipleItemsWithPropsExpectSuccess,34 createMultipleItemsWithPropsExpectSuccess,
35 getTokenProperties,35 getTokenProperties,
36 requirePallets,
37 Pallets,
38 checkPalletsPresence
36} from './util/helpers';39} from './util/helpers';
3740
38chai.use(chaiAsPromised);41chai.use(chaiAsPromised);
91 });94 });
92 });95 });
9396
94 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {97 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {
98 await requirePallets(this, [Pallets.ReFungible]);
99
95 await usingApi(async (api, privateKeyWrapper) => {100 await usingApi(async (api, privateKeyWrapper) => {
96 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});101 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
272 });277 });
273 });278 });
274279
275 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {280 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {
281 await requirePallets(this, [Pallets.ReFungible]);
282
276 await usingApi(async (api: ApiPromise) => {283 await usingApi(async (api: ApiPromise) => {
277 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});284 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
335 });342 });
336 });343 });
337344
338 it('Regular user cannot create items in active ReFungible collection', async () => {345 it('Regular user cannot create items in active ReFungible collection', async function() {
346 await requirePallets(this, [Pallets.ReFungible]);
347
339 await usingApi(async (api: ApiPromise) => {348 await usingApi(async (api: ApiPromise) => {
340 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});349 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
358 });367 });
359 });368 });
369
370 it('Create NFTs that has reached the maximum data limit', async function() {
371 await usingApi(async (api, privateKeyWrapper) => {
372 const collectionId = await createCollectionWithPropsExpectSuccess({
373 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
374 });
375 const alice = privateKeyWrapper('//Alice');
376 const args = [
377 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},
378 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},
379 {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},
380 ];
381 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
382 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
383 });
384 });
360385
361 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {386 it('Create Refungible tokens that has reached the maximum data limit', async function() {
387 await requirePallets(this, [Pallets.ReFungible]);
388
362 await usingApi(async (api, privateKeyWrapper) => {389 await usingApi(async api => {
363 // NFT
364 const collectionId = await createCollectionWithPropsExpectSuccess({
365 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
366 });
367 const alice = privateKeyWrapper('//Alice');
368 const args = [
369 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},
370 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},
371 {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},
372 ];
373 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
374 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
375
376 // ReFungible
377 const collectionIdReFungible =390 const collectionIdReFungible =
378 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});391 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
379 {392 {
403 await usingApi(async (api: ApiPromise) => {416 await usingApi(async (api: ApiPromise) => {
404 const collectionId = await createCollectionExpectSuccess();417 const collectionId = await createCollectionExpectSuccess();
418
419 let types = ['NFT', 'Fungible'];
420
421 if (await checkPalletsPresence([Pallets.ReFungible])) {
422 types.push('ReFungible');
423 }
424
405 const createMultipleItemsTx = api.tx.unique425 const createMultipleItemsTx = api.tx.unique
406 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);426 .createMultipleItems(collectionId, normalizeAccountId(alice.address), types);
407 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);427 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);
408 // garbage collection :-D // lol428 // garbage collection :-D // lol
409 await destroyCollectionExpectSuccess(collectionId);429 await destroyCollectionExpectSuccess(collectionId);
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import usingApi, {executeTransaction} from './substrate/substrate-api';18import usingApi, {executeTransaction} from './substrate/substrate-api';
19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, getBalance, getLastTokenId, getTokenProperties} from './util/helpers';19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, getBalance, getLastTokenId, getTokenProperties, requirePallets, Pallets} from './util/helpers';
2020
21describe.only('Integration Test: createMultipleItemsEx', () => {21describe.only('Integration Test: createMultipleItemsEx', () => {
22 it('can initialize multiple NFT with different owners', async () => {22 it('can initialize multiple NFT with different owners', async () => {
146 });146 });
147 });147 });
148148
149 it('can initialize an RFT with multiple owners', async () => {149 it('can initialize an RFT with multiple owners', async function() {
150 await requirePallets(this, [Pallets.ReFungible]);
151
150 await usingApi(async (api, privateKeyWrapper) => {152 await usingApi(async (api, privateKeyWrapper) => {
151 const alice = privateKeyWrapper('//Alice');153 const alice = privateKeyWrapper('//Alice');
178 });180 });
179 });181 });
180182
181 it('can initialize multiple RFTs with the same owner', async () => {183 it('can initialize multiple RFTs with the same owner', async function() {
184 await requirePallets(this, [Pallets.ReFungible]);
185
182 await usingApi(async (api, privateKeyWrapper) => {186 await usingApi(async (api, privateKeyWrapper) => {
183 const alice = privateKeyWrapper('//Alice');187 const alice = privateKeyWrapper('//Alice');
389 });393 });
390 });394 });
391395
392 it('fails when trying to set multiple owners when creating multiple refungibles', async () => {396 it('fails when trying to set multiple owners when creating multiple refungibles', async function() {
397 await requirePallets(this, [Pallets.ReFungible]);
398
393 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});399 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
394400
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
25 addCollectionAdminExpectSuccess,25 addCollectionAdminExpectSuccess,
26 getCreatedCollectionCount,26 getCreatedCollectionCount,
27 createItemExpectSuccess,27 createItemExpectSuccess,
28 requirePallets,
29 Pallets
28} from './util/helpers';30} from './util/helpers';
2931
30chai.use(chaiAsPromised);32chai.use(chaiAsPromised);
38 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});40 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
39 await destroyCollectionExpectSuccess(collectionId);41 await destroyCollectionExpectSuccess(collectionId);
40 });42 });
41 it('ReFungible collection can be destroyed', async () => {43 it('ReFungible collection can be destroyed', async function() {
44 await requirePallets(this, [Pallets.ReFungible]);
45
42 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});46 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
43 await destroyCollectionExpectSuccess(collectionId);47 await destroyCollectionExpectSuccess(collectionId);
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
1616
17import {evmToAddress} from '@polkadot/util-crypto';17import {evmToAddress} from '@polkadot/util-crypto';
18import {expect} from 'chai';18import {expect} from 'chai';
19import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';19import {getCreatedCollectionCount, getDetailedCollectionInfo, requirePallets, Pallets} from '../util/helpers';
20import {20import {
21 evmCollectionHelpers,21 evmCollectionHelpers,
22 collectionIdToAddress,22 collectionIdToAddress,
28} from './util/helpers';28} from './util/helpers';
2929
30describe('Create RFT collection from EVM', () => {30describe('Create RFT collection from EVM', () => {
31 before(async function() {
32 await requirePallets(this, [Pallets.ReFungible]);
33 });
34
31 itWeb3('Create collection', async ({api, web3, privateKeyWrapper}) => {35 itWeb3('Create collection', async ({api, web3, privateKeyWrapper}) => {
32 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);36 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
146});150});
147151
148describe('(!negative tests!) Create RFT collection from EVM', () => {152describe('(!negative tests!) Create RFT collection from EVM', () => {
153 before(async function() {
154 await requirePallets(this, [Pallets.ReFungible]);
155 });
156
149 itWeb3('(!negative test!) Create collection (bad lengths)', async ({api, web3, privateKeyWrapper}) => {157 itWeb3('(!negative test!) Create collection (bad lengths)', async ({api, web3, privateKeyWrapper}) => {
150 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);158 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// 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/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {createCollectionExpectSuccess, UNIQUE} from '../util/helpers';17import {createCollectionExpectSuccess, UNIQUE, requirePallets, Pallets} from '../util/helpers';
18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, tokenIdToAddress} from './util/helpers';
19import reFungibleTokenAbi from './reFungibleTokenAbi.json';19import reFungibleTokenAbi from './reFungibleTokenAbi.json';
20import {expect} from 'chai';20import {expect} from 'chai';
2121
22describe('Refungible: Information getting', () => {22describe('Refungible: Information getting', () => {
23 before(async function() {
24 await requirePallets(this, [Pallets.ReFungible]);
25 });
26
23 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {27 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
24 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);28 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
120});124});
121125
122describe('Refungible: Plain calls', () => {126describe('Refungible: Plain calls', () => {
127 before(async function() {
128 await requirePallets(this, [Pallets.ReFungible]);
129 });
130
123 itWeb3('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {131 itWeb3('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {
124 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);132 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
399});407});
400408
401describe('RFT: Fees', () => {409describe('RFT: Fees', () => {
410 before(async function() {
411 await requirePallets(this, [Pallets.ReFungible]);
412 });
413
402 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {414 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
403 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);415 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
435});447});
436448
437describe('Common metadata', () => {449describe('Common metadata', () => {
450 before(async function() {
451 await requirePallets(this, [Pallets.ReFungible]);
452 });
453
438 itWeb3('Returns collection name', async ({api, web3, privateKeyWrapper}) => {454 itWeb3('Returns collection name', async ({api, web3, privateKeyWrapper}) => {
439 const collection = await createCollectionExpectSuccess({455 const collection = await createCollectionExpectSuccess({
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// 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/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE} from '../util/helpers';17import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';
18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth} from './util/helpers';
19import reFungibleTokenAbi from './reFungibleTokenAbi.json';19import reFungibleTokenAbi from './reFungibleTokenAbi.json';
2020
24const expect = chai.expect;24const expect = chai.expect;
2525
26describe('Refungible token: Information getting', () => {26describe('Refungible token: Information getting', () => {
27 before(async function() {
28 await requirePallets(this, [Pallets.ReFungible]);
29 });
30
27 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {31 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
28 const alice = privateKeyWrapper('//Alice');32 const alice = privateKeyWrapper('//Alice');
7579
76// FIXME: Need erc721 for ReFubgible.80// FIXME: Need erc721 for ReFubgible.
77describe('Check ERC721 token URI for ReFungible', () => {81describe('Check ERC721 token URI for ReFungible', () => {
82 before(async function() {
83 await requirePallets(this, [Pallets.ReFungible]);
84 });
85
78 itWeb3('Empty tokenURI', async ({web3, api, privateKeyWrapper}) => {86 itWeb3('Empty tokenURI', async ({web3, api, privateKeyWrapper}) => {
79 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);87 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
216});224});
217225
218describe('Refungible: Plain calls', () => {226describe('Refungible: Plain calls', () => {
227 before(async function() {
228 await requirePallets(this, [Pallets.ReFungible]);
229 });
230
219 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {231 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
220 const alice = privateKeyWrapper('//Alice');232 const alice = privateKeyWrapper('//Alice');
477});489});
478490
479describe('Refungible: Fees', () => {491describe('Refungible: Fees', () => {
492 before(async function() {
493 await requirePallets(this, [Pallets.ReFungible]);
494 });
495
480 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {496 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
481 const alice = privateKeyWrapper('//Alice');497 const alice = privateKeyWrapper('//Alice');
532});548});
533549
534describe('Refungible: Substrate calls', () => {550describe('Refungible: Substrate calls', () => {
551 before(async function() {
552 await requirePallets(this, [Pallets.ReFungible]);
553 });
554
535 itWeb3('Events emitted for approve()', async ({web3, api, privateKeyWrapper}) => {555 itWeb3('Events emitted for approve()', async ({web3, api, privateKeyWrapper}) => {
536 const alice = privateKeyWrapper('//Alice');556 const alice = privateKeyWrapper('//Alice');
modifiedtests/src/eth/scheduling.test.tsdiffbeforeafterboth
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';18import {createEthAccountWithBalance, deployFlipper, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';
19import {scheduleExpectSuccess, waitNewBlocks} from '../util/helpers';19import {scheduleExpectSuccess, waitNewBlocks, requirePallets, Pallets} from '../util/helpers';
2020
21describe('Scheduing EVM smart contracts', () => {21describe('Scheduing EVM smart contracts', () => {
22 before(async function() {
23 await requirePallets(this, [Pallets.Scheduler]);
24 });
25
22 itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {26 itWeb3('Successfully schedules and periodically executes an EVM contract', async ({api, web3, privateKeyWrapper}) => {
23 const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);27 const deployer = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
modifiedtests/src/limits.test.tsdiffbeforeafterboth
27 transferExpectSuccess,27 transferExpectSuccess,
28 getFreeBalance,28 getFreeBalance,
29 waitNewBlocks, burnItemExpectSuccess,29 waitNewBlocks, burnItemExpectSuccess,
30 requirePallets,
31 Pallets
30} from './util/helpers';32} from './util/helpers';
31import {expect} from 'chai';33import {expect} from 'chai';
3234
67describe('Number of tokens per address (ReFungible)', () => {69describe('Number of tokens per address (ReFungible)', () => {
68 let alice: IKeyringPair;70 let alice: IKeyringPair;
6971
70 before(async () => {72 before(async function() {
73 await requirePallets(this, [Pallets.ReFungible]);
74
71 await usingApi(async (api, privateKeyWrapper) => {75 await usingApi(async (api, privateKeyWrapper) => {
72 alice = privateKeyWrapper('//Alice');76 alice = privateKeyWrapper('//Alice');
367 let bob: IKeyringPair;371 let bob: IKeyringPair;
368 let charlie: IKeyringPair;372 let charlie: IKeyringPair;
369373
370 before(async () => {374 before(async function() {
375 await requirePallets(this, [Pallets.ReFungible]);
376
371 await usingApi(async (api, privateKeyWrapper) => {377 await usingApi(async (api, privateKeyWrapper) => {
372 alice = privateKeyWrapper('//Alice');378 alice = privateKeyWrapper('//Alice');
modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
17 transferExpectSuccess,17 transferExpectSuccess,
18 transferFromExpectSuccess,18 transferFromExpectSuccess,
19 setCollectionLimitsExpectSuccess,19 setCollectionLimitsExpectSuccess,
20 requirePallets,
21 Pallets
20} from '../util/helpers';22} from '../util/helpers';
21import {IKeyringPair} from '@polkadot/types/types';23import {IKeyringPair} from '@polkadot/types/types';
2224
311313
312 // ---------- Re-Fungible ----------314 // ---------- Re-Fungible ----------
313315
314 it('ReFungible: allows an Owner to nest/unnest their token', async () => {316 it('ReFungible: allows an Owner to nest/unnest their token', async function() {
317 await requirePallets(this, [Pallets.ReFungible]);
318
315 await usingApi(async api => {319 await usingApi(async api => {
316 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});320 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
333 });337 });
334 });338 });
335339
336 it('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {340 it('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', async function() {
341 await requirePallets(this, [Pallets.ReFungible]);
342
337 await usingApi(async api => {343 await usingApi(async api => {
338 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});344 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
715721
716 // ---------- Re-Fungible ----------722 // ---------- Re-Fungible ----------
717723
718 it('ReFungible: disallows to nest token if nesting is disabled', async () => {724 it('ReFungible: disallows to nest token if nesting is disabled', async function() {
725 await requirePallets(this, [Pallets.ReFungible]);
726
719 await usingApi(async api => {727 await usingApi(async api => {
720 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});728 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
745 });753 });
746 });754 });
747755
748 it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => {756 it('ReFungible: disallows a non-Owner to nest someone else\'s token', async function() {
757 await requirePallets(this, [Pallets.ReFungible]);
758
749 await usingApi(async api => {759 await usingApi(async api => {
750 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});760 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
773 });783 });
774 });784 });
775785
776 it('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {786 it('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async function() {
787 await requirePallets(this, [Pallets.ReFungible]);
788
777 await usingApi(async api => {789 await usingApi(async api => {
778 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});790 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
800 });812 });
801 });813 });
802814
803 it('ReFungible: disallows to nest token to an unlisted collection', async () => {815 it('ReFungible: disallows to nest token to an unlisted collection', async function() {
816 await requirePallets(this, [Pallets.ReFungible]);
817
804 await usingApi(async api => {818 await usingApi(async api => {
805 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});819 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
8 createItemExpectSuccess,8 createItemExpectSuccess,
9 getCreateCollectionResult,9 getCreateCollectionResult,
10 transferExpectSuccess,10 transferExpectSuccess,
11 requirePallets,
12 Pallets
11} from '../util/helpers';13} from '../util/helpers';
12import {IKeyringPair} from '@polkadot/types/types';14import {IKeyringPair} from '@polkadot/types/types';
13import {tokenIdToAddress} from '../eth/util/helpers';15import {tokenIdToAddress} from '../eth/util/helpers';
64 await testMakeSureSuppliesRequired({type: 'NFT'});66 await testMakeSureSuppliesRequired({type: 'NFT'});
65 });67 });
6668
67 it('Makes sure collectionById supplies required fields for ReFungible', async () => {69 it('Makes sure collectionById supplies required fields for ReFungible', async function() {
70 await requirePallets(this, [Pallets.ReFungible]);
71
68 await testMakeSureSuppliesRequired({type: 'ReFungible'});72 await testMakeSureSuppliesRequired({type: 'ReFungible'});
69 });73 });
120 it('Sets properties for a NFT collection', async () => {124 it('Sets properties for a NFT collection', async () => {
121 await testSetsPropertiesForCollection('NFT');125 await testSetsPropertiesForCollection('NFT');
122 });126 });
123 it('Sets properties for a ReFungible collection', async () => {127 it('Sets properties for a ReFungible collection', async function() {
128 await requirePallets(this, [Pallets.ReFungible]);
129
124 await testSetsPropertiesForCollection('ReFungible');130 await testSetsPropertiesForCollection('ReFungible');
125 });131 });
178 it('Check valid names for NFT collection properties keys', async () => {184 it('Check valid names for NFT collection properties keys', async () => {
179 await testCheckValidNames('NFT');185 await testCheckValidNames('NFT');
180 });186 });
181 it('Check valid names for ReFungible collection properties keys', async () => {187 it('Check valid names for ReFungible collection properties keys', async function() {
188 await requirePallets(this, [Pallets.ReFungible]);
189
182 await testCheckValidNames('ReFungible');190 await testCheckValidNames('ReFungible');
183 });191 });
209 it('Changes properties of a NFT collection', async () => {217 it('Changes properties of a NFT collection', async () => {
210 await testChangesProperties({type: 'NFT'});218 await testChangesProperties({type: 'NFT'});
211 });219 });
212 it('Changes properties of a ReFungible collection', async () => {220 it('Changes properties of a ReFungible collection', async function() {
221 await requirePallets(this, [Pallets.ReFungible]);
222
213 await testChangesProperties({type: 'ReFungible'});223 await testChangesProperties({type: 'ReFungible'});
214 });224 });
238 it('Deletes properties of a NFT collection', async () => {248 it('Deletes properties of a NFT collection', async () => {
239 await testDeleteProperties({type: 'NFT'});249 await testDeleteProperties({type: 'NFT'});
240 });250 });
241 it('Deletes properties of a ReFungible collection', async () => {251 it('Deletes properties of a ReFungible collection', async function() {
252 await requirePallets(this, [Pallets.ReFungible]);
253
242 await testDeleteProperties({type: 'ReFungible'});254 await testDeleteProperties({type: 'ReFungible'});
243 });255 });
269 it('Fails to set properties in a NFT collection if not its onwer/administrator', async () => {281 it('Fails to set properties in a NFT collection if not its onwer/administrator', async () => {
270 await testFailsSetPropertiesIfNotOwnerOrAdmin({type: 'NFT'});282 await testFailsSetPropertiesIfNotOwnerOrAdmin({type: 'NFT'});
271 });283 });
272 it('Fails to set properties in a ReFungible collection if not its onwer/administrator', async () => {284 it('Fails to set properties in a ReFungible collection if not its onwer/administrator', async function() {
285 await requirePallets(this, [Pallets.ReFungible]);
286
273 await testFailsSetPropertiesIfNotOwnerOrAdmin({type: 'ReFungible'});287 await testFailsSetPropertiesIfNotOwnerOrAdmin({type: 'ReFungible'});
274 });288 });
307 it('Fails to set properties that exceed the limits (NFT)', async () => {321 it('Fails to set properties that exceed the limits (NFT)', async () => {
308 await testFailsSetPropertiesThatExeedLimits({type: 'NFT'});322 await testFailsSetPropertiesThatExeedLimits({type: 'NFT'});
309 });323 });
310 it('Fails to set properties that exceed the limits (ReFungible)', async () => {324 it('Fails to set properties that exceed the limits (ReFungible)', async function() {
325 await requirePallets(this, [Pallets.ReFungible]);
326
311 await testFailsSetPropertiesThatExeedLimits({type: 'ReFungible'});327 await testFailsSetPropertiesThatExeedLimits({type: 'ReFungible'});
312 });328 });
337 it('Fails to set more properties than it is allowed (NFT)', async () => {353 it('Fails to set more properties than it is allowed (NFT)', async () => {
338 await testFailsSetMorePropertiesThanAllowed({type: 'NFT'});354 await testFailsSetMorePropertiesThanAllowed({type: 'NFT'});
339 });355 });
340 it('Fails to set more properties than it is allowed (ReFungible)', async () => {356 it('Fails to set more properties than it is allowed (ReFungible)', async function() {
357 await requirePallets(this, [Pallets.ReFungible]);
358
341 await testFailsSetMorePropertiesThanAllowed({type: 'ReFungible'});359 await testFailsSetMorePropertiesThanAllowed({type: 'ReFungible'});
342 });360 });
392 it('Fails to set properties with invalid names (NFT)', async () => {410 it('Fails to set properties with invalid names (NFT)', async () => {
393 await testFailsSetPropertiesWithInvalidNames({type: 'NFT'});411 await testFailsSetPropertiesWithInvalidNames({type: 'NFT'});
394 });412 });
395 it('Fails to set properties with invalid names (ReFungible)', async () => {413 it('Fails to set properties with invalid names (ReFungible)', async function() {
414 await requirePallets(this, [Pallets.ReFungible]);
415
396 await testFailsSetPropertiesWithInvalidNames({type: 'ReFungible'});416 await testFailsSetPropertiesWithInvalidNames({type: 'ReFungible'});
397 });417 });
443 it('Sets access rights to properties of a collection (NFT)', async () => {463 it('Sets access rights to properties of a collection (NFT)', async () => {
444 await testSetsAccessRightsToProperties({type: 'NFT'});464 await testSetsAccessRightsToProperties({type: 'NFT'});
445 });465 });
446 it('Sets access rights to properties of a collection (ReFungible)', async () => {466 it('Sets access rights to properties of a collection (ReFungible)', async function() {
467 await requirePallets(this, [Pallets.ReFungible]);
468
447 await testSetsAccessRightsToProperties({type: 'ReFungible'});469 await testSetsAccessRightsToProperties({type: 'ReFungible'});
448 });470 });
472 it('Changes access rights to properties of a NFT collection', async () => {494 it('Changes access rights to properties of a NFT collection', async () => {
473 await testChangesAccessRightsToProperty({type: 'NFT'});495 await testChangesAccessRightsToProperty({type: 'NFT'});
474 });496 });
475 it('Changes access rights to properties of a ReFungible collection', async () => {497 it('Changes access rights to properties of a ReFungible collection', async function() {
498 await requirePallets(this, [Pallets.ReFungible]);
499
476 await testChangesAccessRightsToProperty({type: 'ReFungible'});500 await testChangesAccessRightsToProperty({type: 'ReFungible'});
477 });501 });
502 it('Prevents from setting access rights to properties of a NFT collection if not an onwer/admin', async () => {526 it('Prevents from setting access rights to properties of a NFT collection if not an onwer/admin', async () => {
503 await testPreventsFromSettingAccessRightsNotAdminOrOwner({type: 'NFT'});527 await testPreventsFromSettingAccessRightsNotAdminOrOwner({type: 'NFT'});
504 });528 });
505 it('Prevents from setting access rights to properties of a ReFungible collection if not an onwer/admin', async () => {529 it('Prevents from setting access rights to properties of a ReFungible collection if not an onwer/admin', async function() {
530 await requirePallets(this, [Pallets.ReFungible]);
531
506 await testPreventsFromSettingAccessRightsNotAdminOrOwner({type: 'ReFungible'});532 await testPreventsFromSettingAccessRightsNotAdminOrOwner({type: 'ReFungible'});
507 });533 });
531 it('Prevents from adding too many possible properties (NFT)', async () => {557 it('Prevents from adding too many possible properties (NFT)', async () => {
532 await testPreventFromAddingTooManyPossibleProperties({type: 'NFT'});558 await testPreventFromAddingTooManyPossibleProperties({type: 'NFT'});
533 });559 });
534 it('Prevents from adding too many possible properties (ReFungible)', async () => {560 it('Prevents from adding too many possible properties (ReFungible)', async function() {
561 await requirePallets(this, [Pallets.ReFungible]);
562
535 await testPreventFromAddingTooManyPossibleProperties({type: 'ReFungible'});563 await testPreventFromAddingTooManyPossibleProperties({type: 'ReFungible'});
536 });564 });
560 it('Prevents access rights to be modified if constant (NFT)', async () => {588 it('Prevents access rights to be modified if constant (NFT)', async () => {
561 await testPreventAccessRightsModifiedIfConstant({type: 'NFT'});589 await testPreventAccessRightsModifiedIfConstant({type: 'NFT'});
562 });590 });
563 it('Prevents access rights to be modified if constant (ReFungible)', async () => {591 it('Prevents access rights to be modified if constant (ReFungible)', async function() {
592 await requirePallets(this, [Pallets.ReFungible]);
593
564 await testPreventAccessRightsModifiedIfConstant({type: 'ReFungible'});594 await testPreventAccessRightsModifiedIfConstant({type: 'ReFungible'});
565 });595 });
608 it('Prevents adding properties with invalid names (NFT)', async () => {638 it('Prevents adding properties with invalid names (NFT)', async () => {
609 await testPreventsAddingPropertiesWithInvalidNames({type: 'NFT'});639 await testPreventsAddingPropertiesWithInvalidNames({type: 'NFT'});
610 });640 });
611 it('Prevents adding properties with invalid names (ReFungible)', async () => {641 it('Prevents adding properties with invalid names (ReFungible)', async function() {
642 await requirePallets(this, [Pallets.ReFungible]);
643
612 await testPreventsAddingPropertiesWithInvalidNames({type: 'ReFungible'});644 await testPreventsAddingPropertiesWithInvalidNames({type: 'ReFungible'});
613 });645 });
651 it('Reads yet empty properties of a token (NFT)', async () => {683 it('Reads yet empty properties of a token (NFT)', async () => {
652 await testReadsYetEmptyProperties({type: 'NFT'});684 await testReadsYetEmptyProperties({type: 'NFT'});
653 });685 });
654 it('Reads yet empty properties of a token (ReFungible)', async () => {686 it('Reads yet empty properties of a token (ReFungible)', async function() {
687 await requirePallets(this, [Pallets.ReFungible]);
688
655 await testReadsYetEmptyProperties({type: 'ReFungible'});689 await testReadsYetEmptyProperties({type: 'ReFungible'});
656 });690 });
696 it('Assigns properties to a token according to permissions (NFT)', async () => {730 it('Assigns properties to a token according to permissions (NFT)', async () => {
697 await testAssignPropertiesAccordingToPermissions({type: 'NFT'}, 1);731 await testAssignPropertiesAccordingToPermissions({type: 'NFT'}, 1);
698 });732 });
699 it('Assigns properties to a token according to permissions (ReFungible)', async () => {733 it('Assigns properties to a token according to permissions (ReFungible)', async function() {
734 await requirePallets(this, [Pallets.ReFungible]);
735
700 await testAssignPropertiesAccordingToPermissions({type: 'ReFungible'}, 100);736 await testAssignPropertiesAccordingToPermissions({type: 'ReFungible'}, 100);
701 });737 });
749 it('Changes properties of a token according to permissions (NFT)', async () => {785 it('Changes properties of a token according to permissions (NFT)', async () => {
750 await testChangesPropertiesAccordingPermission({type: 'NFT'}, 1);786 await testChangesPropertiesAccordingPermission({type: 'NFT'}, 1);
751 });787 });
752 it('Changes properties of a token according to permissions (ReFungible)', async () => {788 it('Changes properties of a token according to permissions (ReFungible)', async function() {
789 await requirePallets(this, [Pallets.ReFungible]);
790
753 await testChangesPropertiesAccordingPermission({type: 'ReFungible'}, 100);791 await testChangesPropertiesAccordingPermission({type: 'ReFungible'}, 100);
754 });792 });
802 it('Deletes properties of a token according to permissions (NFT)', async () => {840 it('Deletes properties of a token according to permissions (NFT)', async () => {
803 await testDeletePropertiesAccordingPermission({type: 'NFT'}, 1);841 await testDeletePropertiesAccordingPermission({type: 'NFT'}, 1);
804 });842 });
805 it('Deletes properties of a token according to permissions (ReFungible)', async () => {843 it('Deletes properties of a token according to permissions (ReFungible)', async function() {
844 await requirePallets(this, [Pallets.ReFungible]);
845
806 await testDeletePropertiesAccordingPermission({type: 'ReFungible'}, 100);846 await testDeletePropertiesAccordingPermission({type: 'ReFungible'}, 100);
807 });847 });
1029 it('Forbids changing/deleting properties of a token if the user is outside of permissions (NFT)', async () => {1069 it('Forbids changing/deleting properties of a token if the user is outside of permissions (NFT)', async () => {
1030 await testForbidsChangingDeletingPropertiesUserOutsideOfPermissions({type: 'NFT'}, 1);1070 await testForbidsChangingDeletingPropertiesUserOutsideOfPermissions({type: 'NFT'}, 1);
1031 });1071 });
1032 it('Forbids changing/deleting properties of a token if the user is outside of permissions (ReFungible)', async () => {1072 it('Forbids changing/deleting properties of a token if the user is outside of permissions (ReFungible)', async function() {
1073 await requirePallets(this, [Pallets.ReFungible]);
1074
1033 await testForbidsChangingDeletingPropertiesUserOutsideOfPermissions({type: 'ReFungible'}, 100);1075 await testForbidsChangingDeletingPropertiesUserOutsideOfPermissions({type: 'ReFungible'}, 100);
1034 });1076 });
1062 it('Forbids changing/deleting properties of a token if the property is permanent (immutable) (NFT)', async () => {1104 it('Forbids changing/deleting properties of a token if the property is permanent (immutable) (NFT)', async () => {
1063 await testForbidsChangingDeletingPropertiesIfPropertyImmutable({type: 'NFT'}, 1);1105 await testForbidsChangingDeletingPropertiesIfPropertyImmutable({type: 'NFT'}, 1);
1064 });1106 });
1065 it('Forbids changing/deleting properties of a token if the property is permanent (immutable) (ReFungible)', async () => {1107 it('Forbids changing/deleting properties of a token if the property is permanent (immutable) (ReFungible)', async function() {
1108 await requirePallets(this, [Pallets.ReFungible]);
1109
1066 await testForbidsChangingDeletingPropertiesIfPropertyImmutable({type: 'ReFungible'}, 100);1110 await testForbidsChangingDeletingPropertiesIfPropertyImmutable({type: 'ReFungible'}, 100);
1067 });1111 });
1096 it('Forbids adding properties to a token if the property is not declared / forbidden with the \'None\' permission (NFT)', async () => {1140 it('Forbids adding properties to a token if the property is not declared / forbidden with the \'None\' permission (NFT)', async () => {
1097 await testForbidsAddingPropertiesIfPropertyNotDeclared({type: 'NFT'}, 1);1141 await testForbidsAddingPropertiesIfPropertyNotDeclared({type: 'NFT'}, 1);
1098 });1142 });
1099 it('Forbids adding properties to a token if the property is not declared / forbidden with the \'None\' permission (ReFungible)', async () => {1143 it('Forbids adding properties to a token if the property is not declared / forbidden with the \'None\' permission (ReFungible)', async function() {
1144 await requirePallets(this, [Pallets.ReFungible]);
1145
1100 await testForbidsAddingPropertiesIfPropertyNotDeclared({type: 'ReFungible'}, 100);1146 await testForbidsAddingPropertiesIfPropertyNotDeclared({type: 'ReFungible'}, 100);
1101 });1147 });
1140 it('Forbids adding too many properties to a token (NFT)', async () => {1186 it('Forbids adding too many properties to a token (NFT)', async () => {
1141 await testForbidsAddingTooManyProperties({type: 'NFT'}, 1);1187 await testForbidsAddingTooManyProperties({type: 'NFT'}, 1);
1142 });1188 });
1143 it('Forbids adding too many properties to a token (ReFungible)', async () => {1189 it('Forbids adding too many properties to a token (ReFungible)', async function() {
1190 await requirePallets(this, [Pallets.ReFungible]);
1191
1144 await testForbidsAddingTooManyProperties({type: 'ReFungible'}, 100);1192 await testForbidsAddingTooManyProperties({type: 'ReFungible'}, 100);
1145 });1193 });
1149 let collection: number;1197 let collection: number;
1150 let token: number;1198 let token: number;
11511199
1152 before(async () => {1200 before(async function() {
1201 await requirePallets(this, [Pallets.ReFungible]);
1202
1153 await usingApi(async (api, privateKeyWrapper) => {1203 await usingApi(async (api, privateKeyWrapper) => {
1154 alice = privateKeyWrapper('//Alice');1204 alice = privateKeyWrapper('//Alice');
modifiedtests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {tokenIdToAddress} from '../eth/util/helpers';2import {tokenIdToAddress} from '../eth/util/helpers';
3import usingApi, {executeTransaction} from '../substrate/substrate-api';3import usingApi, {executeTransaction} from '../substrate/substrate-api';
4import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult} from '../util/helpers';4import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult, requirePallets, Pallets} from '../util/helpers';
5import {IKeyringPair} from '@polkadot/types/types';5import {IKeyringPair} from '@polkadot/types/types';
66
7describe('nesting check', () => {7describe('nesting check', () => {
47 });47 });
48 });48 });
4949
50 it('called for refungible', async () => {50 it('called for refungible', async function() {
51 await requirePallets(this, [Pallets.ReFungible]);
52
51 await usingApi(async api => {53 await usingApi(async api => {
52 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});54 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
modifiedtests/src/nesting/unnest.test.tsdiffbeforeafterboth
10 setCollectionPermissionsExpectSuccess,10 setCollectionPermissionsExpectSuccess,
11 transferExpectSuccess,11 transferExpectSuccess,
12 transferFromExpectSuccess,12 transferFromExpectSuccess,
13 requirePallets,
14 Pallets
13} from '../util/helpers';15} from '../util/helpers';
14import {IKeyringPair} from '@polkadot/types/types';16import {IKeyringPair} from '@polkadot/types/types';
1517
80 });82 });
81 });83 });
8284
83 it('ReFungible: allows the owner to successfully unnest a token', async () => {85 it('ReFungible: allows the owner to successfully unnest a token', async function() {
86 await requirePallets(this, [Pallets.ReFungible]);
87
84 await usingApi(async api => {88 await usingApi(async api => {
85 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});89 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
modifiedtests/src/nextSponsoring.test.tsdiffbeforeafterboth
27 transferExpectSuccess,27 transferExpectSuccess,
28 normalizeAccountId,28 normalizeAccountId,
29 getNextSponsored,29 getNextSponsored,
30 requirePallets,
31 Pallets
30} from './util/helpers';32} from './util/helpers';
3133
32chai.use(chaiAsPromised);34chai.use(chaiAsPromised);
89 });91 });
90 });92 });
9193
92 it('ReFungible', async () => {94 it('ReFungible', async function() {
95 await requirePallets(this, [Pallets.ReFungible]);
96
93 await usingApi(async (api: ApiPromise) => {97 await usingApi(async (api: ApiPromise) => {
9498
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
49 'inflation',49 'inflation',
50 'unique',50 'unique',
51 'nonfungible',51 'nonfungible',
52 'refungible',
53 'scheduler',
54 'charging',52 'charging',
55];53];
5654
66 await usingApi(async api => {64 await usingApi(async api => {
67 const chain = await api.rpc.system.chain();65 const chain = await api.rpc.system.chain();
66
67 const refungible = 'refungible';
68 const scheduler = 'scheduler';
69 const rmrkPallets = ['rmrkcore', 'rmrkequip'];
6870
69 if (!chain.eq('UNIQUE')) {71 if (chain.eq('OPAL by UNIQUE')) {
70 requiredPallets.push(...['rmrkcore', 'rmrkequip']);72 requiredPallets.push(refungible, scheduler, ...rmrkPallets);
71 }73 } else if (chain.eq('QUARTZ by UNIQUE')) {
74 // Insert Quartz additional pallets here
75 } else if (chain.eq('UNIQUE')) {
76 // Insert Unique additional pallets here
77 }
72 });78 });
73 });79 });
7480
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
38 getDestroyItemsResult,38 getDestroyItemsResult,
39 getModuleNames,39 getModuleNames,
40 Pallets,40 Pallets,
41 requirePallets
41} from './util/helpers';42} from './util/helpers';
4243
43import chai from 'chai';44import chai from 'chai';
5253
53describe('integration test: Refungible functionality:', async () => {54describe('integration test: Refungible functionality:', async () => {
54 before(async function() {55 before(async function() {
56 await requirePallets(this, [Pallets.ReFungible]);
57
55 await usingApi(async (api, privateKeyWrapper) => {58 await usingApi(async (api, privateKeyWrapper) => {
56 alice = privateKeyWrapper('//Alice');59 alice = privateKeyWrapper('//Alice');
modifiedtests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth
14 let api: any;14 let api: any;
15 before(async function() {15 before(async function() {
16 api = await getApiConnection();16 api = await getApiConnection();
17 requirePallets(this, api, [Pallets.RmrkCore]);17 await requirePallets(this, [Pallets.RmrkCore]);
18 });18 });
19 19
20 20
modifiedtests/src/rmrk/addResource.test.tsdiffbeforeafterboth
27 let api: any;27 let api: any;
28 before(async function() {28 before(async function() {
29 api = await getApiConnection();29 api = await getApiConnection();
30 requirePallets(this, api, [Pallets.RmrkCore]);30 await requirePallets(this, [Pallets.RmrkCore]);
31 });31 });
3232
33 it('add resource', async () => {33 it('add resource', async () => {
modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
9 let api: any;9 let api: any;
10 before(async function() {10 before(async function() {
11 api = await getApiConnection();11 api = await getApiConnection();
12 requirePallets(this, api, [Pallets.RmrkEquip]);12 await requirePallets(this, [Pallets.RmrkEquip]);
13 });13 });
1414
15 const alice = '//Alice';15 const alice = '//Alice';
modifiedtests/src/rmrk/burnNft.test.tsdiffbeforeafterboth
17 let api: any;17 let api: any;
18 before(async function() {18 before(async function() {
19 api = await getApiConnection();19 api = await getApiConnection();
20 requirePallets(this, api, [Pallets.RmrkCore]);20 await requirePallets(this, [Pallets.RmrkCore]);
21 });21 });
2222
2323
modifiedtests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth
13 let api: any;13 let api: any;
14 before(async function() {14 before(async function() {
15 api = await getApiConnection();15 api = await getApiConnection();
16 requirePallets(this, api, [Pallets.RmrkCore]);16 await requirePallets(this, [Pallets.RmrkCore]);
17 });17 });
1818
1919
modifiedtests/src/rmrk/createBase.test.tsdiffbeforeafterboth
6 let api: any;6 let api: any;
7 before(async function() {7 before(async function() {
8 api = await getApiConnection();8 api = await getApiConnection();
9 requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);9 await requirePallets(this, [Pallets.RmrkCore, Pallets.RmrkEquip]);
10 });10 });
1111
12 const alice = '//Alice';12 const alice = '//Alice';
modifiedtests/src/rmrk/createCollection.test.tsdiffbeforeafterboth
6 let api: any;6 let api: any;
7 before(async function () {7 before(async function () {
8 api = await getApiConnection();8 api = await getApiConnection();
9 requirePallets(this, api, [Pallets.RmrkCore]);9 await requirePallets(this, [Pallets.RmrkCore]);
10 });10 });
1111
1212
modifiedtests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 requirePallets(this, api, [Pallets.RmrkCore]);10 await requirePallets(this, [Pallets.RmrkCore]);
11 });11 });
1212
13 const Alice = '//Alice';13 const Alice = '//Alice';
modifiedtests/src/rmrk/equipNft.test.tsdiffbeforeafterboth
126 126
127 before(async function () {127 before(async function () {
128 api = await getApiConnection();128 api = await getApiConnection();
129 requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);129 await requirePallets(this, [Pallets.RmrkCore, Pallets.RmrkEquip]);
130 });130 });
131131
132 it('equip nft', async () => {132 it('equip nft', async () => {
modifiedtests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth
9 9
10 before(async function () {10 before(async function () {
11 api = await getApiConnection();11 api = await getApiConnection();
12 requirePallets(this, api, [Pallets.RmrkCore]);12 await requirePallets(this, [Pallets.RmrkCore]);
13 });13 });
1414
1515
modifiedtests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth
11 let api: any;11 let api: any;
12 before(async function () {12 before(async function () {
13 api = await getApiConnection();13 api = await getApiConnection();
14 requirePallets(this, api, [Pallets.RmrkCore]);14 await requirePallets(this, [Pallets.RmrkCore]);
15 });15 });
1616
17 it('lock collection', async () => {17 it('lock collection', async () => {
modifiedtests/src/rmrk/mintNft.test.tsdiffbeforeafterboth
10 10
11 before(async function () {11 before(async function () {
12 api = await getApiConnection();12 api = await getApiConnection();
13 requirePallets(this, api, [Pallets.RmrkCore]);13 await requirePallets(this, [Pallets.RmrkCore]);
14 });14 });
1515
1616
modifiedtests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth
14 let api: any;14 let api: any;
15 before(async function () {15 before(async function () {
16 api = await getApiConnection();16 api = await getApiConnection();
17 requirePallets(this, api, [Pallets.RmrkCore]);17 await requirePallets(this, [Pallets.RmrkCore]);
18 });18 });
1919
2020
modifiedtests/src/rmrk/removeResource.test.tsdiffbeforeafterboth
20 before(async function() {20 before(async function() {
21 api = await getApiConnection();21 api = await getApiConnection();
22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;
23 requirePallets(this, api, [Pallets.RmrkCore]);23 await requirePallets(this, [Pallets.RmrkCore]);
24 });24 });
2525
26 const Alice = '//Alice';26 const Alice = '//Alice';
modifiedtests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth
64 before(async function() {64 before(async function() {
65 await usingApi(async (api, privateKeyWrapper) => {65 await usingApi(async (api, privateKeyWrapper) => {
66 alice = privateKeyWrapper('//Alice');66 alice = privateKeyWrapper('//Alice');
67 requirePallets(this, api, [Pallets.RmrkCore]);67 await requirePallets(this, [Pallets.RmrkCore]);
68 });68 });
69 });69 });
7070
modifiedtests/src/rmrk/sendNft.test.tsdiffbeforeafterboth
9 let api: any;9 let api: any;
10 before(async function () {10 before(async function () {
11 api = await getApiConnection();11 api = await getApiConnection();
12 requirePallets(this, api, [Pallets.RmrkCore]);12 await requirePallets(this, [Pallets.RmrkCore]);
13 });13 });
1414
15 const maxNftId = 0xFFFFFFFF;15 const maxNftId = 0xFFFFFFFF;
modifiedtests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth
10 let api: any;10 let api: any;
11 before(async function () {11 before(async function () {
12 api = await getApiConnection();12 api = await getApiConnection();
13 requirePallets(this, api, [Pallets.RmrkCore]);13 await requirePallets(this, [Pallets.RmrkCore]);
14 });14 });
1515
16 it('set collection property', async () => {16 it('set collection property', async () => {
modifiedtests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 requirePallets(this, api, [Pallets.RmrkCore]);10 await requirePallets(this, [Pallets.RmrkCore]);
11 });11 });
1212
13 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth
8 let api: any;8 let api: any;
9 before(async function () {9 before(async function () {
10 api = await getApiConnection();10 api = await getApiConnection();
11 requirePallets(this, api, [Pallets.RmrkCore]);11 await requirePallets(this, [Pallets.RmrkCore]);
12 });12 });
1313
14 const alice = '//Alice';14 const alice = '//Alice';
modifiedtests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 requirePallets(this, api, [Pallets.RmrkCore]);10 await requirePallets(this, [Pallets.RmrkCore]);
11 });11 });
1212
13 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/setCollectionSponsor.test.tsdiffbeforeafterboth
23 setCollectionSponsorExpectFailure,23 setCollectionSponsorExpectFailure,
24 addCollectionAdminExpectSuccess,24 addCollectionAdminExpectSuccess,
25 getCreatedCollectionCount,25 getCreatedCollectionCount,
26 requirePallets,
27 Pallets
26} from './util/helpers';28} from './util/helpers';
27import {IKeyringPair} from '@polkadot/types/types';29import {IKeyringPair} from '@polkadot/types/types';
2830
50 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});52 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
51 await setCollectionSponsorExpectSuccess(collectionId, bob.address);53 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
52 });54 });
53 it('Set ReFungible collection sponsor', async () => {55 it('Set ReFungible collection sponsor', async function() {
56 await requirePallets(this, [Pallets.ReFungible]);
57
54 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});58 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
55 await setCollectionSponsorExpectSuccess(collectionId, bob.address);59 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
35 getBalance as getTokenBalance,35 getBalance as getTokenBalance,
36 transferFromExpectSuccess,36 transferFromExpectSuccess,
37 transferFromExpectFail,37 transferFromExpectFail,
38 requirePallets,
39 Pallets,
38} from './util/helpers';40} from './util/helpers';
39import {41import {
40 subToEth,42 subToEth,
41 itWeb3, 43 itWeb3,
42} from './eth/util/helpers';44} from './eth/util/helpers';
45import { request } from 'https';
4346
44let alice: IKeyringPair;47let alice: IKeyringPair;
45let bob: IKeyringPair;48let bob: IKeyringPair;
89 });92 });
90 });93 });
94
95 it('[nft] User can transfer owned token', async () => {
96 const nftCollectionId = await createCollectionExpectSuccess();
97 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
98 await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 1, 'NFT');
99 });
91100
92 it('User can transfer owned token', async () => {101 it('[fungible] User can transfer owned token', async () => {
93 await usingApi(async (api, privateKeyWrapper) => {
94 // nft
95 const nftCollectionId = await createCollectionExpectSuccess();
96 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
97 await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 1, 'NFT');
98 // fungible
99 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});102 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
100 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');103 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
101 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob, 1, 'Fungible');104 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob, 1, 'Fungible');
102 // reFungible
103 const reFungibleCollectionId = await
104 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
105 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
106 await transferExpectSuccess(
107 reFungibleCollectionId,
108 newReFungibleTokenId,
109 alice,
110 bob,
111 100,
112 'ReFungible',
113 );
114 });
115 });105 });
106
107 it('[refungible] User can transfer owned token', async function() {
108 await requirePallets(this, [Pallets.ReFungible]);
109
110 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
111 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
112 await transferExpectSuccess(
113 reFungibleCollectionId,
114 newReFungibleTokenId,
115 alice,
116 bob,
117 100,
118 'ReFungible',
119 );
120 });
121
122 it('[nft] Collection admin can transfer owned token', async () => {
123 const nftCollectionId = await createCollectionExpectSuccess();
124 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
125 const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT', bob.address);
126 await transferExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, 1, 'NFT');
127 });
116128
117 it('Collection admin can transfer owned token', async () => {129 it('[fungible] Collection admin can transfer owned token', async () => {
118 await usingApi(async (api, privateKeyWrapper) => {
119 // nft
120 const nftCollectionId = await createCollectionExpectSuccess();
121 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
122 const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT', bob.address);
123 await transferExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, 1, 'NFT');
124 // fungible
125 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});130 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
126 await addCollectionAdminExpectSuccess(alice, fungibleCollectionId, bob.address);131 await addCollectionAdminExpectSuccess(alice, fungibleCollectionId, bob.address);
127 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible', bob.address);132 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible', bob.address);
128 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, 1, 'Fungible');133 await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, 1, 'Fungible');
129 // reFungible
130 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
131 await addCollectionAdminExpectSuccess(alice, reFungibleCollectionId, bob.address);
132 const newReFungibleTokenId = await createItemExpectSuccess(bob, reFungibleCollectionId, 'ReFungible', bob.address);
133 await transferExpectSuccess(
134 reFungibleCollectionId,
135 newReFungibleTokenId,
136 bob,
137 alice,
138 100,
139 'ReFungible',
140 );
141 });
142 });134 });
135
136 it('[refungible] Collection admin can transfer owned token', async function() {
137 await requirePallets(this, [Pallets.ReFungible]);
138
139 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
140 await addCollectionAdminExpectSuccess(alice, reFungibleCollectionId, bob.address);
141 const newReFungibleTokenId = await createItemExpectSuccess(bob, reFungibleCollectionId, 'ReFungible', bob.address);
142 await transferExpectSuccess(
143 reFungibleCollectionId,
144 newReFungibleTokenId,
145 bob,
146 alice,
147 100,
148 'ReFungible',
149 );
150 });
143});151});
144152
145describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {153describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
151 });159 });
152 });160 });
161
153 it('Transfer with not existed collection_id', async () => {162 it('[nft] Transfer with not existed collection_id', async () => {
154 await usingApi(async (api) => {163 await usingApi(async (api) => {
155 // nft
156 const nftCollectionCount = await getCreatedCollectionCount(api);164 const nftCollectionCount = await getCreatedCollectionCount(api);
157 await transferExpectFailure(nftCollectionCount + 1, 1, alice, bob, 1);165 await transferExpectFailure(nftCollectionCount + 1, 1, alice, bob, 1);
158 // fungible
159 const fungibleCollectionCount = await getCreatedCollectionCount(api);
160 await transferExpectFailure(fungibleCollectionCount + 1, 0, alice, bob, 1);
161 // reFungible
162 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
163 await transferExpectFailure(reFungibleCollectionCount + 1, 1, alice, bob, 1);
164 });166 });
165 });167 });
166 it('Transfer with deleted collection_id', async () => {168
167 // nft169 it('[fungible] Transfer with not existed collection_id', async () => {
170 await usingApi(async (api) => {
171 const fungibleCollectionCount = await getCreatedCollectionCount(api);
172 await transferExpectFailure(fungibleCollectionCount + 1, 0, alice, bob, 1);
173 });
174 });
175
176 it('[refungible] Transfer with not existed collection_id', async function() {
177 await requirePallets(this, [Pallets.ReFungible]);
178
179 await usingApi(async (api) => {
180 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
181 await transferExpectFailure(reFungibleCollectionCount + 1, 1, alice, bob, 1);
182 });
168 const nftCollectionId = await createCollectionExpectSuccess();183 });
169 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');184
170 await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId);185 it('[nft] Transfer with deleted collection_id', async () => {
171 await destroyCollectionExpectSuccess(nftCollectionId);186 const nftCollectionId = await createCollectionExpectSuccess();
172 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);187 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
173 // fungible188 await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId);
189 await destroyCollectionExpectSuccess(nftCollectionId);
190 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
191 });
192
193 it('[fungible] Transfer with deleted collection_id', async () => {
174 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});194 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
175 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');195 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
176 await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);196 await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
177 await destroyCollectionExpectSuccess(fungibleCollectionId);197 await destroyCollectionExpectSuccess(fungibleCollectionId);
178 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);198 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
179 // reFungible199 });
200
201 it('[refungible] Transfer with deleted collection_id', async function() {
202 await requirePallets(this, [Pallets.ReFungible]);
203
180 const reFungibleCollectionId = await204 const reFungibleCollectionId = await
181 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});205 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
189 bob,213 bob,
190 1,214 1,
191 );215 );
192 });216 });
217
218 it('[nft] Transfer with not existed item_id', async () => {
219 const nftCollectionId = await createCollectionExpectSuccess();
220 await transferExpectFailure(nftCollectionId, 2, alice, bob, 1);
221 });
222
223 it('[fungible] Transfer with not existed item_id', async () => {
224 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
225 await transferExpectFailure(fungibleCollectionId, 2, alice, bob, 1);
226 });
227
228 it('[refungible] Transfer with not existed item_id', async function() {
229 await requirePallets(this, [Pallets.ReFungible]);
230
231 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
232 await transferExpectFailure(
233 reFungibleCollectionId,
234 2,
235 alice,
236 bob,
237 1,
238 );
239 });
240
241 it('[nft] Transfer with deleted item_id', async () => {
242 const nftCollectionId = await createCollectionExpectSuccess();
243 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
244 await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
245 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
246 });
247
193 it('Transfer with not existed item_id', async () => {248 it('[fungible] Transfer with deleted item_id', async () => {
194 // nft
195 const nftCollectionId = await createCollectionExpectSuccess();
196 await transferExpectFailure(nftCollectionId, 2, alice, bob, 1);
197 // fungible
198 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});249 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
199 await transferExpectFailure(fungibleCollectionId, 2, alice, bob, 1);250 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
200 // reFungible
201 const reFungibleCollectionId = await251 await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
202 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
203 await transferExpectFailure(252 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
204 reFungibleCollectionId,
205 2,
206 alice,
207 bob,
208 1,
209 );
210 });253 });
254
211 it('Transfer with deleted item_id', async () => {255 it('[refungible] Transfer with deleted item_id', async function() {
212 // nft
213 const nftCollectionId = await createCollectionExpectSuccess();
214 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
215 await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
216 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
217 // fungible
218 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});256 await requirePallets(this, [Pallets.ReFungible]);
219 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');257
220 await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
221 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
222 // reFungible
223 const reFungibleCollectionId = await258 const reFungibleCollectionId = await
224 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});259 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
225 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');260 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
233 );268 );
234 });269 });
270
271 it('[nft] Transfer with recipient that is not owner', async () => {
272 const nftCollectionId = await createCollectionExpectSuccess();
273 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
274 await transferExpectFailure(nftCollectionId, newNftTokenId, charlie, bob, 1);
275 });
276
277 it('[fungible] Transfer with recipient that is not owner', async () => {
278 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
279 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
280 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, charlie, bob, 1);
281 });
282
235 it('Transfer with recipient that is not owner', async () => {283 it('[refungible] Transfer with recipient that is not owner', async function() {
236 // nft
237 const nftCollectionId = await createCollectionExpectSuccess();
238 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
239 await transferExpectFailure(nftCollectionId, newNftTokenId, charlie, bob, 1);
240 // fungible
241 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});284 await requirePallets(this, [Pallets.ReFungible]);
242 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');285
243 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, charlie, bob, 1);
244 // reFungible
245 const reFungibleCollectionId = await286 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
246 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
247 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');287 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
276 });316 });
277 });317 });
278318
279 it('RFT', async () => {319 it('RFT', async function() {
320 await requirePallets(this, [Pallets.ReFungible]);
321
280 await usingApi(async (api: ApiPromise) => {322 await usingApi(async (api: ApiPromise) => {
281 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});323 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
31 burnItemExpectSuccess,31 burnItemExpectSuccess,
32 setCollectionLimitsExpectSuccess,32 setCollectionLimitsExpectSuccess,
33 getCreatedCollectionCount,33 getCreatedCollectionCount,
34 requirePallets,
35 Pallets
34} from './util/helpers';36} from './util/helpers';
3537
36chai.use(chaiAsPromised);38chai.use(chaiAsPromised);
49 });51 });
50 });52 });
53
54 it('[nft] Execute the extrinsic and check nftItemList - owner of token', async () => {
55 const nftCollectionId = await createCollectionExpectSuccess();
56 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
57 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
58
59 await transferFromExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, charlie, 1, 'NFT');
60 });
5161
52 it('Execute the extrinsic and check nftItemList - owner of token', async () => {62 it('[fungible] Execute the extrinsic and check nftItemList - owner of token', async () => {
53 await usingApi(async () => {
54 // nft
55 const nftCollectionId = await createCollectionExpectSuccess();
56 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
57 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
58
59 await transferFromExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, charlie, 1, 'NFT');
60
61 // fungible
62 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});63 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
63 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');64 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
64 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);65 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
65 await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1, 'Fungible');66 await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1, 'Fungible');
66
67 // reFungible
68 const reFungibleCollectionId = await
69 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
70 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
71 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 100);
72 await transferFromExpectSuccess(
73 reFungibleCollectionId,
74 newReFungibleTokenId,
75 bob,
76 alice,
77 charlie,
78 100,
79 'ReFungible',
80 );
81 });
82 });67 });
68
69 it('[refungible] Execute the extrinsic and check nftItemList - owner of token', async function() {
70 await requirePallets(this, [Pallets.ReFungible]);
71
72 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
73 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
74 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 100);
75 await transferFromExpectSuccess(
76 reFungibleCollectionId,
77 newReFungibleTokenId,
78 bob,
79 alice,
80 charlie,
81 100,
82 'ReFungible',
83 );
84 });
8385
84 it('Should reduce allowance if value is big', async () => {86 it('Should reduce allowance if value is big', async () => {
85 await usingApi(async (api, privateKeyWrapper) => {87 await usingApi(async (api, privateKeyWrapper) => {
119 });121 });
120 });122 });
121123
122 it('transferFrom for a collection that does not exist', async () => {124 it('[nft] transferFrom for a collection that does not exist', async () => {
123 await usingApi(async (api: ApiPromise) => {125 await usingApi(async (api: ApiPromise) => {
124 // nft
125 const nftCollectionCount = await getCreatedCollectionCount(api);126 const nftCollectionCount = await getCreatedCollectionCount(api);
126 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);127 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
127128
128 await transferFromExpectFail(nftCollectionCount + 1, 1, bob, alice, charlie, 1);129 await transferFromExpectFail(nftCollectionCount + 1, 1, bob, alice, charlie, 1);
129
130 // fungible
131 const fungibleCollectionCount = await getCreatedCollectionCount(api);
132 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
133
134 await transferFromExpectFail(fungibleCollectionCount + 1, 0, bob, alice, charlie, 1);
135 // reFungible
136 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
137 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
138
139 await transferFromExpectFail(reFungibleCollectionCount + 1, 1, bob, alice, charlie, 1);
140 });130 });
141 });131 });
132
133 it('[fungible] transferFrom for a collection that does not exist', async () => {
134 await usingApi(async (api: ApiPromise) => {
135 const fungibleCollectionCount = await getCreatedCollectionCount(api);
136 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
137
138 await transferFromExpectFail(fungibleCollectionCount + 1, 0, bob, alice, charlie, 1);
139 });
140 });
141
142 it('[refungible] transferFrom for a collection that does not exist', async function() {
143 await requirePallets(this, [Pallets.ReFungible]);
144
145 await usingApi(async (api: ApiPromise) => {
146 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
147 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
148
149 await transferFromExpectFail(reFungibleCollectionCount + 1, 1, bob, alice, charlie, 1);
150 });
151 });
142152
143 /* it('transferFrom for a collection that was destroyed', async () => {153 /* it('transferFrom for a collection that was destroyed', async () => {
144 await usingApi(async (api: ApiPromise) => {154 await usingApi(async (api: ApiPromise) => {
158 });168 });
159 }); */169 }); */
170
171 it('[nft] transferFrom for not approved address', async () => {
172 const nftCollectionId = await createCollectionExpectSuccess();
173 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
174
175 await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 1);
176 });
160177
161 it('transferFrom for not approved address', async () => {178 it('[fungible] transferFrom for not approved address', async () => {
162 await usingApi(async () => {
163 // nft
164 const nftCollectionId = await createCollectionExpectSuccess();
165 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
166
167 await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 1);
168
169 // fungible
170 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});179 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
171 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');180 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
172 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1);181 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1);
173 // reFungible
174 const reFungibleCollectionId = await
175 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
176 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
177 await transferFromExpectFail(
178 reFungibleCollectionId,
179 newReFungibleTokenId,
180 bob,
181 alice,
182 charlie,
183 1,
184 );
185 });
186 });182 });
183
184 it('[refungible] transferFrom for not approved address', async function() {
185 await requirePallets(this, [Pallets.ReFungible]);
186
187 const reFungibleCollectionId = await
188 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
189 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
190 await transferFromExpectFail(
191 reFungibleCollectionId,
192 newReFungibleTokenId,
193 bob,
194 alice,
195 charlie,
196 1,
197 );
198 });
199
200 it('[nft] transferFrom incorrect token count', async () => {
201 const nftCollectionId = await createCollectionExpectSuccess();
202 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
203 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
204
205 await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 2);
206 });
187207
188 it('transferFrom incorrect token count', async () => {208 it('[fungible] transferFrom incorrect token count', async () => {
189 await usingApi(async () => {
190 // nft
191 const nftCollectionId = await createCollectionExpectSuccess();
192 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
193 await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
194
195 await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 2);
196
197 // fungible
198 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});209 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
199 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');210 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
200 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);211 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
201 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 2);212 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 2);
202 // reFungible
203 const reFungibleCollectionId = await
204 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
205 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
206 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
207 await transferFromExpectFail(
208 reFungibleCollectionId,
209 newReFungibleTokenId,
210 bob,
211 alice,
212 charlie,
213 2,
214 );
215 });
216 });213 });
214
215 it('[refungible] transferFrom incorrect token count', async function() {
216 await requirePallets(this, [Pallets.ReFungible]);
217
218 const reFungibleCollectionId = await
219 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
220 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
221 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
222 await transferFromExpectFail(
223 reFungibleCollectionId,
224 newReFungibleTokenId,
225 bob,
226 alice,
227 charlie,
228 2,
229 );
230 });
231
232 it('[nft] execute transferFrom from account that is not owner of collection', async () => {
233 await usingApi(async (api, privateKeyWrapper) => {
234 const dave = privateKeyWrapper('//Dave');
235 const nftCollectionId = await createCollectionExpectSuccess();
236 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
237 try {
238 await approveExpectFail(nftCollectionId, newNftTokenId, dave, bob);
239 await transferFromExpectFail(nftCollectionId, newNftTokenId, dave, alice, charlie, 1);
240 } catch (e) {
241 // tslint:disable-next-line:no-unused-expression
242 expect(e).to.be.exist;
243 }
244
245 // await transferFromExpectFail(nftCollectionId, newNftTokenId, Dave, Alice, Charlie, 1);
246 });
247 });
217248
218 it('execute transferFrom from account that is not owner of collection', async () => {249 it('[fungible] execute transferFrom from account that is not owner of collection', async () => {
219 await usingApi(async (api, privateKeyWrapper) => {250 await usingApi(async (api, privateKeyWrapper) => {
220 const dave = privateKeyWrapper('//Dave');251 const dave = privateKeyWrapper('//Dave');
221 // nft252
222 const nftCollectionId = await createCollectionExpectSuccess();
223 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
224 try {
225 await approveExpectFail(nftCollectionId, newNftTokenId, dave, bob);
226 await transferFromExpectFail(nftCollectionId, newNftTokenId, dave, alice, charlie, 1);
227 } catch (e) {
228 // tslint:disable-next-line:no-unused-expression
229 expect(e).to.be.exist;
230 }
231
232 // await transferFromExpectFail(nftCollectionId, newNftTokenId, Dave, Alice, Charlie, 1);
233
234 // fungible
235 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});253 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
236 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');254 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
237 try {255 try {
241 // tslint:disable-next-line:no-unused-expression259 // tslint:disable-next-line:no-unused-expression
242 expect(e).to.be.exist;260 expect(e).to.be.exist;
243 }261 }
244 // reFungible
245 const reFungibleCollectionId = await
246 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
247 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
248 try {
249 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, bob);
250 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, alice, charlie, 1);
251 } catch (e) {
252 // tslint:disable-next-line:no-unused-expression
253 expect(e).to.be.exist;
254 }
255 });262 });
256 });263 });
264
265 it('[refungible] execute transferFrom from account that is not owner of collection', async function() {
266 await requirePallets(this, [Pallets.ReFungible]);
267
268 await usingApi(async (api, privateKeyWrapper) => {
269 const dave = privateKeyWrapper('//Dave');
270 const reFungibleCollectionId = await
271 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
272 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
273 try {
274 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, bob);
275 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, alice, charlie, 1);
276 } catch (e) {
277 // tslint:disable-next-line:no-unused-expression
278 expect(e).to.be.exist;
279 }
280 });
281 });
257 it('transferFrom burnt token before approve NFT', async () => {282 it('transferFrom burnt token before approve NFT', async () => {
258 await usingApi(async () => {283 await usingApi(async () => {
259 // nft284 // nft
276301
277 });302 });
278 });303 });
279 it('transferFrom burnt token before approve ReFungible', async () => {304 it('transferFrom burnt token before approve ReFungible', async function() {
305 await requirePallets(this, [Pallets.ReFungible]);
306
280 await usingApi(async () => {307 await usingApi(async () => {
281 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});308 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
308335
309 });336 });
310 });337 });
311 it('transferFrom burnt token after approve ReFungible', async () => {338 it('transferFrom burnt token after approve ReFungible', async function() {
339 await requirePallets(this, [Pallets.ReFungible]);
340
312 await usingApi(async () => {341 await usingApi(async () => {
313 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});342 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});