difftreelog
Fixes for nesting and permissions tests
in: master
3 files changed
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -10,7 +10,7 @@
enablePublicMintingExpectSuccess,
getTokenOwner,
getTopmostTokenOwner,
- setCollectionPermissionsExceptSuccess,
+ setCollectionPermissionsExpectSuccess,
transferExpectFailure,
transferExpectSuccess,
transferFromExpectSuccess,
@@ -31,7 +31,7 @@
it('Performs the full suite: bundles a token, transfers, and allows to unnest', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
// Create a nested token
@@ -63,7 +63,7 @@
it('NFT: allows an Owner to nest/unnest their token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
// Create a nested token
@@ -82,7 +82,7 @@
it('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
// Create a nested token
@@ -103,7 +103,7 @@
it('Fungible: allows an Owner to nest/unnest their token', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
@@ -130,7 +130,7 @@
const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}});
// Create a nested token
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
@@ -150,7 +150,7 @@
it('ReFungible: allows an Owner to nest/unnest their token', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
@@ -177,7 +177,7 @@
const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
// Create a nested token
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
@@ -204,7 +204,7 @@
it('Disallows excessive token nesting', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
const maxNestingLevel = 5;
@@ -238,7 +238,7 @@
it('NFT: disallows to nest token if nesting is disabled', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Disabled'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Disabled'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
// Try to create a nested token
@@ -260,7 +260,7 @@
it('NFT: disallows a non-Owner to nest someone else\'s token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
await addToAllowListExpectSuccess(alice, collection, bob.address);
await enableAllowListExpectSuccess(alice, collection);
@@ -286,7 +286,7 @@
it('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}});
await addToAllowListExpectSuccess(alice, collection, bob.address);
await enableAllowListExpectSuccess(alice, collection);
@@ -312,7 +312,7 @@
it('NFT: disallows to nest token in an unlisted collection', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[]}});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[]}});
// Create a token to attempt to be nested into
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
@@ -336,7 +336,7 @@
it('Fungible: disallows to nest token if nesting is disabled', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Disabled'});
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
@@ -364,7 +364,7 @@
it('Fungible: disallows a non-Owner to nest someone else\'s token', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'});
await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);
await enableAllowListExpectSuccess(alice, collectionNFT);
@@ -401,7 +401,7 @@
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionFT]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionFT]}});
// Try to create a nested token in the wrong collection
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
@@ -419,7 +419,7 @@
it('Fungible: disallows to nest token in an unlisted collection', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
// Create a token to attempt to be nested into
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
@@ -445,7 +445,7 @@
it('ReFungible: disallows to nest token if nesting is disabled', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Disabled'});
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
@@ -475,7 +475,7 @@
it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'});
await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);
await enableAllowListExpectSuccess(alice, collectionNFT);
@@ -512,7 +512,7 @@
const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};
const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}});
// Try to create a nested token in the wrong collection
await expect(executeTransaction(api, alice, api.tx.unique.createItem(
@@ -530,7 +530,7 @@
it('ReFungible: disallows to nest token to an unlisted collection', async () => {
await usingApi(async api => {
const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
+ await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}});
// Create a token to attempt to be nested into
const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');
tests/src/nesting/unnest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/unnest.test.ts
+++ b/tests/src/nesting/unnest.test.ts
@@ -8,7 +8,7 @@
getBalance,
getTokenOwner,
normalizeAccountId,
- setCollectionPermissionsExceptSuccess,
+ setCollectionPermissionsExpectSuccess,
transferExpectSuccess,
transferFromExpectSuccess,
} from '../util/helpers';
@@ -28,7 +28,7 @@
it('NFT: allows the owner to successfully unnest a token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
@@ -57,7 +57,7 @@
it('Fungible: allows the owner to successfully unnest a token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
@@ -84,7 +84,7 @@
it('ReFungible: allows the owner to successfully unnest a token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
@@ -119,7 +119,7 @@
it('Disallows a non-owner to unnest/burn a token', async () => {
await usingApi(async api => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)};
@@ -149,7 +149,7 @@
// Recursive nesting
it('Prevents Ouroboros creation', async () => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'});
+ await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'});
const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');
// Create a nested token ouroboros
tests/src/util/helpers.tsdiffbeforeafterboth554 });554 });555}555}556556557export const setCollectionPermissionsExceptSuccess = async (sender: IKeyringPair, collectionId: number, permissions: {mintMode?: boolean, access?: 'Normal' | 'AllowList', nesting?: 'Disabled' | 'Owner' | {OwnerRestricted: number[]}}) => {557export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: {mintMode?: boolean, access?: 'Normal' | 'AllowList', nesting?: 'Disabled' | 'Owner' | {OwnerRestricted: number[]}}) => {558 await usingApi(async(api) => {558 await usingApi(async(api) => {559 const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);559 const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);560 const events = await submitTransactionAsync(sender, tx);560 const events = await submitTransactionAsync(sender, tx);1298 await usingApi(async (api) => {1298 await usingApi(async (api) => {129912991300 // Run the transaction1300 // Run the transaction1301 const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode);1301 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1302 const events = await submitTransactionAsync(sender, tx);1302 const events = await submitTransactionAsync(sender, tx);1303 const result = getGenericResult(events);1303 const result = getGenericResult(events);130413041319 await usingApi(async (api) => {1319 await usingApi(async (api) => {132013201321 // Run the transaction1321 // Run the transaction1322 const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode);1322 const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1323 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1323 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1324 const result = getGenericResult(events);1324 const result = getGenericResult(events);132513251345 await usingApi(async (api) => {1345 await usingApi(async (api) => {134613461347 // Run the transaction1347 // Run the transaction1348 const tx = api.tx.unique.setMintPermission(collectionId, enabled);1348 const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1349 const events = await submitTransactionAsync(sender, tx);1349 const events = await submitTransactionAsync(sender, tx);1350 const result = getGenericResult(events);1350 const result = getGenericResult(events);1351 expect(result.success).to.be.true;1351 expect(result.success).to.be.true;