git.delta.rocks / unique-network / refs/commits / 96cdb9b3ccba

difftreelog

fix code style

rkv2022-09-14parent: #9844c48.patch.diff
in: master

6 files changed

modifiedtests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth
15// 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/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import chai from 'chai';
19import chaiAsPromised from 'chai-as-promised';
20import {usingPlaygrounds} from './util/playgrounds';18import {usingPlaygrounds, expect, itSub} from './util/playgrounds';
21
22chai.use(chaiAsPromised);
23const expect = chai.expect;
24
25let donor: IKeyringPair;
26
27before(async () => {
28 await usingPlaygrounds(async (_, privateKey) => {
29 donor = privateKey('//Alice');
30 });
31});
3219
33describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {20describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {
34 let alice: IKeyringPair;21 let alice: IKeyringPair;
35 let bob: IKeyringPair;22 let bob: IKeyringPair;
36 let charlie: IKeyringPair;23 let charlie: IKeyringPair;
3724
38 before(async () => {25 before(async () => {
39 await usingPlaygrounds(async (helper) => {26 await usingPlaygrounds(async (helper, privateKey) => {
27 const donor = privateKey('//Alice');
40 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);28 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
41 });29 });
42 });30 });
4331
44 it('admin transfers other user\'s token', async () => {32 itSub('admin transfers other user\'s token', async ({helper}) => {
45 await usingPlaygrounds(async (helper) => {
46 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});33 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
47 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});34 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
48 const limits = await helper.collection.getEffectiveLimits(collectionId);35 const limits = await helper.collection.getEffectiveLimits(collectionId);
55 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});42 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
56 const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);43 const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
57 expect(newTokenOwner.Substrate).to.be.equal(charlie.address);44 expect(newTokenOwner.Substrate).to.be.equal(charlie.address);
58 });
59 });45 });
6046
61 it('admin burns other user\'s token', async () => {47 itSub('admin burns other user\'s token', async ({helper}) => {
62 await usingPlaygrounds(async (helper) => {
63 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});48 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
6449
65 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});50 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
74 await helper.nft.burnToken(bob, collectionId, tokenId);59 await helper.nft.burnToken(bob, collectionId, tokenId);
75 const token = await helper.nft.getToken(collectionId, tokenId);60 const token = await helper.nft.getToken(collectionId, tokenId);
76 expect(token).to.be.null;61 expect(token).to.be.null;
77 });
78 });62 });
79});63});
8064
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.2// This file is part of Unique Network.
33
4// Unique Network is free software: you can redistribute it and/or modify4// Unique Network is free software: you can redistribute itSub and/or modify
5// it under the terms of the GNU General Public License as published by5// itSub under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is distributed in the hope that itSub will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
15// 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/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import chai from 'chai';
19import chaiAsPromised from 'chai-as-promised';
20import {usingPlaygrounds} from './util/playgrounds';18import {usingPlaygrounds, expect, itSub} from './util/playgrounds';
21
22chai.use(chaiAsPromised);
23const expect = chai.expect;
24
25let donor: IKeyringPair;
26
27before(async () => {
28 await usingPlaygrounds(async (_, privateKey) => {
29 donor = privateKey('//Alice');
30 });
31});
3219
33describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {20describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
34 let alice: IKeyringPair;21 let alice: IKeyringPair;
35 let bob: IKeyringPair;22 let bob: IKeyringPair;
3623
37 before(async () => {24 before(async () => {
38 await usingPlaygrounds(async (helper) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');
39 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);27 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
40 });28 });
41 });29 });
4230
43 it('Changing owner changes owner address', async () => {31 itSub('Changing owner changes owner address', async ({helper}) => {
44 await usingPlaygrounds(async (helper) => {
45 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});32 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
46 const beforeChanging = await helper.collection.getData(collection.collectionId);33 const beforeChanging = await helper.collection.getData(collection.collectionId);
47 expect(beforeChanging?.normalizedOwner).to.be.equal(alice.address);34 expect(beforeChanging?.normalizedOwner).to.be.equal(alice.address);
4835
49 await collection.changeOwner(alice, bob.address);36 await collection.changeOwner(alice, bob.address);
50 const afterChanging = await helper.collection.getData(collection.collectionId);37 const afterChanging = await helper.collection.getData(collection.collectionId);
51 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);38 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);
52 });
53 });39 });
54});40});
5541
59 let charlie: IKeyringPair;45 let charlie: IKeyringPair;
6046
61 before(async () => {47 before(async () => {
62 await usingPlaygrounds(async (helper) => {48 await usingPlaygrounds(async (helper, privateKey) => {
49 const donor = privateKey('//Alice');
63 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);50 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
64 });51 });
65 });52 });
6653
67 it('Changing the owner of the collection is not allowed for the former owner', async () => {54 itSub('Changing the owner of the collection is not allowed for the former owner', async ({helper}) => {
68 await usingPlaygrounds(async (helper) => {
69 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});55 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
7056
71 await collection.changeOwner(alice, bob.address);57 await collection.changeOwner(alice, bob.address);
7258
73 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);59 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
74 await expect(changeOwnerTx()).to.be.rejected;60 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
7561
76 const afterChanging = await helper.collection.getData(collection.collectionId);62 const afterChanging = await helper.collection.getData(collection.collectionId);
77 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);63 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);
78 });
79 });64 });
8065
81 it('New collectionOwner has access to sponsorship management operations in the collection', async () => {66 itSub('New collectionOwner has access to sponsorship management operations in the collection', async ({helper}) => {
82 await usingPlaygrounds(async (helper) => {
83 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});67 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
84 await collection.changeOwner(alice, bob.address);68 await collection.changeOwner(alice, bob.address);
8569
106 await collection.burn(bob);90 await collection.burn(bob);
107 const collectionData = await helper.collection.getData(collection.collectionId);91 const collectionData = await helper.collection.getData(collection.collectionId);
108 expect(collectionData).to.be.null;92 expect(collectionData).to.be.null;
109 });
110 });93 });
11194
112 it('New collectionOwner has access to changeCollectionOwner', async () => {95 itSub('New collectionOwner has access to changeCollectionOwner', async ({helper}) => {
113 await usingPlaygrounds(async (helper) => {
114 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});96 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
115 await collection.changeOwner(alice, bob.address);97 await collection.changeOwner(alice, bob.address);
116 await collection.changeOwner(bob, charlie.address);98 await collection.changeOwner(bob, charlie.address);
117 const collectionData = await collection.getData();99 const collectionData = await collection.getData();
118 expect(collectionData?.normalizedOwner).to.be.equal(charlie.address);100 expect(collectionData?.normalizedOwner).to.be.equal(charlie.address);
119 });
120 });101 });
121});102});
122103
126 let charlie: IKeyringPair;107 let charlie: IKeyringPair;
127108
128 before(async () => {109 before(async () => {
129 await usingPlaygrounds(async (helper) => {110 await usingPlaygrounds(async (helper, privateKey) => {
111 const donor = privateKey('//Alice');
130 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);112 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
131 });113 });
132 });114 });
133115
134 it('Not owner can\'t change owner.', async () => {116 itSub('Not owner can\'t change owner.', async ({helper}) => {
135 await usingPlaygrounds(async (helper) => {
136 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});117 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
137 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);118 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
138 await expect(changeOwnerTx()).to.be.rejected;119 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
139 });
140 });120 });
141121
142 it('Collection admin can\'t change owner.', async () => {122 itSub('Collection admin can\'t change owner.', async ({helper}) => {
143 await usingPlaygrounds(async (helper) => {
144 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});123 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
145 await collection.addAdmin(alice, {Substrate: bob.address});124 await collection.addAdmin(alice, {Substrate: bob.address});
146 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);125 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
147 await expect(changeOwnerTx()).to.be.rejected;126 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
148 });
149 });127 });
150128
151 it('Can\'t change owner of a non-existing collection.', async () => {129 itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {
152 await usingPlaygrounds(async (helper) => {
153 const collectionId = (1 << 32) - 1;130 const collectionId = (1 << 32) - 1;
154 const changeOwnerTx = async () => helper.collection.changeOwner(bob, collectionId, bob.address);131 const changeOwnerTx = async () => helper.collection.changeOwner(bob, collectionId, bob.address);
155 await expect(changeOwnerTx()).to.be.rejected;132 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
156 });
157 });133 });
158134
159 it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {135 itSub('Former collectionOwner not allowed to sponsorship management operations in the collection', async ({helper}) => {
160 await usingPlaygrounds(async (helper) => {
161 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});136 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
162 await collection.changeOwner(alice, bob.address);137 await collection.changeOwner(alice, bob.address);
163138
164 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);139 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
165 await expect(changeOwnerTx()).to.be.rejected;140 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
166141
167 const afterChanging = await helper.collection.getData(collection.collectionId);142 const afterChanging = await helper.collection.getData(collection.collectionId);
168 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);143 expect(afterChanging?.normalizedOwner).to.be.equal(bob.address);
169144
170 const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);145 const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);
171 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);146 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
172 const removeSponsorTx = async () => collection.removeSponsor(alice);147 const removeSponsorTx = async () => collection.removeSponsor(alice);
173 await expect(setSponsorTx()).to.be.rejected;148 await expect(setSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
174 await expect(confirmSponsorshipTx()).to.be.rejected;149 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
175 await expect(removeSponsorTx()).to.be.rejected;150 await expect(removeSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
176151
177 const limits = {152 const limits = {
178 accountTokenOwnershipLimit: 1,153 accountTokenOwnershipLimit: 1,
183 };158 };
184159
185 const setLimitsTx = async () => collection.setLimits(alice, limits);160 const setLimitsTx = async () => collection.setLimits(alice, limits);
186 await expect(setLimitsTx()).to.be.rejected;161 await expect(setLimitsTx()).to.be.rejectedWith(/common\.NoPermission/);
187162
188 const setPermissionTx = async () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});163 const setPermissionTx = async () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});
189 await expect(setPermissionTx()).to.be.rejected;164 await expect(setPermissionTx()).to.be.rejectedWith(/common\.NoPermission/);
190165
191 const burnTx = async () => collection.burn(alice);166 const burnTx = async () => collection.burn(alice);
192 await expect(burnTx()).to.be.rejected;167 await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);
193 });
194 });168 });
195});169});
196170
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.2// This file is part of Unique Network.
33
4// Unique Network is free software: you can redistribute it and/or modify4// Unique Network is free software: you can redistribute itSub and/or modify
5// it under the terms of the GNU General Public License as published by5// itSub under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is distributed in the hope that itSub will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
1313
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17import chai from 'chai';
18import chaiAsPromised from 'chai-as-promised';
19import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
20import {usingPlaygrounds} from './util/playgrounds';18import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
21
22chai.use(chaiAsPromised);
23const expect = chai.expect;
24
25let donor: IKeyringPair;
26
27before(async () => {
28 await usingPlaygrounds(async (_, privateKey) => {
29 donor = privateKey('//Alice');
30 });
31});
32
33let alice: IKeyringPair;
34let bob: IKeyringPair;
35let charlie: IKeyringPair;
3619
37describe('integration test: ext. confirmSponsorship():', () => {20describe('integration test: ext. confirmSponsorship():', () => {
21 let alice: IKeyringPair;
22 let bob: IKeyringPair;
23 let charlie: IKeyringPair;
24 let zeroBalance: IKeyringPair;
3825
39 before(async () => {26 before(async () => {
40 await usingPlaygrounds(async (helper) => {27 await usingPlaygrounds(async (helper, privateKey) => {
28 const donor = privateKey('//Alice');
41 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);29 [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);
42 });30 });
43 });31 });
4432
45 it('Confirm collection sponsorship', async () => {33 itSub('Confirm collection sponsorship', async ({helper}) => {
46 await usingPlaygrounds(async (helper) => {
47 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});34 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
48 await collection.setSponsor(alice, bob.address);35 await collection.setSponsor(alice, bob.address);
49 await collection.confirmSponsorship(bob);36 await collection.confirmSponsorship(bob);
50 });
51 });37 });
5238
53 it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {39 itSub('Add sponsor to a collection after the same sponsor was already added and confirmed', async ({helper}) => {
54 await usingPlaygrounds(async (helper) => {
55 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});40 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
56 await collection.setSponsor(alice, bob.address);41 await collection.setSponsor(alice, bob.address);
57 await collection.confirmSponsorship(bob);42 await collection.confirmSponsorship(bob);
58 await collection.setSponsor(alice, bob.address);43 await collection.setSponsor(alice, bob.address);
59 });
60 });44 });
61 it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {45 itSub('Add new sponsor to a collection after another sponsor was already added and confirmed', async ({helper}) => {
62 await usingPlaygrounds(async (helper) => {
63 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});46 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
64 await collection.setSponsor(alice, bob.address);47 await collection.setSponsor(alice, bob.address);
65 await collection.confirmSponsorship(bob);48 await collection.confirmSponsorship(bob);
66 await collection.setSponsor(alice, charlie.address);49 await collection.setSponsor(alice, charlie.address);
67 });
68 });50 });
6951
70 it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {52 itSub('NFT: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {
71 await usingPlaygrounds(async (helper) => {
72 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
73 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});53 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
74 await collection.setSponsor(alice, bob.address);54 await collection.setSponsor(alice, bob.address);
75 await collection.confirmSponsorship(bob);55 await collection.confirmSponsorship(bob);
78 await token.transfer(zeroBalance, {Substrate: alice.address});58 await token.transfer(zeroBalance, {Substrate: alice.address});
79 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);59 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
80 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;60 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;
81 });
82 });61 });
8362
84 it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {63 itSub('Fungible: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {
85 await usingPlaygrounds(async (helper) => {
86 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
87 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);64 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
88 await collection.setSponsor(alice, bob.address);65 await collection.setSponsor(alice, bob.address);
89 await collection.confirmSponsorship(bob);66 await collection.confirmSponsorship(bob);
90 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);67 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
91 await collection.mint(alice, {Substrate: zeroBalance.address}, 100n);68 await collection.mint(alice, 100n, {Substrate: zeroBalance.address});
92 await collection.transfer(zeroBalance, {Substrate: alice.address}, 1n);69 await collection.transfer(zeroBalance, {Substrate: alice.address}, 1n);
93 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);70 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
94 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;71 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;
95 });
96 });72 });
9773
98 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async function() {74 itSub.ifWithPallets('ReFungible: Transfer fees are paid by the sponsor after confirmation', [Pallets.ReFungible], async ({helper}) => {
99 await usingPlaygrounds(async (helper) => {
100 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
101 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});75 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
102 await collection.setSponsor(alice, bob.address);76 await collection.setSponsor(alice, bob.address);
103 await collection.confirmSponsorship(bob);77 await collection.confirmSponsorship(bob);
104 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);78 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
105 const token = await collection.mintToken(alice, {Substrate: zeroBalance.address}, 100n);79 const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});
106 await token.transfer(zeroBalance, {Substrate: alice.address}, 1n);80 await token.transfer(zeroBalance, {Substrate: alice.address}, 1n);
107 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);81 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
108 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;82 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;
109 });83 });
110 });
11184
112 it('CreateItem fees are paid by the sponsor after confirmation', async () => {85 itSub('CreateItem fees are paid by the sponsor after confirmation', async ({helper}) => {
113 await usingPlaygrounds(async (helper) => {
114 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
115 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});86 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
116 await collection.setSponsor(alice, bob.address);87 await collection.setSponsor(alice, bob.address);
117 await collection.confirmSponsorship(bob);88 await collection.confirmSponsorship(bob);
123 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);94 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
12495
125 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;96 expect(bobBalanceAfter < bobBalanceBefore).to.be.true;
126 });
127 });97 });
12898
129 it('NFT: Sponsoring of transfers is rate limited', async () => {99 itSub('NFT: Sponsoring of transfers is rate limited', async ({helper}) => {
130 await usingPlaygrounds(async (helper) => {
131 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
132 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});100 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
133 await collection.setSponsor(alice, bob.address);101 await collection.setSponsor(alice, bob.address);
134 await collection.confirmSponsorship(bob);102 await collection.confirmSponsorship(bob);
142 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);110 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
143111
144 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;112 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;
145 });
146 });113 });
147114
148 it('Fungible: Sponsoring is rate limited', async () => {115 itSub('Fungible: Sponsoring is rate limited', async ({helper}) => {
149 await usingPlaygrounds(async (helper) => {
150 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
151 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});116 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
152 await collection.setSponsor(alice, bob.address);117 await collection.setSponsor(alice, bob.address);
153 await collection.confirmSponsorship(bob);118 await collection.confirmSponsorship(bob);
154119
155 await collection.mint(alice, {Substrate: zeroBalance.address}, 100n);120 await collection.mint(alice, 100n, {Substrate: zeroBalance.address});
156 await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);121 await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);
157 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);122 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
158123
161 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);126 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
162127
163 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;128 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;
164 });
165 });129 });
166130
167 it('ReFungible: Sponsoring is rate limited', async function() {131 itSub.ifWithPallets('ReFungible: Sponsoring is rate limited', [Pallets.ReFungible], async ({helper}) => {
168 await usingPlaygrounds(async (helper) => {
169 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
170 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});132 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
171 await collection.setSponsor(alice, bob.address);133 await collection.setSponsor(alice, bob.address);
172 await collection.confirmSponsorship(bob);134 await collection.confirmSponsorship(bob);
173135
174 const token = await collection.mintToken(alice, {Substrate: zeroBalance.address}, 100n);136 const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});
175 await token.transfer(zeroBalance, {Substrate: alice.address});137 await token.transfer(zeroBalance, {Substrate: alice.address});
176138
177 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);139 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
180 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);142 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
181143
182 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;144 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;
183 });145 });
184 });
185146
186 it('NFT: Sponsoring of createItem is rate limited', async () => {147 itSub('NFT: Sponsoring of createItem is rate limited', async ({helper}) => {
187 await usingPlaygrounds(async (helper) => {
188 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);
189 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});148 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
190 await collection.setSponsor(alice, bob.address);149 await collection.setSponsor(alice, bob.address);
191 await collection.confirmSponsorship(bob);150 await collection.confirmSponsorship(bob);
200 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);159 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
201160
202 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;161 expect(bobBalanceAfter === bobBalanceBefore).to.be.true;
203 });
204 });162 });
205});163});
206164
207describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {165describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {
166 let alice: IKeyringPair;
167 let bob: IKeyringPair;
168 let charlie: IKeyringPair;
169 let ownerZeroBalance: IKeyringPair;
170 let senderZeroBalance: IKeyringPair;
171
208 before(async () => {172 before(async () => {
209 await usingPlaygrounds(async (helper) => {173 await usingPlaygrounds(async (helper, privateKey) => {
174 const donor = privateKey('//Alice');
210 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);175 [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);
211 });176 });
212 });177 });
213178
214 it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {179 itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {
215 await usingPlaygrounds(async (helper) => {180 const collectionId = 1_000_000;
216 const collectionId = 1 << 32 - 1;
217 const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);181 const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);
218 await expect(confirmSponsorshipTx()).to.be.rejected;182 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
219 });
220 });183 });
221184
222 it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {185 itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {
223 await usingPlaygrounds(async (helper) => {
224 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});186 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
225 await collection.setSponsor(alice, bob.address);187 await collection.setSponsor(alice, bob.address);
226 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);188 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
227 await expect(confirmSponsorshipTx()).to.be.rejected;189 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
228 });
229 });190 });
230191
231 it('(!negative test!) Confirm sponsorship using owner address', async () => {192 itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {
232 await usingPlaygrounds(async (helper) => {
233 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});193 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
234 await collection.setSponsor(alice, bob.address);194 await collection.setSponsor(alice, bob.address);
235 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);195 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
236 await expect(confirmSponsorshipTx()).to.be.rejected;196 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
237 });
238 });197 });
239198
240 it('(!negative test!) Confirm sponsorship by collection admin', async () => {199 itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {
241 await usingPlaygrounds(async (helper) => {
242 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});200 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
243 await collection.setSponsor(alice, bob.address);201 await collection.setSponsor(alice, bob.address);
244 await collection.addAdmin(alice, {Substrate: charlie.address});202 await collection.addAdmin(alice, {Substrate: charlie.address});
245 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);203 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
246 await expect(confirmSponsorshipTx()).to.be.rejected;204 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
247 });
248 });205 });
249206
250 it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {207 itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {
251 await usingPlaygrounds(async (helper) => {
252 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});208 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
253 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);209 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
254 await expect(confirmSponsorshipTx()).to.be.rejected;210 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
255 });
256 });211 });
257212
258 it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {213 itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {
259 await usingPlaygrounds(async (helper) => {
260 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});214 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
261 await collection.burn(alice);215 await collection.burn(alice);
262 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);216 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
263 await expect(confirmSponsorshipTx()).to.be.rejected;217 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
264 });
265 });218 });
266219
267 it('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async () => {220 itSub('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async ({helper}) => {
268 await usingPlaygrounds(async (helper) => {
269 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});221 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
270 await collection.setSponsor(alice, bob.address);222 await collection.setSponsor(alice, bob.address);
271 await collection.confirmSponsorship(bob);223 await collection.confirmSponsorship(bob);
272 const [ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([0n, 0n], donor);
273 const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});224 const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});
274 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);225 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);
275 const transferTx = async () => token.transfer(senderZeroBalance, {Substrate: alice.address});226 const transferTx = async () => token.transfer(senderZeroBalance, {Substrate: alice.address});
276 await expect(transferTx()).to.be.rejected;227 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
277 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);228 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);
278 expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);229 expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);
279 });
280 });230 });
281});231});
282232
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.2// This file is part of Unique Network.
33
4// Unique Network is free software: you can redistribute it and/or modify4// Unique Network is free software: you can redistribute itSub and/or modify
5// it under the terms of the GNU General Public License as published by5// itSub under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is distributed in the hope that itSub will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
1313
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17import chai from 'chai';
18import chaiAsPromised from 'chai-as-promised';
19import {usingPlaygrounds} from './util/playgrounds';17import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
20import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';
21import {IProperty} from './util/playgrounds/types';19import {IProperty} from './util/playgrounds/types';
22
23chai.use(chaiAsPromised);
24const expect = chai.expect;
25
26let donor: IKeyringPair;
27
28before(async () => {
29 await usingPlaygrounds(async (_, privateKey) => {
30 donor = privateKey('//Alice');
31 });
32});
33
34let alice: IKeyringPair;
3520
36describe('integration test: ext. createCollection():', () => {21describe('integration test: ext. createCollection():', () => {
22 let alice: IKeyringPair;
23
37 before(async () => {24 before(async () => {
38 await usingPlaygrounds(async (helper) => {25 await usingPlaygrounds(async (helper, privateKey) => {
26 const donor = privateKey('//Alice');
39 [alice] = await helper.arrange.createAccounts([100n], donor);27 [alice] = await helper.arrange.createAccounts([100n], donor);
40 });28 });
41 });29 });
42 it('Create new NFT collection', async () => {30 itSub('Create new NFT collection', async ({helper}) => {
43 await usingPlaygrounds(async (helper) => {31
44 await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});32 await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
45 });
46 });33 });
47 it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {34 itSub('Create new NFT collection whith collection_name of maximum length (64 bytes)', async ({helper}) => {
48 await usingPlaygrounds(async (helper) => {35
49 await helper.nft.mintCollection(alice, {name: 'A'.repeat(64), description: 'descr', tokenPrefix: 'COL'});36 await helper.nft.mintCollection(alice, {name: 'A'.repeat(64), description: 'descr', tokenPrefix: 'COL'});
50 });
51 });37 });
52 it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {38 itSub('Create new NFT collection whith collection_description of maximum length (256 bytes)', async ({helper}) => {
53 await usingPlaygrounds(async (helper) => {39
54 await helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(256), tokenPrefix: 'COL'});40 await helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(256), tokenPrefix: 'COL'});
55 });
56 });41 });
57 it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {42 itSub('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async ({helper}) => {
58 await usingPlaygrounds(async (helper) => {43
59 await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(16)});44 await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(16)});
60 });
61 });45 });
62 it('Create new Fungible collection', async () => {46 itSub('Create new Fungible collection', async ({helper}) => {
63 await usingPlaygrounds(async (helper) => {47
64 await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 0);48 await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 0);
65 });
66 });49 });
67 it('Create new ReFungible collection', async function() {50 itSub.ifWithPallets('Create new ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
68 await usingPlaygrounds(async (helper) => {51
69 await helper.rft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});52 await helper.rft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
70 });53 });
71 });
7254
73 it('create new collection with properties', async () => {55 itSub('create new collection with properties', async ({helper}) => {
74 await usingPlaygrounds(async (helper) => {56
75 await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',57 await helper.nft.mintCollection(alice, {
58 name: 'name', description: 'descr', tokenPrefix: 'COL',
76 properties: [{key: 'key1', value: 'val1'}],59 properties: [{key: 'key1', value: 'val1'}],
77 tokenPropertyPermissions: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}],60 tokenPropertyPermissions: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}],
78 });61 });
79 });
80 });62 });
8163
82 it('Create new collection with extra fields', async () => {64 itSub('Create new collection with extra fields', async ({helper}) => {
83 await usingPlaygrounds(async (helper) => {65
84 const collection = await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 8);66 const collection = await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 8);
85 await collection.setPermissions(alice, {access: 'AllowList'});67 await collection.setPermissions(alice, {access: 'AllowList'});
86 await collection.setLimits(alice, {accountTokenOwnershipLimit: 3});68 await collection.setLimits(alice, {accountTokenOwnershipLimit: 3});
94 expect(raw.permissions.access).to.be.equal('AllowList');76 expect(raw.permissions.access).to.be.equal('AllowList');
95 expect(raw.mode).to.be.deep.equal({Fungible: '8'});77 expect(raw.mode).to.be.deep.equal({Fungible: '8'});
96 expect(limits.accountTokenOwnershipLimit).to.be.equal(3);78 expect(limits.accountTokenOwnershipLimit).to.be.equal(3);
97 });
98 });79 });
9980
100 it('New collection is not external', async () => {81 itSub('New collection is not external', async ({helper}) => {
101 await usingPlaygrounds(async (helper) => {82
102 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});83 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
103 const data = await collection.getData();84 const data = await collection.getData();
104 expect(data?.raw.readOnly).to.be.false;85 expect(data?.raw.readOnly).to.be.false;
105 });
106 });86 });
107});87});
10888
109describe('(!negative test!) integration test: ext. createCollection():', () => {89describe('(!negative test!) integration test: ext. createCollection():', () => {
90 let alice: IKeyringPair;
91
92 before(async () => {
93 await usingPlaygrounds(async (helper, privateKey) => {
94 const donor = privateKey('//Alice');
95 [alice] = await helper.arrange.createAccounts([100n], donor);
96 });
97 });
98
110 it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {99 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {
111 await usingPlaygrounds(async (helper) => {
112 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});100 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});
113 await expect(mintCollectionTx()).to.be.rejected;101 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
114 });
115 });102 });
116 it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {103 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {
117 await usingPlaygrounds(async (helper) => {
118 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});104 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});
119 await expect(mintCollectionTx()).to.be.rejected;105 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
120 });
121 });106 });
122 it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {107 itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {
123 await usingPlaygrounds(async (helper) => {108
124 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});109 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});
125 await expect(mintCollectionTx()).to.be.rejected;110 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
126 });
127 });111 });
128 it('(!negative test!) fails when bad limits are set', async () => {112 itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {
129 await usingPlaygrounds(async (helper) => {113
130 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});114 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});
131 await expect(mintCollectionTx()).to.be.rejected;115 await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
132 });
133 });116 });
134117
135 it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {118 itSub('(!negative test!) create collection with incorrect property limit (64 elements)', async ({helper}) => {
136 const props: IProperty[] = [];119 const props: IProperty[] = [];
137120
138 for (let i = 0; i < 65; i++) {121 for (let i = 0; i < 65; i++) {
139 props.push({key: `key${i}`, value: `value${i}`});122 props.push({key: `key${i}`, value: `value${i}`});
140 }123 }
141 await usingPlaygrounds(async (helper) => {
142 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});124 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
143 await expect(mintCollectionTx()).to.be.rejected;125 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
144 });
145 });126 });
146127
147 it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {128 itSub('(!negative test!) create collection with incorrect property limit (40 kb)', async ({helper}) => {
148 const props: IProperty[] = [];129 const props: IProperty[] = [];
149130
150 for (let i = 0; i < 32; i++) {131 for (let i = 0; i < 32; i++) {
151 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});132 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});
152 }133 }
153 await usingPlaygrounds(async (helper) => {134
154 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});135 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
155 await expect(mintCollectionTx()).to.be.rejected;136 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
156 });
157 });137 });
158});138});
159139
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.2// This file is part of Unique Network.
33
4// Unique Network is free software: you can redistribute it and/or modify4// Unique Network is free software: you can redistribute itSub and/or modify
5// it under the terms of the GNU General Public License as published by5// itSub under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is distributed in the hope that itSub will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
1313
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// 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/>.
1616
17import chai from 'chai';
18import chaiAsPromised from 'chai-as-promised';
19import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18
20import {19import {
21 createCollection,20 createCollection,
22 itApi,21 itApi,
23 normalizeAccountId,22 normalizeAccountId,
24 getCreateItemResult,23 getCreateItemResult,
25} from './util/helpers';24} from './util/helpers';
25
26import {usingPlaygrounds} from './util/playgrounds';26import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
27import {IProperty} from './util/playgrounds/types';27import {IProperty} from './util/playgrounds/types';
28import {executeTransaction} from './substrate/substrate-api';28import {executeTransaction} from './substrate/substrate-api';
2929
30chai.use(chaiAsPromised);
31const expect = chai.expect;
32
33let donor: IKeyringPair;
34
35before(async () => {
36 await usingPlaygrounds(async (_, privateKey) => {
37 donor = privateKey('//Alice');
38 });
39});
40
41let alice: IKeyringPair;
42let bob: IKeyringPair;
4330
44describe('integration test: ext. ():', () => {31describe('integration test: ext. ():', () => {
32 let alice: IKeyringPair;
33 let bob: IKeyringPair;
34
45 before(async () => {35 before(async () => {
46 await usingPlaygrounds(async (helper) => {36 await usingPlaygrounds(async (helper, privateKey) => {
37 const donor = privateKey('//Alice');
47 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);38 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
48 });39 });
49 });40 });
5041
51 it('Create new item in NFT collection', async () => {42 itSub('Create new item in NFT collection', async ({helper}) => {
52 await usingPlaygrounds(async (helper) => {
53 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});43 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
54 await collection.mintToken(alice, {Substrate: alice.address});44 await collection.mintToken(alice, {Substrate: alice.address});
55 });
56 });45 });
57 it('Create new item in Fungible collection', async () => {46 itSub('Create new item in Fungible collection', async ({helper}) => {
58 await usingPlaygrounds(async (helper) => {
59 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);47 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
60 await collection.mint(alice, {Substrate: alice.address}, 10n);48 await collection.mint(alice, 10n, {Substrate: alice.address});
61 });
62 });49 });
63 itApi.skip('Check events on create new item in Fungible collection', async ({api}) => {50 itApi.skip('Check events on create new item in Fungible collection', async ({api}) => {
64 const createMode = 'Fungible';51 const createMode = 'Fungible';
86 }73 }
87
88 });74 });
89 it('Create new item in ReFungible collection', async function() {75 itSub.ifWithPallets('Create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
90 await usingPlaygrounds(async (helper) => {
91 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});76 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
92 await collection.mintToken(alice, {Substrate: alice.address}, 100n);77 await collection.mintToken(alice, 100n, {Substrate: alice.address});
93 });78 });
94 });
95 it('Create new item in NFT collection with collection admin permissions', async () => {79 itSub('Create new item in NFT collection with collection admin permissions', async ({helper}) => {
96 await usingPlaygrounds(async (helper) => {
97 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});80 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
98 await collection.addAdmin(alice, {Substrate: bob.address});81 await collection.addAdmin(alice, {Substrate: bob.address});
99 await collection.mintToken(bob, {Substrate: alice.address});82 await collection.mintToken(bob, {Substrate: alice.address});
100 });
101 });83 });
102 it('Create new item in Fungible collection with collection admin permissions', async () => {84 itSub('Create new item in Fungible collection with collection admin permissions', async ({helper}) => {
103 await usingPlaygrounds(async (helper) => {
104 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);85 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
105 await collection.addAdmin(alice, {Substrate: bob.address});86 await collection.addAdmin(alice, {Substrate: bob.address});
106 await collection.mint(bob, {Substrate: alice.address}, 10n);87 await collection.mint(bob, 10n, {Substrate: alice.address});
107 });
108 });88 });
109 it('Create new item in ReFungible collection with collection admin permissions', async function() {89 itSub.ifWithPallets('Create new item in ReFungible collection with collection admin permissions', [Pallets.ReFungible], async ({helper}) => {
110 await usingPlaygrounds(async (helper) => {
111 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});90 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
112 await collection.addAdmin(alice, {Substrate: bob.address});91 await collection.addAdmin(alice, {Substrate: bob.address});
113 await collection.mintToken(bob, {Substrate: alice.address}, 100n);92 await collection.mintToken(bob, 100n, {Substrate: alice.address});
114 });93 });
115 });
11694
117 it('Set property Admin', async () => {95 itSub('Set property Admin', async ({helper}) => {
118 await usingPlaygrounds(async (helper) => {
119 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',96 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
120 properties: [{key: 'k', value: 'v'}],97 properties: [{key: 'k', value: 'v'}],
121 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}}],98 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}}],
122 });99 });
123 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);100 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
124 });
125 });101 });
126102
127 it('Set property AdminConst', async () => {103 itSub('Set property AdminConst', async ({helper}) => {
128 await usingPlaygrounds(async (helper) => {
129 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',104 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
130 properties: [{key: 'k', value: 'v'}],105 properties: [{key: 'k', value: 'v'}],
131 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}}],106 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}}],
132 });107 });
133 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);108 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
134 });
135 });109 });
136110
137 it('Set property itemOwnerOrAdmin', async () => {111 itSub('Set property itemOwnerOrAdmin', async ({helper}) => {
138 await usingPlaygrounds(async (helper) => {
139 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',112 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',
140 properties: [{key: 'k', value: 'v'}],113 properties: [{key: 'k', value: 'v'}],
141 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}}],114 tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}}],
142 });115 });
143 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);116 await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
144 });
145 });117 });
146118
147 it('Check total pieces of Fungible token', async () => {119 itSub('Check total pieces of Fungible token', async ({helper}) => {
148 await usingPlaygrounds(async (helper) => {
149 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);120 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
150 const amount = 10n;121 const amount = 10n;
151 await collection.mint(alice, {Substrate: bob.address}, amount);122 await collection.mint(alice, amount, {Substrate: bob.address});
152 {123 {
153 const totalPieces = await collection.getTotalPieces();124 const totalPieces = await collection.getTotalPieces();
154 expect(totalPieces).to.be.equal(amount);125 expect(totalPieces).to.be.equal(amount);
158 const totalPieces = await collection.getTotalPieces();129 const totalPieces = await collection.getTotalPieces();
159 expect(totalPieces).to.be.equal(amount);130 expect(totalPieces).to.be.equal(amount);
160 }131 }
161 });
162 });132 });
163133
164 it('Check total pieces of NFT token', async () => {134 itSub('Check total pieces of NFT token', async ({helper}) => {
165 await usingPlaygrounds(async (helper) => {
166 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});135 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
167 const amount = 1n;136 const amount = 1n;
168 const token = await collection.mintToken(alice, {Substrate: bob.address});137 const token = await collection.mintToken(alice, {Substrate: bob.address});
175 const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);144 const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);
176 expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);145 expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);
177 }146 }
178 });
179 });147 });
180148
181 it('Check total pieces of ReFungible token', async function() {149 itSub.ifWithPallets('Check total pieces of ReFungible token', [Pallets.ReFungible], async ({helper}) => {
182 await usingPlaygrounds(async (helper) => {
183 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});150 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
184 const amount = 100n;151 const amount = 100n;
185 const token = await collection.mintToken(alice, {Substrate: bob.address}, amount);152 const token = await collection.mintToken(alice, amount, {Substrate: bob.address});
186 {153 {
187 const totalPieces = await token.getTotalPieces();154 const totalPieces = await token.getTotalPieces();
188 expect(totalPieces).to.be.equal(amount);155 expect(totalPieces).to.be.equal(amount);
192 const totalPieces = await token.getTotalPieces();159 const totalPieces = await token.getTotalPieces();
193 expect(totalPieces).to.be.equal(amount);160 expect(totalPieces).to.be.equal(amount);
194 }161 }
195 });162 });
196 });
197});163});
198164
199describe('Negative integration test: ext. createItem():', () => {165describe('Negative integration test: ext. createItem():', () => {
166 let alice: IKeyringPair;
167 let bob: IKeyringPair;
168
200 before(async () => {169 before(async () => {
201 await usingPlaygrounds(async (helper) => {170 await usingPlaygrounds(async (helper, privateKey) => {
171 const donor = privateKey('//Alice');
202 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);172 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
203 });173 });
204 });174 });
205175
206 it('Regular user cannot create new item in NFT collection', async () => {176 itSub('Regular user cannot create new item in NFT collection', async ({helper}) => {
207 await usingPlaygrounds(async (helper) => {
208 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});177 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
209 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});178 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});
210 await expect(mintTx()).to.be.rejected;179 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
211 });
212 });180 });
213 it('Regular user cannot create new item in Fungible collection', async () => {181 itSub('Regular user cannot create new item in Fungible collection', async ({helper}) => {
214 await usingPlaygrounds(async (helper) => {
215 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);182 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
216 const mintTx = async () => collection.mint(bob, {Substrate: bob.address}, 10n);183 const mintTx = async () => collection.mint(bob, 10n, {Substrate: bob.address});
217 await expect(mintTx()).to.be.rejected;184 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
218 });
219 });185 });
220 it('Regular user cannot create new item in ReFungible collection', async () => {186 itSub('Regular user cannot create new item in ReFungible collection', async ({helper}) => {
221 await usingPlaygrounds(async (helper) => {
222 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});187 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
223 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});188 const mintTx = async () => collection.mintToken(bob, 100n, {Substrate: bob.address});
224 await expect(mintTx()).to.be.rejected;189 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
225 });
226 });190 });
227191
228 it('No editing rights', async () => {192 itSub('No editing rights', async ({helper}) => {
229 await usingPlaygrounds(async (helper) => {
230 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',193 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
231 tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],194 tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],
232 });195 });
233 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);196 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
234 await expect(mintTx()).to.be.rejected;197 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
235 });
236 });198 });
237199
238 it('User doesnt have editing rights', async () => {200 itSub('User doesnt have editing rights', async ({helper}) => {
239 await usingPlaygrounds(async (helper) => {
240 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',201 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
241 tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],202 tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
242 });203 });
243 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);204 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
244 await expect(mintTx()).to.be.rejected;205 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
245 });
246 });206 });
247207
248 it('Adding property without access rights', async () => {208 itSub('Adding property without access rights', async ({helper}) => {
249 await usingPlaygrounds(async (helper) => {
250 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});209 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
251 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);210 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
252 await expect(mintTx()).to.be.rejected;211 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
253 });
254 });212 });
255213
256 it('Adding more than 64 prps', async () => {214 itSub('Adding more than 64 prps', async ({helper}) => {
257 const props: IProperty[] = [];215 const props: IProperty[] = [];
258216
259 for (let i = 0; i < 65; i++) {217 for (let i = 0; i < 65; i++) {
260 props.push({key: `key${i}`, value: `value${i}`});218 props.push({key: `key${i}`, value: `value${i}`});
261 }219 }
262220
263 await usingPlaygrounds(async (helper) => {221
264 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});222 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
265 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);223 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);
266 await expect(mintTx()).to.be.rejected;224 await expect(mintTx()).to.be.rejectedWith('Verification Error');
267 });
268 });225 });
269226
270 it('Trying to add bigger property than allowed', async () => {227 itSub('Trying to add bigger property than allowed', async ({helper}) => {
271 await usingPlaygrounds(async (helper) => {
272 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',228 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
273 tokenPropertyPermissions: [229 tokenPropertyPermissions: [
274 {key: 'k1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},230 {key: 'k1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},
279 {key: 'k1', value: 'vvvvvv'.repeat(5000)},235 {key: 'k1', value: 'vvvvvv'.repeat(5000)},
280 {key: 'k2', value: 'vvv'.repeat(5000)},236 {key: 'k2', value: 'vvv'.repeat(5000)},
281 ]);237 ]);
282 await expect(mintTx()).to.be.rejected;238 await expect(mintTx()).to.be.rejectedWith(/common\.NoSpaceForProperty/);
283 });
284 });239 });
285240
286 it('Check total pieces for invalid Fungible token', async () => {241 itSub('Check total pieces for invalid Fungible token', async ({helper}) => {
287 await usingPlaygrounds(async (helper) => {
288 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);242 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
289 const invalidTokenId = 1_000_000;243 const invalidTokenId = 1_000_000;
290 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;244 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
291 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);245 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
292 });
293 });246 });
294247
295 it('Check total pieces for invalid NFT token', async () => {248 itSub('Check total pieces for invalid NFT token', async ({helper}) => {
296 await usingPlaygrounds(async (helper) => {
297 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});249 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
298 const invalidTokenId = 1_000_000;250 const invalidTokenId = 1_000_000;
299 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;251 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
300 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);252 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
301 });
302 });253 });
303254
304 it('Check total pieces for invalid Refungible token', async function() {255 itSub.ifWithPallets('Check total pieces for invalid Refungible token', [Pallets.ReFungible], async ({helper}) => {
305 await usingPlaygrounds(async (helper) => {
306 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});256 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
307 const invalidTokenId = 1_000_000;257 const invalidTokenId = 1_000_000;
308 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;258 expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;
309 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);259 expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);
310 });260 });
311 });
312});261});
313262
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
2// This file is part of Unique Network.2// This file is part of Unique Network.
33
4// Unique Network is free software: you can redistribute it and/or modify4// Unique Network is free software: you can redistribute itSub and/or modify
5// it under the terms of the GNU General Public License as published by5// itSub under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is distributed in the hope that it will be useful,9// Unique Network is distributed in the hope that itSub will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
15// 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/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import chai from 'chai';
19import chaiAsPromised from 'chai-as-promised';
20import {18import {
21 normalizeAccountId,19 normalizeAccountId,
22} from './util/helpers';20} from './util/helpers';
23import {usingPlaygrounds} from './util/playgrounds';21import {usingPlaygrounds, expect, Pallets, itSub} from './util/playgrounds';
2422
25chai.use(chaiAsPromised);
26const expect = chai.expect;
27
28let donor: IKeyringPair;
29
30before(async () => {
31 await usingPlaygrounds(async (_, privateKey) => {
32 donor = privateKey('//Alice');
33 });
34});
3523
36describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {24describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {
37 let alice: IKeyringPair;25 let alice: IKeyringPair;
3826
39 before(async () => {27 before(async () => {
40 await usingPlaygrounds(async (helper) => {28 await usingPlaygrounds(async (helper, privateKey) => {
29 const donor = privateKey('//Alice');
41 [alice] = await helper.arrange.createAccounts([100n], donor);30 [alice] = await helper.arrange.createAccounts([100n], donor);
42 });31 });
43 });32 });
4433
45 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {34 itSub('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async ({helper}) => {
46 await usingPlaygrounds(async (helper) => {
47 const collection = await helper.nft.mintCollection(alice, {35 const collection = await helper.nft.mintCollection(alice, {
48 name: 'name',36 name: 'name',
49 description: 'descr',37 description: 'descr',
63 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});51 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
64 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);52 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
65 }53 }
66 });
67 });54 });
6855
69 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {56 itSub('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async ({helper}) => {
70 await usingPlaygrounds(async (helper) => {
71 const collection = await helper.ft.mintCollection(alice, {57 const collection = await helper.ft.mintCollection(alice, {
72 name: 'name',58 name: 'name',
73 description: 'descr',59 description: 'descr',
78 {value: 2n},64 {value: 2n},
79 {value: 3n},65 {value: 3n},
80 ];66 ];
81 await helper.ft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);67 await helper.ft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, args, {Substrate: alice.address});
82 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(6n);68 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(6n);
83 });
84 });69 });
8570
86 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {71 itSub.ifWithPallets('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', [Pallets.ReFungible], async ({helper}) => {
87 await usingPlaygrounds(async (helper) => {
88 const collection = await helper.rft.mintCollection(alice, {72 const collection = await helper.rft.mintCollection(alice, {
89 name: 'name',73 name: 'name',
90 description: 'descr',74 description: 'descr',
100 for (const [i, token] of tokens.entries()) {84 for (const [i, token] of tokens.entries()) {
101 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(BigInt(i + 1));85 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(BigInt(i + 1));
102 }86 }
103 });87 });
104 });
10588
106 it('Can mint amount of items equals to collection limits', async () => {89 itSub('Can mint amount of items equals to collection limits', async ({helper}) => {
107 await usingPlaygrounds(async (helper) => {
108 const collection = await helper.nft.mintCollection(alice, {90 const collection = await helper.nft.mintCollection(alice, {
109 name: 'name',91 name: 'name',
110 description: 'descr',92 description: 'descr',
115 });97 });
116 const args = [{}, {}];98 const args = [{}, {}];
117 await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);99 await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
118 });
119 });100 });
120101
121 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {102 itSub('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async ({helper}) => {
122 await usingPlaygrounds(async (helper) => {
123 const collection = await helper.nft.mintCollection(alice, {103 const collection = await helper.nft.mintCollection(alice, {
124 name: 'name',104 name: 'name',
125 description: 'descr',105 description: 'descr',
139 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});119 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
140 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);120 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
141 }121 }
142 });
143 });122 });
144123
145 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {124 itSub('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async ({helper}) => {
146 await usingPlaygrounds(async (helper) => {
147 const collection = await helper.nft.mintCollection(alice, {125 const collection = await helper.nft.mintCollection(alice, {
148 name: 'name',126 name: 'name',
149 description: 'descr',127 description: 'descr',
163 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});141 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
164 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);142 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
165 }143 }
166 });
167 });144 });
168145
169 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {146 itSub('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async ({helper}) => {
170 await usingPlaygrounds(async (helper) => {
171 const collection = await helper.nft.mintCollection(alice, {147 const collection = await helper.nft.mintCollection(alice, {
172 name: 'name',148 name: 'name',
173 description: 'descr',149 description: 'descr',
187 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});163 expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});
188 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);164 expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);
189 }165 }
190 });
191 });166 });
192});167});
193168
196 let bob: IKeyringPair;171 let bob: IKeyringPair;
197172
198 before(async () => {173 before(async () => {
199 await usingPlaygrounds(async (helper) => {174 await usingPlaygrounds(async (helper, privateKey) => {
175 const donor = privateKey('//Alice');
200 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);176 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
201 });177 });
202 });178 });
203179
204 it('Regular user cannot create items in active NFT collection', async () => {180 itSub('Regular user cannot create items in active NFT collection', async ({helper}) => {
205 await usingPlaygrounds(async (helper) => {
206 const collection = await helper.nft.mintCollection(alice, {181 const collection = await helper.nft.mintCollection(alice, {
207 name: 'name',182 name: 'name',
208 description: 'descr',183 description: 'descr',
214 ];189 ];
215 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);190 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
216 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);191 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
217 });
218 });192 });
219193
220 it('Regular user cannot create items in active Fungible collection', async () => {194 itSub('Regular user cannot create items in active Fungible collection', async ({helper}) => {
221 await usingPlaygrounds(async (helper) => {
222 const collection = await helper.ft.mintCollection(alice, {195 const collection = await helper.ft.mintCollection(alice, {
223 name: 'name',196 name: 'name',
224 description: 'descr',197 description: 'descr',
229 {value: 2n},202 {value: 2n},
230 {value: 3n},203 {value: 3n},
231 ];204 ];
232 const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);205 const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});
233 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);206 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
234 });
235 });207 });
236208
237 it('Regular user cannot create items in active ReFungible collection', async function() {209 itSub.ifWithPallets('Regular user cannot create items in active ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
238 await usingPlaygrounds(async (helper) => {
239 const collection = await helper.rft.mintCollection(alice, {210 const collection = await helper.rft.mintCollection(alice, {
240 name: 'name',211 name: 'name',
241 description: 'descr',212 description: 'descr',
248 ];219 ];
249 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);220 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
250 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);221 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
251 });222 });
252 });
253223
254 it('Create token in not existing collection', async () => {224 itSub('Create token in not existing collection', async ({helper}) => {
255 await usingPlaygrounds(async (helper) => {
256 const collectionId = 1_000_000;225 const collectionId = 1_000_000;
257 const args = [226 const args = [
258 {},227 {},
259 {},228 {},
260 ];229 ];
261 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);230 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);
262 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);231 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
263 });
264 });232 });
265233
266 it('Create NFTs that has reached the maximum data limit', async function() {234 itSub('Create NFTs that has reached the maximum data limit', async ({helper}) => {
267 await usingPlaygrounds(async (helper) => {
268 const collection = await helper.nft.mintCollection(alice, {235 const collection = await helper.nft.mintCollection(alice, {
269 name: 'name',236 name: 'name',
270 description: 'descr',237 description: 'descr',
279 {properties: [{key: 'data', value: 'C'.repeat(32769)}]},246 {properties: [{key: 'data', value: 'C'.repeat(32769)}]},
280 ];247 ];
281 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);248 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
282 await expect(mintTx()).to.be.rejected;249 await expect(mintTx()).to.be.rejectedWith('Verification Error');
283 });250 });
284 });
285251
286 it('Create Refungible tokens that has reached the maximum data limit', async function() {252 itSub.ifWithPallets('Create Refungible tokens that has reached the maximum data limit', [Pallets.ReFungible], async ({helper}) => {
287 await usingPlaygrounds(async (helper) => {
288 const collection = await helper.rft.mintCollection(alice, {253 const collection = await helper.rft.mintCollection(alice, {
289 name: 'name',254 name: 'name',
290 description: 'descr',255 description: 'descr',
299 {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},264 {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},
300 ];265 ];
301 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);266 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
302 await expect(mintTx()).to.be.rejected;267 await expect(mintTx()).to.be.rejectedWith('Verification Error');
303 });268 });
304 });
305269
306 it('Create tokens with different types', async () => {270 itSub.ifWithPallets('Create tokens with different types', [Pallets.ReFungible], async ({helper}) => {
307 await usingPlaygrounds(async (helper) => {
308 const {collectionId} = await helper.nft.mintCollection(alice, {271 const {collectionId} = await helper.nft.mintCollection(alice, {
309 name: 'name',272 name: 'name',
310 description: 'descr',273 description: 'descr',
311 tokenPrefix: 'COL',274 tokenPrefix: 'COL',
312 });275 });
313276
314 //FIXME:
315 const types = ['NFT', 'Fungible', 'ReFungible'];277 const types = ['NFT', 'Fungible', 'ReFungible'];
316 const mintTx = helper.api?.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), types);278 const mintTx = helper.api?.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), types);
317 await expect(helper.signTransaction(alice, mintTx)).to.be.rejected;279 await expect(helper.signTransaction(alice, mintTx)).to.be.rejected;
318 });
319 });280 });
320281
321 it('Create tokens with different data limits <> maximum data limit', async () => {282 itSub('Create tokens with different data limits <> maximum data limit', async ({helper}) => {
322 await usingPlaygrounds(async (helper) => {
323 const collection = await helper.nft.mintCollection(alice, {283 const collection = await helper.nft.mintCollection(alice, {
324 name: 'name',284 name: 'name',
325 description: 'descr',285 description: 'descr',
333 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},293 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},
334 ];294 ];
335 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);295 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
336 await expect(mintTx()).to.be.rejected;296 await expect(mintTx()).to.be.rejectedWith('Verification Error');
337 });
338 });297 });
339298
340 it('Fails when minting tokens exceeds collectionLimits amount', async () => {299 itSub('Fails when minting tokens exceeds collectionLimits amount', async ({helper}) => {
341 await usingPlaygrounds(async (helper) => {
342 const collection = await helper.nft.mintCollection(alice, {300 const collection = await helper.nft.mintCollection(alice, {
343 name: 'name',301 name: 'name',
344 description: 'descr',302 description: 'descr',
355 {},313 {},
356 ];314 ];
357 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);315 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
358 await expect(mintTx()).to.be.rejected;316 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
359 });
360 });317 });
361318
362 it('User doesnt have editing rights', async () => {319 itSub('User doesnt have editing rights', async ({helper}) => {
363 await usingPlaygrounds(async (helper) => {
364 const collection = await helper.nft.mintCollection(alice, {320 const collection = await helper.nft.mintCollection(alice, {
365 name: 'name',321 name: 'name',
366 description: 'descr',322 description: 'descr',
373 {properties: [{key: 'data', value: 'A'}]},329 {properties: [{key: 'data', value: 'A'}]},
374 ];330 ];
375 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);331 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
376 await expect(mintTx()).to.be.rejected;332 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
377 });
378 });333 });
379334
380 it('Adding property without access rights', async () => {335 itSub('Adding property without access rights', async ({helper}) => {
381 await usingPlaygrounds(async (helper) => {
382 const collection = await helper.nft.mintCollection(alice, {336 const collection = await helper.nft.mintCollection(alice, {
383 name: 'name',337 name: 'name',
384 description: 'descr',338 description: 'descr',
394 {properties: [{key: 'data', value: 'A'}]},348 {properties: [{key: 'data', value: 'A'}]},
395 ];349 ];
396 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);350 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
397 await expect(mintTx()).to.be.rejected;351 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
398 });
399 });352 });
400353
401 it('Adding more than 64 prps', async () => {354 itSub('Adding more than 64 prps', async ({helper}) => {
402 await usingPlaygrounds(async (helper) => {
403 const collection = await helper.nft.mintCollection(alice, {355 const collection = await helper.nft.mintCollection(alice, {
404 name: 'name',356 name: 'name',
405 description: 'descr',357 description: 'descr',
418 ];370 ];
419371
420 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);372 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
421 await expect(mintTx()).to.be.rejected;373 await expect(mintTx()).to.be.rejectedWith('Verification Error');
422 });
423 });374 });
424});375});
425376