git.delta.rocks / unique-network / refs/commits / 156a79ad752f

difftreelog

Tests fixes sync

Andrey Kuznetsov2022-05-30parent: #4153532.patch.diff
in: master

7 files changed

modifiedtests/package.jsondiffbeforeafterboth
47 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",47 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",
48 "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",48 "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",
49 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",49 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
50 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
51 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",50 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",
52 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",51 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",
53 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",52 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
217 });217 });
218 });218 });
219
220 it('Burn a token in a destroyed collection', async () => {
221 const createMode = 'NFT';
222 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
223 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
224 await destroyCollectionExpectSuccess(collectionId);
225
226 await usingApi(async (api) => {
227 const tx = api.tx.unique.burnItem(collectionId, tokenId, 0);
228 const badTransaction = async function () {
229 await submitTransactionExpectFailAsync(alice, tx);
230 };
231 await expect(badTransaction()).to.be.rejected;
232 });
233
234 });
235219
236 it('Burn a token that was never created', async () => {220 it('Burn a token that was never created', async () => {
237 const createMode = 'NFT';221 const createMode = 'NFT';
modifiedtests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth
39 it('Check event from createMultipleItems(): ', async () => {39 it('Check event from createMultipleItems(): ', async () => {
40 await usingApi(async (api: ApiPromise) => {40 await usingApi(async (api: ApiPromise) => {
41 const collectionID = await createCollectionExpectSuccess();41 const collectionID = await createCollectionExpectSuccess();
42 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];42 const args = [{NFT: {}}, {NFT: {}}, {NFT: {}}];
43 const createMultipleItems = api.tx.unique.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);43 const createMultipleItems = api.tx.unique.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);
44 const events = await submitTransactionAsync(alice, createMultipleItems);44 const events = await submitTransactionAsync(alice, createMultipleItems);
45 const msg = JSON.stringify(uniqueEventMessage(events));45 const msg = JSON.stringify(uniqueEventMessage(events));
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
63 const bob = privateKey('//Bob');63 const bob = privateKey('//Bob');
64 const tx = api.tx.unique.createCollectionEx({64 const tx = api.tx.unique.createCollectionEx({
65 mode: {Fungible: 8},65 mode: {Fungible: 8},
66 //access: 'AllowList',66 permissions: {
67 access: 'AllowList'
68 },
67 name: [1],69 name: [1],
68 description: [2],70 description: [2],
69 tokenPrefix: '0x000000',71 tokenPrefix: '0x000000',
70 //offchainSchema: '0x111111',
71 //schemaVersion: 'Unique',
72 pendingSponsor: bob.address,72 pendingSponsor: bob.address,
73 limits: {73 limits: {
74 accountTokenOwnershipLimit: 3,74 accountTokenOwnershipLimit: 3,
75 },75 },
76 //constOnChainSchema: '0x333333',
77 });76 });
78 const events = await submitTransactionAsync(alice, tx);77 const events = await submitTransactionAsync(alice, tx);
79 const result = getCreateCollectionResult(events);78 const result = getCreateCollectionResult(events);
8079
81 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;80 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;
82 expect(collection.owner.toString()).to.equal(alice.address);81 expect(collection.owner.toString()).to.equal(alice.address);
83 expect(collection.mode.asFungible.toNumber()).to.equal(8);82 expect(collection.mode.asFungible.toNumber()).to.equal(8);
84 //expect(collection.access.isAllowList).to.be.true;83 expect(collection.permissions.access.toHuman()).to.equal('AllowList');
85 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);84 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);
86 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);85 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);
87 expect(collection.tokenPrefix.toString()).to.equal('0x000000');86 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);87 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);
91 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);88 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);
92 //expect(collection.constOnChainSchema.toString()).to.equal('0x333333');
93 });89 });
94 });90 });
95});91});
modifiedtests/src/limits.test.tsdiffbeforeafterboth
27 createItemExpectFailure,27 createItemExpectFailure,
28 transferExpectSuccess,28 transferExpectSuccess,
29 getFreeBalance,29 getFreeBalance,
30 waitNewBlocks,30 waitNewBlocks, burnItemExpectSuccess,
31} from './util/helpers';31} from './util/helpers';
32import {expect} from 'chai';32import {expect} from 'chai';
3333
48 await createItemExpectSuccess(alice, collectionId, 'NFT');48 await createItemExpectSuccess(alice, collectionId, 'NFT');
49 }49 }
50 await createItemExpectFailure(alice, collectionId, 'NFT');50 await createItemExpectFailure(alice, collectionId, 'NFT');
51 for(let i = 1; i < 11; i++) {
52 await burnItemExpectSuccess(alice, collectionId, i);
53 }
51 await destroyCollectionExpectSuccess(collectionId);54 await destroyCollectionExpectSuccess(collectionId);
52 });55 });
5356
57 await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});60 await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
58 await createItemExpectSuccess(alice, collectionId, 'NFT');61 await createItemExpectSuccess(alice, collectionId, 'NFT');
59 await createItemExpectFailure(alice, collectionId, 'NFT');62 await createItemExpectFailure(alice, collectionId, 'NFT');
63 await burnItemExpectSuccess(alice, collectionId, 1);
60 await destroyCollectionExpectSuccess(collectionId);64 await destroyCollectionExpectSuccess(collectionId);
61 });65 });
62});66});
77 await createItemExpectSuccess(alice, collectionId, 'ReFungible');81 await createItemExpectSuccess(alice, collectionId, 'ReFungible');
78 }82 }
79 await createItemExpectFailure(alice, collectionId, 'ReFungible');83 await createItemExpectFailure(alice, collectionId, 'ReFungible');
84 for(let i = 1; i < 11; i++) {
85 await burnItemExpectSuccess(alice, collectionId, i, 100);
86 }
80 await destroyCollectionExpectSuccess(collectionId);87 await destroyCollectionExpectSuccess(collectionId);
81 });88 });
8289
85 await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});92 await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
86 await createItemExpectSuccess(alice, collectionId, 'ReFungible');93 await createItemExpectSuccess(alice, collectionId, 'ReFungible');
87 await createItemExpectFailure(alice, collectionId, 'ReFungible');94 await createItemExpectFailure(alice, collectionId, 'ReFungible');
95 await burnItemExpectSuccess(alice, collectionId, 1, 100);
88 await destroyCollectionExpectSuccess(collectionId);96 await destroyCollectionExpectSuccess(collectionId);
89 });97 });
90});98});
modifiedtests/src/nextSponsoring.test.tsdiffbeforeafterboth
6868
69 // After transfer69 // After transfer
70 await transferExpectSuccess(collectionId, itemId, alice, bob, 1);70 await transferExpectSuccess(collectionId, itemId, alice, bob, 1);
71 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.equal(5);71 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId)).to.be.lessThanOrEqual(5);
7272
73 // Not existing token 73 // Not existing token
74 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId+1)).to.be.equal(-1);74 expect(await getNextSponsored(api, collectionId, normalizeAccountId(alice), itemId+1)).to.be.equal(-1);
86 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(0);86 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(0);
8787
88 await transferExpectSuccess(funCollectionId, 0, alice, bob, 10, 'Fungible');88 await transferExpectSuccess(funCollectionId, 0, alice, bob, 10, 'Fungible');
89 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.equal(5);89 expect(await getNextSponsored(api, funCollectionId, normalizeAccountId(alice), 0)).to.be.lessThanOrEqual(5);
90 });90 });
91 });91 });
9292
101 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(0);101 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(0);
102102
103 await transferExpectSuccess(refunCollectionId, refunItemId, alice, bob, 10, 'ReFungible');103 await transferExpectSuccess(refunCollectionId, refunItemId, alice, bob, 10, 'ReFungible');
104 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.equal(5);104 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId)).to.be.lessThanOrEqual(5);
105105
106 // Not existing token 106 // Not existing token
107 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId+1)).to.be.equal(-1);107 expect(await getNextSponsored(api, refunCollectionId, normalizeAccountId(alice), refunItemId+1)).to.be.equal(-1);
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
168 // nft168 // nft
169 const nftCollectionId = await createCollectionExpectSuccess();169 const nftCollectionId = await createCollectionExpectSuccess();
170 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');170 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
171 await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId);
171 await destroyCollectionExpectSuccess(nftCollectionId);172 await destroyCollectionExpectSuccess(nftCollectionId);
172 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);173 await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
173 // fungible174 // fungible
174 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});175 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
175 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');176 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
177 await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
176 await destroyCollectionExpectSuccess(fungibleCollectionId);178 await destroyCollectionExpectSuccess(fungibleCollectionId);
177 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);179 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
178 // reFungible180 // reFungible
179 const reFungibleCollectionId = await181 const reFungibleCollectionId = await
180 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});182 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
181 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');183 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
184 await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
182 await destroyCollectionExpectSuccess(reFungibleCollectionId);185 await destroyCollectionExpectSuccess(reFungibleCollectionId);
183 await transferExpectFailure(186 await transferExpectFailure(
184 reFungibleCollectionId,187 reFungibleCollectionId,