difftreelog
test fix eslint warnings
in: master
4 files changed
tests/src/createItem.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// 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/>.161617import {default as usingApi, executeTransaction} from './substrate/substrate-api';17import {default as usingApi} from './substrate/substrate-api';18import chai from 'chai';18import chai from 'chai';19import {Keyring} from '@polkadot/api';19import {Keyring} from '@polkadot/api';20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';125 });125 });126126127 it('No editing rights', async () => {127 it('No editing rights', async () => {128 await usingApi(async api => {128 await usingApi(async () => {129 const createMode = 'NFT';129 const createMode = 'NFT';130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 131 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});131 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});136 });136 });137137138 it('User doesnt have editing rights', async () => {138 it('User doesnt have editing rights', async () => {139 await usingApi(async api => {139 await usingApi(async () => {140 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});140 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});141 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);141 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);142 });142 });143 });143 });144144145 it('Adding property without access rights', async () => {145 it('Adding property without access rights', async () => {146 await usingApi(async api => {146 await usingApi(async () => {147 const newCollectionID = await createCollectionWithPropsExpectSuccess();147 const newCollectionID = await createCollectionWithPropsExpectSuccess();148 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);148 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);149149152 });152 });153153154 it('Adding more than 64 prps', async () => {154 it('Adding more than 64 prps', async () => {155 await usingApi(async api => {155 await usingApi(async () => {156 const prps = [];156 const prps = [];157157158 for (let i = 0; i < 65; i++) {158 for (let i = 0; i < 65; i++) {166 });166 });167167168 it('Trying to add bigger property than allowed', async () => {168 it('Trying to add bigger property than allowed', async () => {169 await usingApi(async api => {169 await usingApi(async () => {170 const newCollectionID = await createCollectionWithPropsExpectSuccess();170 const newCollectionID = await createCollectionWithPropsExpectSuccess();171 171 172 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);172 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -49,13 +49,13 @@
const alice = privateKey('//Alice');
await submitTransactionAsync(
alice,
- api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}])
+ api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),
);
const args = [
{NFT: {properties: [{key: 'data', value: '1'}]}},
{NFT: {properties: [{key: 'data', value: '2'}]}},
- {NFT: {properties: [{key: 'data', value: '3'}]}}
+ {NFT: {properties: [{key: 'data', value: '3'}]}},
];
const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
await submitTransactionAsync(alice, createMultipleItemsTx);
@@ -143,7 +143,7 @@
const args = [
{NFT: {properties: [{key: 'k', value: 'v1'}]}},
{NFT: {properties: [{key: 'k', value: 'v2'}]}},
- {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+ {NFT: {properties: [{key: 'k', value: 'v3'}]}},
];
await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -171,7 +171,7 @@
const args = [
{NFT: {properties: [{key: 'k', value: 'v1'}]}},
{NFT: {properties: [{key: 'k', value: 'v2'}]}},
- {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+ {NFT: {properties: [{key: 'k', value: 'v3'}]}},
];
await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -190,16 +190,14 @@
it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionWithPropsExpectSuccess(
- {propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
- );
+ const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
const alice = privateKey('//Alice');
const args = [
{NFT: {properties: [{key: 'k', value: 'v1'}]}},
{NFT: {properties: [{key: 'k', value: 'v2'}]}},
- {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+ {NFT: {properties: [{key: 'k', value: 'v3'}]}},
];
await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -230,16 +228,14 @@
it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionWithPropsExpectSuccess(
- {propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
- );
+ const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const args = [
{NFT: {properties: [{key: 'data', value: 'v1'}]}},
{NFT: {properties: [{key: 'data', value: 'v2'}]}},
- {NFT: {properties: [{key: 'data', value: 'v3'}]}}
+ {NFT: {properties: [{key: 'data', value: 'v3'}]}},
];
const createMultipleItemsTx = api.tx.unique
.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
@@ -358,9 +354,7 @@
it('Create token in not existing collection', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await getCreatedCollectionCount(api) + 1;
- const createMultipleItemsTx = api.tx.unique.createMultipleItems(
- collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']
- );
+ const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);
await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);
});
});
@@ -369,7 +363,7 @@
await usingApi(async (api: ApiPromise) => {
// NFT
const collectionId = await createCollectionWithPropsExpectSuccess({
- propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+ propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
});
const alice = privateKey('//Alice');
const args = [
@@ -399,11 +393,7 @@
const collectionId = await createCollectionExpectSuccess();
const createMultipleItemsTx = api.tx.unique
.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);
- await expect(
- executeTransaction(api, alice, createMultipleItemsTx)
- ).to.be.rejectedWith(
- /nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/
- );
+ await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);
// garbage collection :-D // lol
await destroyCollectionExpectSuccess(collectionId);
});
@@ -412,7 +402,7 @@
it('Create tokens with different data limits <> maximum data limit', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionWithPropsExpectSuccess({
- propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+ propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
});
const args = [
{NFT: {properties: [{key: 'key', value: 'A'}]}},
@@ -441,7 +431,7 @@
it('User doesnt have editing rights', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionWithPropsExpectSuccess({
- propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]
+ propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
@@ -449,7 +439,7 @@
const args = [
{NFT: {properties: [{key: 'key1', value: 'v2'}]}},
{NFT: {}},
- {NFT: {}}
+ {NFT: {}},
];
const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
@@ -497,11 +487,11 @@
const args = [
{NFT: {properties: prps}},
{NFT: {properties: prps}},
- {NFT: {properties: prps}}
+ {NFT: {properties: prps}},
];
// there are no permissions, but will fail anyway because of too much weight for a block
- const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);;
+ const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;
});
});
@@ -509,7 +499,7 @@
it('Trying to add bigger property than allowed', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionWithPropsExpectSuccess({
- propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+ propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -16,8 +16,8 @@
import {expect} from 'chai';
import privateKey from './substrate/privateKey';
-import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';
+import usingApi, {executeTransaction} from './substrate/substrate-api';
+import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess} from './util/helpers';
describe('createMultipleItemsEx', () => {
it('can initialize multiple NFT with different owners', async () => {
@@ -175,7 +175,6 @@
propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
await addCollectionAdminExpectSuccess(alice, collection, bob.address);
await usingApi(async (api) => {
const data = [
@@ -236,9 +235,7 @@
const alice = privateKey('//Alice');
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await usingApi(async (api) => {
- await expect(
- executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))
- ).to.be.rejectedWith(/common\.PropertyLimitReached/);
+ await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
});
});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -347,7 +347,7 @@
name: strToUTF16(name),
description: strToUTF16(description),
tokenPrefix: strToUTF16(tokenPrefix),
- mode: modeprm as any
+ mode: modeprm as any,
});
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getCreateCollectionResult(events);
@@ -561,7 +561,7 @@
expect(result.success).to.be.true;
});
-}
+};
export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
await usingApi(async (api) => {