difftreelog
Quick fix for nesting tests
in: master
5 files changed
tests/src/nesting/graphs.test.tsdiffbeforeafterboth14 * ```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);191920 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}})}));tests/src/nesting/nest.test.tsdiffbeforeafterboth10 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');363637 // Create a nested token37 // Create a nested token63 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');686869 // Create a nested token69 // Create a nested token82 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');878788 // Create a nested token88 // Create a nested token103 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)};109109130130131 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});131 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});132132133 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});133 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}});134134135 // Create a nested token135 // Create a nested token136 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)};156156177177178 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});178 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});179179180 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});180 await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});181181182 // Create a nested token182 // Create a nested token183 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');209209210 // Create a nested-token matryoshka210 // Create a nested-token matryoshka226 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');231231232 // Try to create a nested token232 // Try to create a nested token248 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'});252252253 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]}});278278279 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:[]}});304304305 // Create a token to attempt to be nested into305 // Create a token to attempt to be nested into306 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)};330330352 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'});356356357 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)};390390391 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]}});393393394 // Try to create a nested token in the wrong collection394 // Try to create a nested token in the wrong collection395 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:[]}});411411412 // Create a token to attempt to be nested into412 // Create a token to attempt to be nested into413 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)};439439463 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'});467467468 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)};501501502 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]}});504504505 // Try to create a nested token in the wrong collection505 // Try to create a nested token in the wrong collection506 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:[]}});522522523 // Create a token to attempt to be nested into523 // Create a token to attempt to be nested into524 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');524 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');tests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth14 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$/);444445 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$/);565657 const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address});57 const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address});tests/src/nesting/unnest.test.tsdiffbeforeafterboth8 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)};343457 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)};636384 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)};9090119 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)};125125149 // Recursive nesting149 // Recursive nesting150 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');154154155 // Create a nested token ouroboros155 // Create a nested token ouroborostests/src/util/helpers.tsdiffbeforeafterboth325};325};326326327export 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};329329330 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 any352 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}556557export 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);562563 expect(result.success).to.be.true;564 });565}557566558export 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 expect1300 // tslint:disable-next-line:no-unused-expression1309 // tslint:disable-next-line:no-unused-expression1301 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}130513141344 // Get the collection1353 // Get the collection1345 const collection = await queryCollectionExpectSuccess(api, collectionId);1354 const collection = await queryCollectionExpectSuccess(api, collectionId);134613551347 expect(collection.mintMode.toHuman()).to.be.equal(enabled);1356 expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);1348 });1357 });1349}1358}13501359