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.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -63,17 +63,16 @@
const bob = privateKey('//Bob');
const tx = api.tx.unique.createCollectionEx({
mode: {Fungible: 8},
- //access: 'AllowList',
+ permissions: {
+ access: 'AllowList'
+ },
name: [1],
description: [2],
tokenPrefix: '0x000000',
- //offchainSchema: '0x111111',
- //schemaVersion: 'Unique',
pendingSponsor: bob.address,
limits: {
accountTokenOwnershipLimit: 3,
},
- //constOnChainSchema: '0x333333',
});
const events = await submitTransactionAsync(alice, tx);
const result = getCreateCollectionResult(events);
@@ -81,15 +80,12 @@
const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;
expect(collection.owner.toString()).to.equal(alice.address);
expect(collection.mode.asFungible.toNumber()).to.equal(8);
- //expect(collection.access.isAllowList).to.be.true;
+ expect(collection.permissions.access.toHuman()).to.equal('AllowList');
expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);
expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);
expect(collection.tokenPrefix.toString()).to.equal('0x000000');
- //expect(collection.offchainSchema.toString()).to.equal('0x111111');
- //expect(collection.schemaVersion.isUnique).to.be.true;
expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);
expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);
- //expect(collection.constOnChainSchema.toString()).to.equal('0x333333');
});
});
});
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.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 {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi} from './substrate/substrate-api';23import {24 createCollectionExpectSuccess,25 setCollectionSponsorExpectSuccess,26 confirmSponsorshipExpectSuccess,27 createItemExpectSuccess,28 transferExpectSuccess,29 normalizeAccountId,30 getNextSponsored,31} from './util/helpers';3233chai.use(chaiAsPromised);34const expect = chai.expect;35363738describe('Integration Test getNextSponsored(collection_id, owner, item_id):', () => {39 let alice: IKeyringPair;40 let bob: IKeyringPair;4142 before(async () => {43 await usingApi(async () => {44 alice = privateKey('//Alice');45 bob = privateKey('//Bob');46 });47 });4849 it('NFT', async () => {50 await usingApi(async (api: ApiPromise) => {5152 // Not existing collection 53 expect(await getNextSponsored(api, 0, normalizeAccountId(alice), 0)).to.be.equal(-1);5455 const collectionId = await createCollectionExpectSuccess();56 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);5758 // Check with Disabled sponsoring state59 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(-1);60 await setCollectionSponsorExpectSuccess(collectionId, bob.address);6162 // Check with Unconfirmed sponsoring state63 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(-1);64 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6566 // Check with Confirmed sponsoring state67 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(0);6869 // After transfer70 await transferExpectSuccess(collectionId, itemId, alice, bob, 1);71 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(5);7273 // Not existing token 74 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId+1)).to.be.equal(-1);75 });76 });7778 it('Fungible', async () => {79 await usingApi(async (api: ApiPromise) => {8081 const createMode = 'Fungible';82 const funCollectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});83 await createItemExpectSuccess(alice, funCollectionId, createMode);84 await setCollectionSponsorExpectSuccess(funCollectionId, bob.address);85 await confirmSponsorshipExpectSuccess(funCollectionId, '//Bob');86 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(0);8788 await transferExpectSuccess(funCollectionId, 0, alice, bob, 10, 'Fungible');89 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(5);90 });91 });9293 it('ReFungible', async () => {94 await usingApi(async (api: ApiPromise) => {9596 const createMode = 'ReFungible';97 const refunCollectionId = await createCollectionExpectSuccess({mode: {type: createMode}});98 const refunItemId = await createItemExpectSuccess(alice, refunCollectionId, createMode);99 await setCollectionSponsorExpectSuccess(refunCollectionId, bob.address);100 await confirmSponsorshipExpectSuccess(refunCollectionId, '//Bob');101 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(0);102103 await transferExpectSuccess(refunCollectionId, refunItemId, alice, bob, 10, 'ReFungible');104 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(5);105106 // Not existing token 107 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId+1)).to.be.equal(-1);108 });109 });110});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 {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi} from './substrate/substrate-api';23import {24 createCollectionExpectSuccess,25 setCollectionSponsorExpectSuccess,26 confirmSponsorshipExpectSuccess,27 createItemExpectSuccess,28 transferExpectSuccess,29 normalizeAccountId,30 getNextSponsored,31} from './util/helpers';3233chai.use(chaiAsPromised);34const expect = chai.expect;35363738describe('Integration Test getNextSponsored(collection_id, owner, item_id):', () => {39 let alice: IKeyringPair;40 let bob: IKeyringPair;4142 before(async () => {43 await usingApi(async () => {44 alice = privateKey('//Alice');45 bob = privateKey('//Bob');46 });47 });4849 it('NFT', async () => {50 await usingApi(async (api: ApiPromise) => {5152 // Not existing collection 53 expect(await getNextSponsored(api, 0, normalizeAccountId(alice), 0)).to.be.equal(-1);5455 const collectionId = await createCollectionExpectSuccess();56 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);5758 // Check with Disabled sponsoring state59 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(-1);60 await setCollectionSponsorExpectSuccess(collectionId, bob.address);6162 // Check with Unconfirmed sponsoring state63 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(-1);64 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6566 // Check with Confirmed sponsoring state67 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(0);6869 // After transfer70 await transferExpectSuccess(collectionId, itemId, alice, bob, 1);71 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.lessThanOrEqual(5);7273 // Not existing token 74 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId+1)).to.be.equal(-1);75 });76 });7778 it('Fungible', async () => {79 await usingApi(async (api: ApiPromise) => {8081 const createMode = 'Fungible';82 const funCollectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});83 await createItemExpectSuccess(alice, funCollectionId, createMode);84 await setCollectionSponsorExpectSuccess(funCollectionId, bob.address);85 await confirmSponsorshipExpectSuccess(funCollectionId, '//Bob');86 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(0);8788 await transferExpectSuccess(funCollectionId, 0, alice, bob, 10, 'Fungible');89 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.lessThanOrEqual(5);90 });91 });9293 it('ReFungible', async () => {94 await usingApi(async (api: ApiPromise) => {9596 const createMode = 'ReFungible';97 const refunCollectionId = await createCollectionExpectSuccess({mode: {type: createMode}});98 const refunItemId = await createItemExpectSuccess(alice, refunCollectionId, createMode);99 await setCollectionSponsorExpectSuccess(refunCollectionId, bob.address);100 await confirmSponsorshipExpectSuccess(refunCollectionId, '//Bob');101 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(0);102103 await transferExpectSuccess(refunCollectionId, refunItemId, alice, bob, 10, 'ReFungible');104 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.lessThanOrEqual(5);105106 // Not existing token 107 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId+1)).to.be.equal(-1);108 });109 });110});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,