git.delta.rocks / unique-network / refs/commits / 764dfd599fff

difftreelog

Quick fix for nesting tests

Andrey Kuznetsov2022-05-29parent: #e4d7343.patch.diff
in: master

5 files changed

modifiedtests/src/nesting/graphs.test.tsdiffbeforeafterboth
14 * ```14 * ```
15 */15 */
16async function buildComplexObjectGraph(api: ApiPromise, sender: IKeyringPair): Promise<number> {16async function buildComplexObjectGraph(api: ApiPromise, sender: IKeyringPair): Promise<number> {
17 const events = await executeTransaction(api, sender, api.tx.unique.createCollectionEx({mode: 'NFT', limits: {nestingRule: 'Owner'}}));17 const events = await executeTransaction(api, sender, api.tx.unique.createCollectionEx({mode: 'NFT', permissions: {nesting: 'Owner'}}));
18 const {collectionId} = getCreateCollectionResult(events);18 const {collectionId} = getCreateCollectionResult(events);
1919
20 await executeTransaction(api, sender, api.tx.unique.createMultipleItemsEx(collectionId, {NFT: Array(8).fill({owner: {Substrate: sender.address}})}));20 await executeTransaction(api, sender, api.tx.unique.createMultipleItemsEx(collectionId, {NFT: Array(8).fill({owner: {Substrate: sender.address}})}));
modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
10 enablePublicMintingExpectSuccess,10 enablePublicMintingExpectSuccess,
11 getTokenOwner, 11 getTokenOwner,
12 getTopmostTokenOwner,12 getTopmostTokenOwner,
13 setCollectionLimitsExpectSuccess, 13 setCollectionPermissionsExceptSuccess,
14 transferExpectFailure, 14 transferExpectFailure,
15 transferExpectSuccess, 15 transferExpectSuccess,
16 transferFromExpectSuccess,16 transferFromExpectSuccess,
31 it('Performs the full suite: bundles a token, transfers, and allows to unnest', async () => {31 it('Performs the full suite: bundles a token, transfers, and allows to unnest', async () => {
32 await usingApi(async api => {32 await usingApi(async api => {
33 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});33 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
34 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});34 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
35 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');35 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
3636
37 // Create a nested token37 // Create a nested token
63 it('NFT: allows an Owner to nest/unnest their token', async () => {63 it('NFT: allows an Owner to nest/unnest their token', async () => {
64 await usingApi(async api => {64 await usingApi(async api => {
65 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});65 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
66 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});66 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
67 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');67 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
6868
69 // Create a nested token69 // Create a nested token
82 it('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {82 it('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {
83 await usingApi(async api => {83 await usingApi(async api => {
84 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});84 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
85 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});85 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
86 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');86 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
8787
88 // Create a nested token88 // Create a nested token
103 it('Fungible: allows an Owner to nest/unnest their token', async () => {103 it('Fungible: allows an Owner to nest/unnest their token', async () => {
104 await usingApi(async api => {104 await usingApi(async api => {
105 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});105 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
106 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});106 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
107 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});107 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});
108 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};108 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
109109
130130
131 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});131 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
132132
133 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});133 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}});
134134
135 // Create a nested token135 // Create a nested token
136 await expect(executeTransaction(api, alice, api.tx.unique.createItem(136 await expect(executeTransaction(api, alice, api.tx.unique.createItem(
150 it('ReFungible: allows an Owner to nest/unnest their token', async () => {150 it('ReFungible: allows an Owner to nest/unnest their token', async () => {
151 await usingApi(async api => {151 await usingApi(async api => {
152 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});152 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
153 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});153 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
154 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});154 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});
155 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};155 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
156156
177177
178 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});178 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
179179
180 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});180 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
181181
182 // Create a nested token182 // Create a nested token
183 await expect(executeTransaction(api, alice, api.tx.unique.createItem(183 await expect(executeTransaction(api, alice, api.tx.unique.createItem(
204 it('Disallows excessive token nesting', async () => {204 it('Disallows excessive token nesting', async () => {
205 await usingApi(async api => {205 await usingApi(async api => {
206 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});206 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
207 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});207 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
208 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');208 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
209209
210 // Create a nested-token matryoshka210 // Create a nested-token matryoshka
226 it('NFT: disallows to nest token if nesting is disabled', async () => {226 it('NFT: disallows to nest token if nesting is disabled', async () => {
227 await usingApi(async api => {227 await usingApi(async api => {
228 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});228 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
229 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Disabled'});229 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Disabled'});
230 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');230 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
231231
232 // Try to create a nested token232 // Try to create a nested token
248 it('NFT: disallows a non-Owner to nest someone else\'s token', async () => {248 it('NFT: disallows a non-Owner to nest someone else\'s token', async () => {
249 await usingApi(async api => {249 await usingApi(async api => {
250 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});250 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
251 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});251 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
252252
253 await addToAllowListExpectSuccess(alice, collection, bob.address);253 await addToAllowListExpectSuccess(alice, collection, bob.address);
254 await enableAllowListExpectSuccess(alice, collection);254 await enableAllowListExpectSuccess(alice, collection);
274 it('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {274 it('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {
275 await usingApi(async api => {275 await usingApi(async api => {
276 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});276 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
277 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});277 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
278278
279 await addToAllowListExpectSuccess(alice, collection, bob.address);279 await addToAllowListExpectSuccess(alice, collection, bob.address);
280 await enableAllowListExpectSuccess(alice, collection);280 await enableAllowListExpectSuccess(alice, collection);
300 it('NFT: disallows to nest token in an unlisted collection', async () => {300 it('NFT: disallows to nest token in an unlisted collection', async () => {
301 await usingApi(async api => {301 await usingApi(async api => {
302 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});302 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
303 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[]}});303 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[]}});
304304
305 // Create a token to attempt to be nested into305 // Create a token to attempt to be nested into
306 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');306 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
324 it('Fungible: disallows to nest token if nesting is disabled', async () => {324 it('Fungible: disallows to nest token if nesting is disabled', async () => {
325 await usingApi(async api => {325 await usingApi(async api => {
326 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});326 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
327 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});327 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'});
328 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');328 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
329 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};329 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
330330
352 it('Fungible: disallows a non-Owner to nest someone else\'s token', async () => {352 it('Fungible: disallows a non-Owner to nest someone else\'s token', async () => {
353 await usingApi(async api => {353 await usingApi(async api => {
354 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});354 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
355 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});355 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
356356
357 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);357 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);
358 await enableAllowListExpectSuccess(alice, collectionNFT);358 await enableAllowListExpectSuccess(alice, collectionNFT);
389 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};389 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
390390
391 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});391 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
392 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});392 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionFT]}});
393393
394 // Try to create a nested token in the wrong collection394 // Try to create a nested token in the wrong collection
395 await expect(executeTransaction(api, alice, api.tx.unique.createItem(395 await expect(executeTransaction(api, alice, api.tx.unique.createItem(
407 it('Fungible: disallows to nest token in an unlisted collection', async () => {407 it('Fungible: disallows to nest token in an unlisted collection', async () => {
408 await usingApi(async api => {408 await usingApi(async api => {
409 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});409 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
410 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});410 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
411411
412 // Create a token to attempt to be nested into412 // Create a token to attempt to be nested into
413 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');413 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
433 it('ReFungible: disallows to nest token if nesting is disabled', async () => {433 it('ReFungible: disallows to nest token if nesting is disabled', async () => {
434 await usingApi(async api => {434 await usingApi(async api => {
435 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});435 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
436 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});436 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'});
437 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');437 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
438 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};438 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
439439
463 it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => {463 it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => {
464 await usingApi(async api => {464 await usingApi(async api => {
465 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});465 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
466 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});466 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
467467
468 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);468 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);
469 await enableAllowListExpectSuccess(alice, collectionNFT);469 await enableAllowListExpectSuccess(alice, collectionNFT);
500 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};500 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
501501
502 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});502 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
503 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});503 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
504504
505 // Try to create a nested token in the wrong collection505 // Try to create a nested token in the wrong collection
506 await expect(executeTransaction(api, alice, api.tx.unique.createItem(506 await expect(executeTransaction(api, alice, api.tx.unique.createItem(
518 it('ReFungible: disallows to nest token to an unlisted collection', async () => {518 it('ReFungible: disallows to nest token to an unlisted collection', async () => {
519 await usingApi(async api => {519 await usingApi(async api => {
520 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});520 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
521 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});521 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
522522
523 // Create a token to attempt to be nested into523 // Create a token to attempt to be nested into
524 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');524 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
modifiedtests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth
14 const bob = privateKey('//Bob');14 const bob = privateKey('//Bob');
15 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({15 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({
16 mode: 'NFT',16 mode: 'NFT',
17 limits: {17 permissions: {
18 nestingRule: {OwnerRestricted: []},18 nesting: {OwnerRestricted: []},
19 },19 },
20 }));20 }));
21 const collection = getCreateCollectionResult(events).collectionId;21 const collection = getCreateCollectionResult(events).collectionId;
39 it('called for nonfungible', async () => {39 it('called for nonfungible', async () => {
40 await usingApi(async api => {40 await usingApi(async api => {
41 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});41 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
42 await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {NFT: {ConstData: []}})))42 await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {NFT: {properties: []}})))
43 .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);43 .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);
4444
45 const token = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});45 const token = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
51 it('called for refungible', async () => {51 it('called for refungible', async () => {
52 await usingApi(async api => {52 await usingApi(async api => {
53 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});53 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
54 await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {ReFungible: {ConstData: []}})))54 await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {ReFungible: {}})))
55 .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);55 .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);
5656
57 const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address});57 const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address});
modifiedtests/src/nesting/unnest.test.tsdiffbeforeafterboth
8 getBalance,8 getBalance,
9 getTokenOwner,9 getTokenOwner,
10 normalizeAccountId,10 normalizeAccountId,
11 setCollectionLimitsExpectSuccess,11 setCollectionPermissionsExceptSuccess,
12 transferExpectSuccess,12 transferExpectSuccess,
13 transferFromExpectSuccess,13 transferFromExpectSuccess,
14} from '../util/helpers';14} from '../util/helpers';
28 it('NFT: allows the owner to successfully unnest a token', async () => {28 it('NFT: allows the owner to successfully unnest a token', async () => {
29 await usingApi(async api => {29 await usingApi(async api => {
30 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});30 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
31 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});31 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
32 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');32 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
33 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};33 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
3434
57 it('Fungible: allows the owner to successfully unnest a token', async () => {57 it('Fungible: allows the owner to successfully unnest a token', async () => {
58 await usingApi(async api => {58 await usingApi(async api => {
59 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});59 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
60 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});60 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
61 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');61 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
62 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};62 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
6363
84 it('ReFungible: allows the owner to successfully unnest a token', async () => {84 it('ReFungible: allows the owner to successfully unnest a token', async () => {
85 await usingApi(async api => {85 await usingApi(async api => {
86 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});86 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
87 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});87 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
88 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');88 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
89 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};89 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
9090
119 it('Disallows a non-owner to unnest/burn a token', async () => {119 it('Disallows a non-owner to unnest/burn a token', async () => {
120 await usingApi(async api => {120 await usingApi(async api => {
121 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});121 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
122 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});122 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
123 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');123 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
124 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};124 const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
125125
149 // Recursive nesting149 // Recursive nesting
150 it('Prevents Ouroboros creation', async () => {150 it('Prevents Ouroboros creation', async () => {
151 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});151 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
152 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});152 await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
153 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');153 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
154154
155 // Create a nested token ouroboros155 // Create a nested token ouroboros
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
325};325};
326326
327export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {327export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {
328 const {name, description, mode, tokenPrefix, schemaVersion} = {...defaultCreateCollectionParams, ...params};328 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
329329
330 let collectionId = 0;330 let collectionId = 0;
331 await usingApi(async (api) => {331 await usingApi(async (api) => {
348 name: strToUTF16(name),348 name: strToUTF16(name),
349 description: strToUTF16(description),349 description: strToUTF16(description),
350 tokenPrefix: strToUTF16(tokenPrefix),350 tokenPrefix: strToUTF16(tokenPrefix),
351 mode: modeprm as any,351 mode: modeprm as any
352 schemaVersion: schemaVersion,
353 });352 });
354 const events = await submitTransactionAsync(alicePrivateKey, tx);353 const events = await submitTransactionAsync(alicePrivateKey, tx);
355 const result = getCreateCollectionResult(events);354 const result = getCreateCollectionResult(events);
555 });554 });
556}555}
556
557export const setCollectionPermissionsExceptSuccess = async (sender: IKeyringPair, collectionId: number, permissions: {mintMode?: boolean, access?: 'Normal' | 'AllowList', nesting?: 'Disabled' | 'Owner' | {OwnerRestricted: number[]}}) => {
558 await usingApi(async(api) => {
559 const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);
560 const events = await submitTransactionAsync(sender, tx);
561 const result = getGenericResult(events);
562
563 expect(result.success).to.be.true;
564 });
565}
557566
558export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {567export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
559 await usingApi(async (api) => {568 await usingApi(async (api) => {
1299 // What to expect1308 // What to expect
1300 // tslint:disable-next-line:no-unused-expression1309 // tslint:disable-next-line:no-unused-expression
1301 expect(result.success).to.be.true;1310 expect(result.success).to.be.true;
1302 expect(collection.access.toHuman()).to.be.equal(accessMode);1311 expect(collection.permissions.access.toHuman()).to.be.equal(accessMode);
1303 });1312 });
1304}1313}
13051314
1344 // Get the collection1353 // Get the collection
1345 const collection = await queryCollectionExpectSuccess(api, collectionId);1354 const collection = await queryCollectionExpectSuccess(api, collectionId);
13461355
1347 expect(collection.mintMode.toHuman()).to.be.equal(enabled);1356 expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);
1348 });1357 });
1349}1358}
13501359