git.delta.rocks / unique-network / refs/commits / c4e0a12cf681

difftreelog

CORE-410 Add test for collection properties

Trubnikov Sergey2022-06-27parent: #956d7c1.patch.diff
in: master

1 file changed

modifiedtests/src/refungible.test.tsdiffbeforeafterboth
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 {default as usingApi} from './substrate/substrate-api';17import {default as usingApi, executeTransaction} from './substrate/substrate-api';
18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';
19import {19import {
20 createCollectionExpectSuccess,20 createCollectionExpectSuccess,
30 transfer,30 transfer,
31 burnItem,31 burnItem,
32 repartitionRFT,32 repartitionRFT,
33 createCollectionWithPropsExpectSuccess,
34 getDetailedCollectionInfo,
33} from './util/helpers';35} from './util/helpers';
3436
35import chai from 'chai';37import chai from 'chai';
188 });190 });
189});191});
192
193describe('Test Refungible properties:', () => {
194 before(async () => {
195 await usingApi(async (api, privateKeyWrapper) => {
196 alice = privateKeyWrapper('//Alice');
197 bob = privateKeyWrapper('//Bob');
198 });
199 });
200
201 it('Сreate new collection with properties', async () => {
202 await usingApi(async api => {
203 const properties = [{key: 'key1', value: 'val1'}];
204 const propertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];
205 const collectionId = await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},
206 properties: properties,
207 propPerm: propertyPermissions,
208 });
209 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
210 expect(collection.properties.toHuman()).to.be.deep.equal(properties);
211 expect(collection.tokenPropertyPermissions.toHuman()).to.be.deep.equal(propertyPermissions);
212 });
213 });
214
215 it.only('Set properties for exist collection', async () => {
216 await usingApi(async api => {
217 const collectionId = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},
218 });
219
220 const properties = [{key: 'key1', value: 'val1'}];
221 // await expect(executeTransaction(
222 // api,
223 // alice,
224 // api.tx.unique.setCollectionProperties(collectionId, properties),
225 // )).to.not.be.rejected;
226
227 const propertyPermissions = [
228 {key: 'key1', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},
229 {key: 'key2', permission: {collectionAdmin: false, mutable: true, tokenOwner: false}},
230 ];
231 await expect(executeTransaction(
232 api,
233 alice,
234 api.tx.unique.setTokenPropertyPermissions(collectionId, propertyPermissions),
235 )).to.not.be.rejected;
236
237 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
238 expect(collection.properties.toHuman()).to.be.deep.equal(properties);
239 expect(collection.tokenPropertyPermissions.toHuman()).to.be.deep.equal(propertyPermissions);
240 });
241 });
242});
190243