difftreelog
Tests fixes sync
in: master
7 files changed
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -47,7 +47,6 @@
"testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",
"testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",
"testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
- "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
"testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",
"testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",
"testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -217,22 +217,6 @@
});
});
- it('Burn a token in a destroyed collection', async () => {
- const createMode = 'NFT';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
- const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
- await destroyCollectionExpectSuccess(collectionId);
-
- await usingApi(async (api) => {
- const tx = api.tx.unique.burnItem(collectionId, tokenId, 0);
- const badTransaction = async function () {
- await submitTransactionExpectFailAsync(alice, tx);
- };
- await expect(badTransaction()).to.be.rejected;
- });
-
- });
-
it('Burn a token that was never created', async () => {
const createMode = 'NFT';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createMultipleItemsEvent.test.ts
+++ b/tests/src/check-event/createMultipleItemsEvent.test.ts
@@ -39,7 +39,7 @@
it('Check event from createMultipleItems(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
+ const args = [{NFT: {}}, {NFT: {}}, {NFT: {}}];
const createMultipleItems = api.tx.unique.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);
const events = await submitTransactionAsync(alice, createMultipleItems);
const msg = JSON.stringify(uniqueEventMessage(events));
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 {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';2122describe('integration test: ext. createCollection():', () => {23 it('Create new NFT collection', async () => {24 await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});25 });26 it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {27 await createCollectionExpectSuccess({name: 'A'.repeat(64)});28 });29 it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {30 await createCollectionExpectSuccess({description: 'A'.repeat(256)});31 });32 it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {33 await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});34 });35 it('Create new Fungible collection', async () => {36 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});37 });38 it('Create new ReFungible collection', async () => {39 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40 });4142 it('create new collection with properties #1', async () => {43 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},44 properties: [{key: 'key1', value: 'val1'}],45 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});46 });4748 it('create new collection with properties #2', async () => {49 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},50 properties: [{key: 'key1', value: 'val1'}],51 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});52 });5354 it('create new collection with properties #3', async () => {55 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},56 properties: [{key: 'key1', value: 'val1'}],57 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});58 });5960 it('Create new collection with extra fields', async () => {61 await usingApi(async api => {62 const alice = privateKey('//Alice');63 const bob = privateKey('//Bob');64 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},66 //access: 'AllowList',67 name: [1],68 description: [2],69 tokenPrefix: '0x000000',70 //offchainSchema: '0x111111',71 //schemaVersion: 'Unique',72 pendingSponsor: bob.address,73 limits: {74 accountTokenOwnershipLimit: 3,75 },76 //constOnChainSchema: '0x333333',77 });78 const events = await submitTransactionAsync(alice, tx);79 const result = getCreateCollectionResult(events);8081 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;82 expect(collection.owner.toString()).to.equal(alice.address);83 expect(collection.mode.asFungible.toNumber()).to.equal(8);84 //expect(collection.access.isAllowList).to.be.true;85 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);86 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);87 expect(collection.tokenPrefix.toString()).to.equal('0x000000');88 //expect(collection.offchainSchema.toString()).to.equal('0x111111');89 //expect(collection.schemaVersion.isUnique).to.be.true;90 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);91 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);92 //expect(collection.constOnChainSchema.toString()).to.equal('0x333333');93 });94 });95});9697describe('(!negative test!) integration test: ext. createCollection():', () => {98 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {99 await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});100 });101 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {102 await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});103 });104 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {105 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});106 });107 it('fails when bad limits are set', async () => {108 await usingApi(async api => {109 const alice = privateKey('//Alice');110 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});111 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);112 });113 });114115 it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {116 const props = [];117118 for (let i = 0; i < 65; i++) {119 props.push({key: `key${i}`, value: `value${i}`});120 }121122 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});123 });124125 it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {126 const props = [];127128 for (let i = 0; i < 32; i++) {129 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});130 }131132 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});133 });134});1// 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 {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';2122describe('integration test: ext. createCollection():', () => {23 it('Create new NFT collection', async () => {24 await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});25 });26 it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {27 await createCollectionExpectSuccess({name: 'A'.repeat(64)});28 });29 it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {30 await createCollectionExpectSuccess({description: 'A'.repeat(256)});31 });32 it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {33 await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});34 });35 it('Create new Fungible collection', async () => {36 await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});37 });38 it('Create new ReFungible collection', async () => {39 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40 });4142 it('create new collection with properties #1', async () => {43 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},44 properties: [{key: 'key1', value: 'val1'}],45 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});46 });4748 it('create new collection with properties #2', async () => {49 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},50 properties: [{key: 'key1', value: 'val1'}],51 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});52 });5354 it('create new collection with properties #3', async () => {55 await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},56 properties: [{key: 'key1', value: 'val1'}],57 propPerm: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});58 });5960 it('Create new collection with extra fields', async () => {61 await usingApi(async api => {62 const alice = privateKey('//Alice');63 const bob = privateKey('//Bob');64 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},66 permissions: {67 access: 'AllowList'68 },69 name: [1],70 description: [2],71 tokenPrefix: '0x000000',72 pendingSponsor: bob.address,73 limits: {74 accountTokenOwnershipLimit: 3,75 },76 });77 const events = await submitTransactionAsync(alice, tx);78 const result = getCreateCollectionResult(events);7980 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;81 expect(collection.owner.toString()).to.equal(alice.address);82 expect(collection.mode.asFungible.toNumber()).to.equal(8);83 expect(collection.permissions.access.toHuman()).to.equal('AllowList');84 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);85 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);86 expect(collection.tokenPrefix.toString()).to.equal('0x000000');87 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);88 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);89 });90 });91});9293describe('(!negative test!) integration test: ext. createCollection():', () => {94 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {95 await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});96 });97 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {98 await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});99 });100 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {101 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});102 });103 it('fails when bad limits are set', async () => {104 await usingApi(async api => {105 const alice = privateKey('//Alice');106 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});107 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);108 });109 });110111 it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {112 const props = [];113114 for (let i = 0; i < 65; i++) {115 props.push({key: `key${i}`, value: `value${i}`});116 }117118 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});119 });120121 it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {122 const props = [];123124 for (let i = 0; i < 32; i++) {125 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});126 }127128 await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});129 });130});tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -27,7 +27,7 @@
createItemExpectFailure,
transferExpectSuccess,
getFreeBalance,
- waitNewBlocks,
+ waitNewBlocks, burnItemExpectSuccess,
} from './util/helpers';
import {expect} from 'chai';
@@ -48,6 +48,9 @@
await createItemExpectSuccess(alice, collectionId, 'NFT');
}
await createItemExpectFailure(alice, collectionId, 'NFT');
+ for(let i = 1; i < 11; i++) {
+ await burnItemExpectSuccess(alice, collectionId, i);
+ }
await destroyCollectionExpectSuccess(collectionId);
});
@@ -57,6 +60,7 @@
await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
await createItemExpectSuccess(alice, collectionId, 'NFT');
await createItemExpectFailure(alice, collectionId, 'NFT');
+ await burnItemExpectSuccess(alice, collectionId, 1);
await destroyCollectionExpectSuccess(collectionId);
});
});
@@ -77,6 +81,9 @@
await createItemExpectSuccess(alice, collectionId, 'ReFungible');
}
await createItemExpectFailure(alice, collectionId, 'ReFungible');
+ for(let i = 1; i < 11; i++) {
+ await burnItemExpectSuccess(alice, collectionId, i, 100);
+ }
await destroyCollectionExpectSuccess(collectionId);
});
@@ -85,6 +92,7 @@
await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
await createItemExpectSuccess(alice, collectionId, 'ReFungible');
await createItemExpectFailure(alice, collectionId, 'ReFungible');
+ await burnItemExpectSuccess(alice, collectionId, 1, 100);
await destroyCollectionExpectSuccess(collectionId);
});
});
tests/src/nextSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/nextSponsoring.test.ts
+++ b/tests/src/nextSponsoring.test.ts
@@ -68,7 +68,7 @@
// After transfer
await transferExpectSuccess(collectionId, itemId, alice, bob, 1);
- expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(5);
+ expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.lessThanOrEqual(5);
// Not existing token
expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId+1)).to.be.equal(-1);
@@ -86,7 +86,7 @@
expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(0);
await transferExpectSuccess(funCollectionId, 0, alice, bob, 10, 'Fungible');
- expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(5);
+ expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.lessThanOrEqual(5);
});
});
@@ -101,7 +101,7 @@
expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(0);
await transferExpectSuccess(refunCollectionId, refunItemId, alice, bob, 10, 'ReFungible');
- expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(5);
+ expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.lessThanOrEqual(5);
// Not existing token
expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId+1)).to.be.equal(-1);
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -168,17 +168,20 @@
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId);
await destroyCollectionExpectSuccess(nftCollectionId);
await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
await destroyCollectionExpectSuccess(fungibleCollectionId);
await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await transferExpectFailure(
reFungibleCollectionId,