difftreelog
fix createCollection flags test
in: master
2 files changed
tests/src/createCollection.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub, Pallets} from './util';19import {CollectionFlag, ICollectionCreationOptions, IProperty} from './util/playgrounds/types';20import {UniqueHelper} from './util/playgrounds/unique';2122async function mintCollectionHelper(helper: UniqueHelper, signer: IKeyringPair, options: ICollectionCreationOptions, type?: 'nft' | 'fungible' | 'refungible') {23 let collection;24 if(type === 'nft') {25 collection = await helper.nft.mintCollection(signer, options);26 } else if(type === 'fungible') {27 collection = await helper.ft.mintCollection(signer, options, 0);28 } else {29 collection = await helper.rft.mintCollection(signer, options);30 }31 const data = await collection.getData();32 expect(data?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(signer.address));33 expect(data?.name).to.be.equal(options.name);34 expect(data?.description).to.be.equal(options.description);35 expect(data?.raw.tokenPrefix).to.be.equal(options.tokenPrefix);36 if(options.properties) {37 expect(data?.raw.properties).to.be.deep.equal(options.properties);38 }39 if(options.adminList) {40 expect(data?.admins).to.be.deep.equal(options.adminList);41 }4243 if(options.flags) {44 if((options.flags[0] & 64) != 0)45 expect(data?.raw.flags.erc721metadata).to.be.true;46 if((options.flags[0] & 128) != 0)47 expect(data?.raw.flags.foreign).to.be.false;48 }4950 if(options.tokenPropertyPermissions) {51 expect(data?.raw.tokenPropertyPermissions).to.be.deep.equal(options.tokenPropertyPermissions);52 }5354 return collection;55}5657describe('integration test: ext. createCollection():', () => {58 let alice: IKeyringPair;59 let bob: IKeyringPair;6061 before(async () => {62 await usingPlaygrounds(async (helper, privateKey) => {63 const donor = await privateKey({url: import.meta.url});64 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);65 });66 });67 itSub('Create new NFT collection', async ({helper}) => {68 await mintCollectionHelper(helper, alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 'nft');69 });70 itSub('Create new NFT collection whith collection_name of maximum length (64 bytes)', async ({helper}) => {71 await mintCollectionHelper(helper, alice, {name: 'A'.repeat(64), description: 'descr', tokenPrefix: 'COL'}, 'nft');72 });73 itSub('Create new NFT collection whith collection_description of maximum length (256 bytes)', async ({helper}) => {74 await mintCollectionHelper(helper, alice, {name: 'name', description: 'A'.repeat(256), tokenPrefix: 'COL'}, 'nft');75 });76 itSub('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async ({helper}) => {77 await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(16)}, 'nft');78 });7980 itSub('Create new Fungible collection', async ({helper}) => {81 await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'fungible');82 });8384 itSub.ifWithPallets('Create new ReFungible collection', [Pallets.ReFungible], async ({helper}) => {85 await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'refungible');86 });8788 itSub('create new collection with properties', async ({helper}) => {89 await mintCollectionHelper(helper, alice, {90 name: 'name', description: 'descr', tokenPrefix: 'COL',91 properties: [{key: 'key1', value: 'val1'}],92 tokenPropertyPermissions: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}],93 }, 'nft');94 });9596 itSub('create new collection with admin', async ({helper}) => {97 await mintCollectionHelper(helper, alice, {98 name: 'name', description: 'descr', tokenPrefix: 'COL',99 adminList: [{Substrate: bob.address}],100 }, 'nft');101 });102103 itSub('create new collection with flags', async ({helper}) => {104 await mintCollectionHelper(helper, alice, {105 name: 'name', description: 'descr', tokenPrefix: 'COL',106 flags: [CollectionFlag.Erc721metadata],107 }, 'nft');108109 await mintCollectionHelper(helper, alice, {110 name: 'name', description: 'descr', tokenPrefix: 'COL',111 flags: [CollectionFlag.Foreign],112 }, 'nft');113114 await mintCollectionHelper(helper, alice, {115 name: 'name', description: 'descr', tokenPrefix: 'COL',116 flags: [CollectionFlag.Erc721metadata, CollectionFlag.Foreign],117 }, 'nft');118 });119120 itSub('Create new collection with extra fields', async ({helper}) => {121 const collection = await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'fungible');122 await collection.setPermissions(alice, {access: 'AllowList'});123 await collection.setLimits(alice, {accountTokenOwnershipLimit: 3});124 const data = await collection.getData();125 const limits = await collection.getEffectiveLimits();126 const raw = data?.raw;127128 expect(data?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));129 expect(data?.name).to.be.equal('name');130 expect(data?.description).to.be.equal('descr');131 expect(raw.permissions.access).to.be.equal('AllowList');132 expect(raw.mode).to.be.deep.equal({Fungible: '0'});133 expect(limits.accountTokenOwnershipLimit).to.be.equal(3);134 });135136 itSub('New collection is not external', async ({helper}) => {137 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});138 const data = await collection.getData();139 expect(data?.raw.readOnly).to.be.false;140 });141});142143describe('(!negative test!) integration test: ext. createCollection():', () => {144 let alice: IKeyringPair;145146 before(async () => {147 await usingPlaygrounds(async (helper, privateKey) => {148 const donor = await privateKey({url: import.meta.url});149 [alice] = await helper.arrange.createAccounts([100n], donor);150 });151 });152153 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {154 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});155 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');156 });157 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {158 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});159 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');160 });161 itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {162 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});163 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');164 });165166 itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {167 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});168 await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);169 });170171 itSub('(!negative test!) create collection with incorrect property limit (64 elements)', async ({helper}) => {172 const props: IProperty[] = [];173174 for(let i = 0; i < 65; i++) {175 props.push({key: `key${i}`, value: `value${i}`});176 }177 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});178 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');179 });180181 itSub('(!negative test!) create collection with incorrect property limit (40 kb)', async ({helper}) => {182 const props: IProperty[] = [];183184 for(let i = 0; i < 32; i++) {185 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});186 }187188 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});189 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');190 });191});tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -41,7 +41,7 @@
for(const arg of args) {
if(typeof arg !== 'string')
continue;
- const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis'];
+ const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis', 'Bad input data provided to validate_transaction', 'account balance too low', '1006:: Abnormal Closure'];
const needToSkip = skippedWarnings.reduce((a, b) => a || arg.includes(b), false);
if(needToSkip || arg === 'Normal connection closure')
return;